diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index 0c1be15..23da521 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -72,25 +72,24 @@ class WorkerController extends Controller } $status_work = $this->status_work; - $resumes = Worker::query()->with('users')->with('job_titles') - ->WhereHas('users', - function (Builder $query) { - $query->Where('is_worker', '=', '1')-> - Where('is_bd', '=', '0'); + $resumes = Worker::query()->with('users')->with('job_titles'); + $resumes = $resumes->whereHas('users', function (Builder $query) { + $query->Where('is_worker', '=', '1') + ->Where('is_bd', '=', '0'); }); if ($request->get('sort')) { $sort = $request->get('sort'); switch ($sort) { case 'name_up': - $resumes = $resumes->whereHas('users', function (Builder $query) { - $query = $query->orderBy('surname')->orderBy('id'); - }); + $resumes = $resumes->orderBy(User::select('surname') + ->whereColumn('Workers.user_id', 'users.id') + ); break; case 'name_down': - $resumes = $resumes->whereHas('users', function (Builder $query) { - $query = $query->orderByDesc('surname')->orderby('id'); - }); + $resumes = $resumes->orderByDesc(User::select('surname') + ->whereColumn('Workers.user_id', 'users.id') + ); break; case 'created_at_up': $resumes = $resumes->OrderBy('created_at')->orderBy('id'); break; case 'created_at_down': $resumes = $resumes->orderByDesc('created_at')->orderBy('id'); break; diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index 6da6769..acbc4b2 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -10,8 +10,8 @@