/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Request $request, $id)
 {
     //
     $data = $request->all();
     //dd($data);
     $id_period = $data['id_period'];
     $id_company = $data['id_company'];
     if ($id == 1) {
         // Add code for load teacher whitout period
         /*
         			$teachers =  \App\RegistryStudent::Join('users','users.id','=','registry_students.id_student')
         			        ->leftJoin('registry_companies', 'users.id', '=', 'registry_companies.id_student')
         			->select('registry_students.id as id_registry_student','users.id','users.first_name','users.last_name','users.type')
         			->whereNull('registry_companies.id_student')
         			->Where('registry_students.id_period',$id_period)
         			->get()->toJson();*/
         $teachers = \App\RegistryStudent::Join('users', function ($join) {
             $join->on('users.id', '=', 'registry_students.id_student');
         })->leftJoin('registry_companies', function ($leftJoin) use($id_company, $id_period) {
             $leftJoin->on('users.id', '=', 'registry_companies.id_student')->Where('registry_companies.id_company', '=', $id_company)->Where('registry_companies.id_period', '=', $id_period);
         })->select('registry_students.id as id_registry_student', 'users.id', 'users.first_name', 'users.last_name', 'users.type')->whereNull('registry_companies.id_student')->Where('registry_students.id_period', $id_period)->get()->toJson();
         //dd($teachers);
         //dd(count(json_decode($teachers,true)));
     } else {
         // Add code for load teacher whit period
         $teachers = \App\RegistryCompany::Join('users', 'users.id', '=', 'registry_companies.id_student')->select('registry_companies.id as id_registry_company', 'users.id', 'users.first_name', 'users.last_name', 'users.type')->Where('registry_companies.id_period', $id_period)->Where('registry_companies.id_company', $id_company)->get()->toJson();
     }
     //dd(100);
     $status = count(json_decode($teachers, true)) > 0 ? true : false;
     if ($request->ajax()) {
         return response()->json(['status' => $status, 'data' => $teachers]);
     }
 }
Ejemplo n.º 2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     $methodology = \App\Methodology::lists('name', 'id');
     $currentuser = $this->user;
     $company = \App\RegistryCompany::Join('companies', function ($join) use($currentuser) {
         $join->on('companies.id', '=', 'registry_companies.id_company')->where('registry_companies.id_student', '=', $currentuser->id);
     })->select('companies.id', 'companies.name')->where('id_period', $id)->get();
     //dd($company[0]->name);
     if (count($company) > 0) {
         $teamwork = \App\RegistryCompany::Join('users', function ($join) use($company) {
             $join->on('users.id', '=', 'registry_companies.id_student')->where('registry_companies.id_company', '=', $company[0]->id);
         })->select('users.id', 'users.first_name', 'users.last_name', 'users.email')->where('id_period', $id)->get();
     } else {
         $teamwork = array();
     }
     if (count($company) > 0 && count($teamwork) > 0) {
         $account = \App\ConfigCorreo::where('id_company', '=', $company[0]->id)->where('id_period', '=', $id)->get();
         if (count($account) > 0) {
             $account = $account[0];
         } else {
             $account = array();
         }
     } else {
         $account = array();
     }
     if (count($company) > 0 && count($teamwork) > 0) {
         $methodology_use = \App\RegistryMethodology::where('id_company', '=', $company[0]->id)->where('id_period', '=', $id)->get();
         if (count($methodology_use) > 0) {
             $methodology_use = $methodology_use[0];
         } else {
             $methodology_use = array();
         }
     } else {
         $methodology_use = array();
     }
     //dd();
     return view("Admin.Course.Settings.setting", ['company' => $company, 'teamwork' => $teamwork, 'id' => $id, 'account' => $account, 'methodology' => $methodology, 'methodology_use' => $methodology_use]);
 }