app/Http/ApiControllers/BatchController.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)
    {
        $validator = Validator::make($request->all(), [
                'name'          =>  'required',
                'start_date'    =>  'required|date',
                'end_date'      =>  'required|date',
            ]);
          if ($validator->fails()) {
              $this->setError('400');
              $messages=[];
              foreach ($validator->messages()->toArray() as $key=>$value) {
                    $messages[] = (object)['attribue' => $key, 'message' => $value[0]];
              }
              $this->setValidationError(['validation' => $messages]);
              return $this->response('400');
          }
         $batch = $request->only('name', 'start_date', 'end_date');
         $result = $this->batchInterface->store($batch);
         event(new ContentCRUDEvent('Create Batch', $request->admin_id, 'Create', 'Made '. $result->name. ' Batch.'));
         return $this->response('201');
    }
public function store ( Request $ request ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'name' => 'required' , 'start_date' => 'required|date' , 'end_date' => 'required|date' , ] ) ; if ( $ validator -> fails ( ) ) { $ this -> setError ( '400' ) ; $ messages = [ ] ; foreach ( $ validator -> messages ( ) -> toArray ( ) as $ key => $ value ) { $ messages [ ] = ( object ) [ 'attribue' => $ key , 'message' => $ value [ 0 ] ] ; } $ this -> setValidationError ( [ 'validation' => $ messages ] ) ; return $ this -> response ( '400' ) ; } $ batch = $ request -> only ( 'name' , 'start_date' , 'end_date' ) ; $ result = $ this -> batchInterface -> store ( $ batch ) ; event ( new ContentCRUDEvent ( 'Create Batch' , $ request -> admin_id , 'Create' , 'Made ' . $ result -> name . ' Batch.' ) ) ; return $ this -> response ( '201' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .