app/Http/Controllers/AreaController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
         $respuesta=[];
        $vl=$this->validatorCrearArea($request->all());
      if ($vl->fails())
         {
               return response()->json($vl->errors());
         }else
             {
                    $area= new Area;
                    $area->fill($request->all());
                try
                {
                     $area->save();
                      return response([
                            'status' => Response::HTTP_OK,
                            'response_time' => microtime(true) - LARAVEL_START,
                            'area' => $area,
                            'msg' => 'Área creada con éxito'
                        ],Response::HTTP_OK);
                }catch(Exception $e){
                    return response([
                        'status' => Response::HTTP_BAD_REQUEST,
                        'response_time' => microtime(true) - LARAVEL_START,
                        'error' => 'Fallo al crear el área',
                        'consola' =>$e,
                        'request' => $request->all()
                    ],Response::HTTP_BAD_REQUEST);
               }
         }
    }
public function store ( Request $ request ) { $ respuesta = [ ] ; $ vl = $ this -> validatorCrearArea ( $ request -> all ( ) ) ; if ( $ vl -> fails ( ) ) { return response ( ) -> json ( $ vl -> errors ( ) ) ; } else { $ area = new Area ; $ area -> fill ( $ request -> all ( ) ) ; try { $ area -> save ( ) ; return response ( [ 'status' => Response :: HTTP_OK , 'response_time' => microtime ( true ) - LARAVEL_START , 'area' => $ area , 'msg' => 'Área creada con éxito' ] , Response :: HTTP_OK ) ; } catch ( Exception $ e ) { return response ( [ 'status' => Response :: HTTP_BAD_REQUEST , 'response_time' => microtime ( true ) - LARAVEL_START , 'error' => 'Fallo al crear el área', 'consola' => $ e , 'request' => $ request -> all ( ) ] , Response :: HTTP_BAD_REQUEST ) ; } } }
Store a newly created resource in storage.
Store a newly created resource in storage .
//Validaciòn de las entradas por el metodo POST