php - Laravel populating the current class from its ID -
I am looking at creating a solution using the famous in Larval 4 such as
$ message_id = 123; $ Message = new message (); If (! $ Message-> loadFromId ($ message_id)) {message 'Failed to get message'; } And {return $ message-> Get ('body'); } However I can not decide how to do this. I know that Larval Gas gives an example of return class to a 'search' method but it is not what I need. I want to be able to load the current class and want to return a boolean. I think there is a load method in Larval, for which relationship is required.
I think I can make a new method like 'LoadFrame ID', with a series of best ways I wanted. but I'm not sure. I think I will drag a 'relation' (whatever) from the database and will use it with the load method.
Can anyone help me with this?
This is the method for finding what you want:
$ Message_id = 123; $ Message = message: search ($ message_id); If (! $ Message) {return 'failed to receive message'; } And {return $ message-> Body; }
Comments
Post a Comment