<?php
/**
 * Created by PhpStorm.
 * User: zhanghao
 * Date: 2019/4/1
 * Time: 14:42
 */

namespace App\Http\Controllers\Web\Hardware\Pad;

use App\Http\Controllers\Web\WebBaseController;
use Illuminate\Http\Request;
use App\Repositories\Jobfair\JobfairPersonSignedRepository;
use App\Services\Jobfair\JobfairPersonalJopApplyService;
use App\Repositories\Jobfair\JobfairPersonalJobsApplyRepository;
class PadInterviewController extends WebBaseController
{
    protected $jobfairPersonSignedRepository;
    protected $jobfairPersonalJopApplyService;
    protected $jobfairPersonalJobsApplyRepository;
    /**
     * PadInterviewController constructor.
     * @param JobfairPersonSignedRepository $jobfairPersonSignedRepository
     */
    public function __construct(JobfairPersonSignedRepository $jobfairPersonSignedRepository,JobfairPersonalJobsApplyRepository $jobfairPersonalJobsApplyRepository,JobfairPersonalJopApplyService $jobfairPersonalJopApplyService)
    {
        $this->jobfairPersonSignedRepository = $jobfairPersonSignedRepository;
        $this->jobfairPersonalJobsApplyRepository = $jobfairPersonalJobsApplyRepository;
        $this->jobfairPersonalJopApplyService = $jobfairPersonalJopApplyService;
    }

    public function list()
    {
        $jobfair_id = session('floorplan_stands.jobfair_id');
        $user = auth('web-company')->user();
        $result = $this->jobfairPersonSignedRepository->getSignedInterview(['jobfairid'=>$jobfair_id]);
        $where = [
            'jobfair_id'=>$jobfair_id,
            'company_id'=>$user->id,
        ];
        foreach ($result as &$value){
            $where['personal_uid'] = $value->uid;
            $value['flag'] =  $this->jobfairPersonalJobsApplyRepository->interviewFind($where);
        }
        return view('app.hardware.pad.interview_list',['result' => $result]);
    }

    public function interview(Request $request){
        $user = auth('web-company')->user();
        return $this->jobfairPersonalJopApplyService->interview($request,$user);
    }
}