WorkerController.php 2.13 KB
<?php

namespace App\Http\Controllers;

use App\Models\Static_worker;
use App\Models\Worker;
use Illuminate\Http\Request;

class WorkerController extends Controller
{
    public $status_work = Array(0 => 'Ищу работу', 1=> 'Не указано', 2=>'Не ищу работу');
    //профиль
    public function profile(Worker $worker) {
        $get_date = date('Y.m');

        $c = Static_worker::query()->where('year_month', '=', $get_date)
            ->where('user_id', '=', $worker->users->id)
            ->get();

        if ($c->count() > 0) {
            $upd = Static_worker::find($c[0]->id);
            $upd->lookin = $upd->lookin + 1;
            $upd->save();
        } else {
            $crt = new Static_worker();
            $crt->lookin = 1;
            $crt->year_month = $get_date;
            $crt->user_id = $worker->user_id;
            $crt->save();
        }

        $stat = Static_worker::query()->where('year_month', '=', $get_date)
                            ->where('user_id', '=', $worker->users->id)
                            ->get();

        return view('public.workers.profile', compact('worker', 'stat'));
    }

    // лист база резюме
    public function bd_resume() {
        $status_work = $this->status_work;
        $resumes = Worker::query()->with('users')->with('job_titles');

        $res_count = $resumes->count();
        $resumes = $resumes->paginate(5);

        return view('resume', compact('resumes', 'status_work', 'res_count'));
    }

    // анкета соискателя
    public function resume_profile(Worker $worker) {
        $status_work = $this->status_work;
        $Query = Worker::query()->with('users')->with('job_titles')
            ->with('place_worker')->with('sertificate')->with('prev_company')
            ->with('infobloks');
        $Query = $Query->where('id', '=', $worker->id);
        $Query = $Query->get();
        return view('worker', compact('Query', 'status_work'));
    }

    // скачать анкету соискателя
    public function resume_download(Worker $worker) {
        print_r('Резюме для скачивания');
    }
}