public static function with($relations) { if (is_string($relations)) { $relations = func_get_args(); } $instance = new static(); return $instance->newQuery()->with($relations); }
public function getRoleByName($roleName) { $query = $this->model->with('roles')->whereHas('roles', function ($q) use($roleName) { $q->where('name', '=', $roleName); })->get(); return $query; }