app/Http/ApiControllers/TopicDetailController.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(), [
                        'topic_id'     =>  'required|exists:topic,id',
                        'name'         =>  'required',
                        'descriptions' =>  'required',
                        'date'         =>  'required|date',
                        'teacher_id'   =>  'required|exists:user,id',
                        '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');
        }
         $topicdetail = $request->all();
         $result = $this->topicdetailInterface->store($topicdetail);
         if (isset($result)) {
           $this->data(array('id' =>  $result));
           event(new ContentCRUDEvent('Create Topic Detail', $request->admin_id, 'Create', 'Created '. $result->name. ' Topic Detail.'));
         }
         return $this->response('201');
    }
public function store ( Request $ request ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'topic_id' => 'required|exists:topic,id' , 'name' => 'required' , 'descriptions' => 'required' , 'date' => 'required|date' , 'teacher_id' => 'required|exists:user,id' , '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' ) ; } $ topicdetail = $ request -> all ( ) ; $ result = $ this -> topicdetailInterface -> store ( $ topicdetail ) ; if ( isset ( $ result ) ) { $ this -> data ( array ( 'id' => $ result ) ) ; event ( new ContentCRUDEvent ( 'Create Topic Detail' , $ request -> admin_id , 'Create' , 'Created ' . $ result -> name . ' Topic Detail.' ) ) ; } return $ this -> response ( '201' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .