Пример #1
0
 /**
  * Creates a new Convocatoria model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Convocatoria();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function store(Request $request)
 {
     try {
         $user = AuthenticateController::checkUser('Supervisor');
         $convocatoria = new Convocatoria($request->all());
         $convocatoria->save();
         return response()->json($convocatoria);
     } catch (QueryException $e) {
         return response()->json(['message' => 'server_error', 'exception' => $e->getMessage()], 500);
     } catch (Exceptions\TokenExpiredException $e) {
         return response()->json(['token_expired'], $e->getStatusCode());
     } catch (Exceptions\TokenInvalidException $e) {
         return response()->json(['token_invalid'], $e->getStatusCode());
     } catch (UnauthorizedException $e) {
         return response()->json(['unauthorized'], $e->getStatusCode());
     } catch (Exceptions\JWTException $e) {
         return response()->json(['token_absent'], $e->getStatusCode());
     }
 }