My database structure like this: category: id, name Parents: category_id parent_id
id has parent categories like id used in parents model as foreign key category_id against have parents parent. parent_id actually is categor id. I want to get records like this SELECT category.name FROM category INNER JOIN category_parents ON category.id = category_parents.category_id WHERE category_parents.category_id=79 but in eloqent model relation ship.
https://laravel.com/docs/5.2/eloquent
There's also some "advanced wheres" somewhere in the documentation.
Thanks for reply me. But i want where clause in eloquent relationship that described above.
Try using whereHas, eg.
->whereHas('RelationshipName', function($query) {
$query('your-field', your-condition);
})
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community