/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (count(Enseignant_Privilege::where(function ($query) { $query->where('id_Enseignant', '=', Auth::user()->id_Enseignant)->where('id_Privilege', '=', '1'); })->get()) > 0) { return $next($request); } else { return redirect('/'); } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (count(Enseignant_Privilege::where(function ($query) { $query->where('id_Enseignant', '=', JWTAuth::parseToken()->toUser()->id_Enseignant)->where('id_Privilege', '=', '7'); })->get()) > 0) { return $next($request); } else { return Response::json(['error' => 'Permission denied'], HttpResponse::HTTP_UNAUTHORIZED); } }
public function index() { if (Auth::check()) { if (count(\App\Models\Enseignant_Privilege::where(function ($query) { $query->where('id_Enseignant', '=', Auth::user()->id_Enseignant)->where('id_Privilege', '=', '1'); })->orWhere(function ($query) { $query->where('id_Enseignant', '=', Auth::user()->id_Enseignant)->where('id_Privilege', '=', '5'); })->get()) > 0) { $sessions = $this->gestSession->getSessions(); } else { $sessions = $this->gestSession->getSessionByEnseignant(Auth::user()->id_Enseignant); } } else { $sessions = $this->gestSession->getSessions(); } return view('welcome', compact('sessions')); }
public function show($banqueId = null) { if (is_null($banqueId)) { // display the hole banque if (count(\App\Models\Enseignant_Privilege::where(function ($query) { $query->where('id_Enseignant', '=', Auth::user()->id_Enseignant)->where('id_Privilege', '=', '1'); })->orWhere(function ($query) { $query->where('id_Enseignant', '=', Auth::user()->id_Enseignant)->where('id_Privilege', '=', '5'); })->get()) > 0) { return view('banque', ['banqueItems' => Banque::all(), 'contexteItems' => Contexte::all(), 'critereItems' => Critere::all(), 'domaineItems' => Domaine::all(), 'systemeItems' => Systeme::all(), 'competenceItems' => Competence::all(), 'enseignantList' => Enseignant::all(), 'plaintesItems' => Plainte::all()]); } else { return view('banque', ['banqueItems' => $this->gestSession->getBanqueByEnseignant(Auth::user()->id_Enseignant), 'contexteItems' => Contexte::all(), 'critereItems' => Critere::all(), 'domaineItems' => Domaine::all(), 'systemeItems' => Systeme::all(), 'competenceItems' => Competence::all(), 'enseignantList' => Enseignant::all(), 'plaintesItems' => Plainte::all()]); } } else { // display specific banque $banque = Banque::find($banqueId); $banque->items = Item::join('TitreGItem', 'TitreGItem.id_TitreGItem', '=', 'Item.id_TitreGItem')->where('Item.id_Banque', '=', $banque->id_Banque)->orderBy('Item.id_TitreGItem', 'ASC')->orderBy('Item.id_Item', 'ASC')->get(); $banque->auteurs = Banque_Enseignant::where('id_Banque', '=', $banqueId)->get(); $banque->files = File::where('id_Banque', '=', $banqueId)->get(); return is_null($banque) ? response()->json(['error' => 'Banque not found'], HttpResponse::HTTP_NOT_FOUND) : $banque; } }
public function deletePrivileges($enseignantId) { Enseignant_Privilege::where('Enseignant_Privilege.id_Enseignant', '=', $enseignantId)->delete(); }