lundi 29 février 2016

How to always append attributes to Laravel Eloquent model?

I was wondering how to always append some data to Eloquent model without the need of asking for it for example when getting Posts form database I want to append the user info for each user as:

{
    id: 1
    title: "My Post Title"
    body: "Some text"
    created_at: "2-28-2016"
    user:{
            id: 1,
            name: "john smith",
            email: "example@mail.com"
         }
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Lq9JdI
via IFTTT

Aucun commentaire:

Enregistrer un commentaire