I am currently using Laravel 4.2.
I have a Order belonging to a User :
class Order extend Eloquent
{
public function user ()
{
return $this->belongTo('User');
}
}
And a User hasMany Order :
class User extend Eloquent
{
public function orders ()
{
return $this->hasMany('Order');
}
}
I am able to do $user->orders to get the orders related to a user but I was wondering if it was possible to get the same result the other way around direcly with objects like in other ORMs. Something like Order::where('user', '=', User::find(1)).
I am currently using Laravel 4.2. I have a Order belonging to a User :
And a User hasMany Order :
I am able to do $user->orders to get the orders related to a user but I was wondering if it was possible to get the same result the other way around direcly with objects like in other ORMs. Something like
Order::where('user', '=', User::find(1))
.