/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($encadrantId = null, $serviceId = null)
 {
     if (is_null($serviceId)) {
         return Encadrant_Service_Etudiant::join('Service', 'Service.id_Service', '=', 'Encadrant_Service_Etudiant.id_Stage')->select('Service.*')->where('Encadrant_Service_Etudiant.id_Enseignant', '=', $encadrantId)->distinct()->get();
     } else {
         $service = Service::find($serviceId);
         return is_null($stage) ? response()->json(['error' => 'stage Note not found'], HttpResponse::HTTP_NOT_FOUND) : $service;
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($encadrantId = null)
 {
     //afficher all stage of a specifique encadrant
     if (is_null($encadrantId)) {
         return Encadrant_Service_Etudiant::join('Enseignant', 'Enseignant.id_Enseignant', '=', 'Encadrant_Service_Etudiant.id_Enseignant')->select('Enseignant.*')->distinct()->get();
     } else {
         $encadrant = Enseignant::find($encadrantId);
         return is_null($encadrant) ? response()->json(['error' => 'encadrant Note not found'], HttpResponse::HTTP_NOT_FOUND) : $encadrant;
     }
 }
 public function isStageValid($id_Etudiant, $id_Stage)
 {
     // retrieve all student stages
     $stagesAffecte = Encadrant_Service_Etudiant::join('Service', 'Service.id_Service', '=', 'Encadrant_Service_Etudiant.id_Service')->select('isValid')->where('id_Etudiant', $id_Etudiant)->where('id_Stage', $id_Stage)->get();
     foreach ($stagesAffecte as $stage) {
         if (!$stage->isValid) {
             return false;
         }
     }
     return true;
 }