Пример #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     foreach (Slot::all() as $slot) {
         foreach (Recruiter::all() as $recruiter) {
             DB::table('interviews')->insert(['slot_id' => $slot->id, 'recruiter_id' => $recruiter->id]);
         }
     }
 }
Пример #2
0
 public function index()
 {
     $slots = \App\Slot::all();
     return view('dashboard.admin.profile')->with(['user' => \Auth::User(), 'slots' => $slots]);
 }
Пример #3
0
use Illuminate\Support\Facades\DB;
Route::get('/', function () {
    $slots = \App\Slot::all();
    $interviewsForJson = [];
    $interviews = Interview::with(['slot'])->get();
    foreach ($interviews as $interview) {
        $interviewsForJson[$interview->id] = ['id' => $interview->id, 'begins_at' => date_format($interview->slot->begins_at, 'H:i'), 'ends_at' => date_format($interview->slot->ends_at, 'H:i'), 'recruiter' => ['identity' => $interview->recruiter->identity, 'title' => $interview->recruiter->title]];
    }
    return view('home', ['slots' => $slots, 'recruiters_rh' => Recruiter::with(['interviews.candidate'])->where('rh', true)->get(), 'recruiters_admissions' => Recruiter::with(['interviews.candidate'])->where('admissions', true)->get(), 'recruiters_coaching' => Recruiter::with(['interviews.candidate'])->where('coaching', true)->get(), 'interviews' => json_encode($interviewsForJson)]);
});
Route::get('/gestion', ['middleware' => 'auth.basic', function () {
    return view('gestion', ['slots' => \App\Slot::all(), 'recruiters' => Recruiter::with(['interviews.candidate'])->get()]);
}]);
Route::get('/print', ['middleware' => 'auth.basic', function () {
    $pdfMaker = app('dompdf.wrapper');
    $pdf = $pdfMaker->loadView('print', ['slots' => \App\Slot::all(), 'recruiters' => Recruiter::with(['interviews.candidate', 'interviews.slot'])->get()]);
    return $pdf->stream('entretiens_par_recruteurs.pdf');
}]);
Route::post('/save-interview', function (SaveInterviewRequest $request) {
    return DB::transaction(function () use($request) {
        try {
            $candidate = Candidate::create(['firstname' => $request->input('firstname'), 'lastname' => $request->input('lastname'), 'email' => $request->input('email'), 'phone' => $request->input('phone'), 'promo' => $request->input('promo')]);
            $interview = Interview::findOrFail((int) $request->input('interview'));
            if (!is_null($interview->candidate_id)) {
                throw new Exception("Interview already taken!");
            }
            $interview->candidate_id = $candidate->id;
            $interview->save();
            return response()->json('Interview saved');
        } catch (Exception $e) {
            return response()->json('Interview NOT saved', 500);
 public function admin()
 {
     $user = \Auth::User();
     $slots = \App\Slot::all();
     return view('valence')->with(['user' => $user, 'slots' => $slots]);
 }