app/Http/ApiControllers/IntakeController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request)
    {
        $validator = Validator::make($request->all(), [
              'available'         =>  'required',
              'form_link'         =>  'required',
              'admin_id'          =>  'required'
          ]);
        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');
        }
        $intake = $this->intakeInterface->getIntake();
        $newintake = $this->intakeInterface->update($request->only('available', 'form_link'));
        if (!empty($newintake)) {
            if ($newintake->available != $intake->available && $newintake->available == 1) {
                event(new IntakeAvailableEvent($newintake));
            }
            $this->data(array('updated' =>  1));
            event(new ContentCRUDEvent('Update Intake', $request->admin_id, 'Update', 'Updated Intake Information'));
            return $this->response('200');
        }else{
            return $this->response('200');
        }
    }
public function update ( Request $ request ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'available' => 'required' , 'form_link' => 'required' , 'admin_id' => 'required' ] ) ; 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' ) ; } $ intake = $ this -> intakeInterface -> getIntake ( ) ; $ newintake = $ this -> intakeInterface -> update ( $ request -> only ( 'available' , 'form_link' ) ) ; if ( ! empty ( $ newintake ) ) { if ( $ newintake -> available != $ intake -> available && $ newintake -> available == 1 ) { event ( new IntakeAvailableEvent ( $ newintake ) ) ; } $ this -> data ( array ( 'updated' => 1 ) ) ; event ( new ContentCRUDEvent ( 'Update Intake' , $ request -> admin_id , 'Update' , 'Updated Intake Information' ) ) ; return $ this -> response ( '200' ) ; } else { return $ this -> response ( '200' ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .