public function all(array $columns = ['*'], array $with = [], $orders = [], $limit = 50, $page = 1)
{
$all = $this->model;
$all = $all->whereHas('classrooms.students', function ($q) {
$q->where('student_id', Auth::user()->owner_id);
})->with(['classrooms.students' => function ($q) {
$q->where('student_id', Auth::user()->owner_id);
}]);
if (!empty($with)) {
$all = $all->with($with);
}
foreach ($orders as $order) {
$order['order'] = isset($order['order']) ? $order['order'] : 'ASC';
$all = $all->orderBy($order['column'], $order['order']);
}
$all = $all->paginate($limit, $columns, 'page', $page);
return $all;
}