I use Laravel and Eloquent and I want get data from two table via relation.
For example i want select all book in categories that category status is active.
class Book extends Model
{
public $belongsTo = [
'category' => '..\Models\Categories',
];
public function categories() {
return $this->belongsTo('..\Models\Categories');
}
}
In controller i can use next code for select all books.
Book::with('categories');
Is there way to select all book in categories that category status is active?