app/Http/ApiControllers/TopicController.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, $id)
    {
        $validator = Validator::make($request->all(), [
                        'start_date'  =>  'date',
                        'end_date'    =>  'date',
                        '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');
        }
        $topic = $this->topicInterface->find($id);
        if (empty($topic)) {
            $this->setError('404', $id);
            return $this->response('404');
        }else{
            if ($this->topicInterface->update($request->all(),$id)) {
                $this->data(array('updated' =>  1));
                event(new ContentCRUDEvent('Update Topic', $request->admin_id, 'Update', 'Updated '. $topic->name. ' Topic'));
                return $this->response('200');
            }else {
                return $this->response('500');
            };
        }
    }
public function update ( Request $ request , $ id ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'start_date' => 'date' , 'end_date' => 'date' , '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' ) ; } $ topic = $ this -> topicInterface -> find ( $ id ) ; if ( empty ( $ topic ) ) { $ this -> setError ( '404' , $ id ) ; return $ this -> response ( '404' ) ; } else { if ( $ this -> topicInterface -> update ( $ request -> all ( ) , $ id ) ) { $ this -> data ( array ( 'updated' => 1 ) ) ; event ( new ContentCRUDEvent ( 'Update Topic' , $ request -> admin_id , 'Update' , 'Updated ' . $ topic -> name . ' Topic' ) ) ; return $ this -> response ( '200' ) ; } else { return $ this -> response ( '500' ) ; } ; } }
Update the specified resource in storage.
Update the specified resource in storage .