mercredi 26 octobre 2016

Laravel / Eloquent - Returning Related Table Columns At The Root Level and Not As Child Object Properties

When I use the with() method in the following fashion:

User::with('projects')->get();

I'll get a response that looks like:

Array(
    [0] => Array(
        [id] => 1
        [user_name] => big gulp
        [group_id] => 5
        [projects] => Array(
            [project_name] => new project
        )
    )
)

How do I get results which treats the columns related to the projects table as root level properties? I am looking for results that look like:

Array(
    [0] => Array(
        [id] => 1
        [user_name] => big gulp
        [group_id] => 5
        [project_name] => new project
    )
)



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

Aucun commentaire:

Enregistrer un commentaire