/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Request $request, $id)
 {
     $data = $request->all();
     $id_period = $data['id_period'];
     if ($id == 1) {
         // Add code for load teacher whitout period
         $teachers = \App\User::leftJoin('registry_teachers', function ($join) use($id_period) {
             $join->on('users.id', '=', 'registry_teachers.id_teacher')->where('registry_teachers.id_period', '=', $id_period);
         })->whereNull('registry_teachers.id_teacher')->Where('users.active', 1)->Where('users.type', '<>', 'Student')->select('users.id', 'users.first_name', 'users.last_name', 'users.type')->get()->toJson();
         //dd(count(json_decode($teachers,true)));
     } else {
         // Add code for load teacher whit period
         $teachers = \App\RegistryTeacher::Join('users', 'users.id', '=', 'registry_teachers.id_teacher')->select('registry_teachers.id as id_registry_teacher', 'users.id', 'users.first_name', 'users.last_name', 'users.type')->Where('registry_teachers.id_period', $id_period)->get()->toJson();
     }
     $status = count(json_decode($teachers, true)) > 0 ? true : false;
     if ($request->ajax()) {
         return response()->json(['status' => $status, 'data' => $teachers]);
     }
 }
 public function getRegistryPeriods()
 {
     //dd();
     $periods = \App\RegistryTeacher::Join('periods', 'periods.id', '=', 'registry_teachers.id_period')->select('registry_teachers.id as id_registry_teacher', 'periods.id', 'periods.name', 'periods.start', 'periods.end')->Where('id_teacher', $this->user->id)->orderBy('periods.end', 'desc')->get();
     return $periods;
 }