http://laravel.com/docs/5.1/eloquent-relationships Define relationships in your models, e.g.
// App/Call
...
function place() {
return $this->belongsTo('App\Place');
}
You should be able to end up with:
$calls = \App\Call::with([
'places' => function ($query) { $query->select('id', 'name'); },
'departments' => function ($query) { $query->select('id', 'name'); },
'callStatuses' => function ($query) { $query->select('id', 'name'); },
...
])->get(['title', ...]);
$calls[0]->place->name;
$calls[0]->callStatus->name;
tanerkucukyuruk said:
http://laravel.com/docs/5.1/eloquent-relationships Define relationships in your models, e.g.
// App/Call ... function place() { return $this->belongsTo('App\Place'); }
You should be able to end up with:
$calls = \App\Call::with([ 'places' => function ($query) { $query->select('id', 'name'); }, 'departments' => function ($query) { $query->select('id', 'name'); }, 'callStatuses' => function ($query) { $query->select('id', 'name'); }, ... ])->get(['title', ...]); $calls[0]->place->name; $calls[0]->callStatus->name;
calls is related to places, and places is related to departaments.
with the work in this case?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community