Thursday, 15 March 2012

php - Laravel populating the current class from its ID -



php - Laravel populating the current class from its ID -

i'm looking build solution in laravel 4 using eloquent such as

$message_id = 123; $message = new message(); if(!$message->loadfromid($message_id)){ homecoming 'failed find message'; }else{ homecoming $message->get('body'); }

however cannot determine how this. know laravel gas 'find' method returns instance of class not need. want able load current class , homecoming boolean. understand laravel has load method requires relation.

i assume can create new method such 'loadfromid' series of laravel methods simulate want. i'm not sure. guess pull 'relation' (whatever is) database , utilize load method.

can help me this?

the find method want:

$message_id = 123; $message = message::find($message_id); if(!$message){ homecoming 'failed find message'; }else{ homecoming $message->body; }

php laravel-4 load eloquent

No comments:

Post a Comment