Hy all I am a beginner in laravel.I am having trouble with loading relation based on a condition.
There is three tables picture, videos, and order.
order table contains the following fields
1.type => 0 or 1 (photo or video)
2.type_id
Order table contains the following relations
public function pictures()
{
return $this->hasMany('App\Pictures','id', 'type_id);
}
public function videos()
{
return $this->hasMany('App\Videos', 'id', 'type_id');
}
I want to load picture relation with order only if type equals 0 and video if the type is 1. Please help
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2N87C03
via IFTTT
Aucun commentaire:
Enregistrer un commentaire