app/Api/V1/Controllers/FaqController.php
/**
     * Persist a newly created faq.
     *
     * @param  \Illuminate\Http\Request $request
     * @return \Dingo\Api\Http\Response
     * @throws \Illuminate\Validation\ValidationException
     */
Persist a newly created faq.
Persist a newly created faq .
public function store(Request $request, Faq $faq)
    {
        $this->validate($request, [
            'question' => 'required',
            'answer' => 'required'
        ]);
        if ($faq->create($request->only('question', 'answer'))) {
            return new Response(['status' => 'Faq created'], 201);
        }
        throw new StoreResourceFailedException('Faq couldn\'t be stored');
    }
public function store ( Request $ request , Faq $ faq ) { $ this -> validate ( $ request , [ 'question' => 'required' , 'answer' => 'required' ] ) ; if ( $ faq -> create ( $ request -> only ( 'question' , 'answer' ) ) ) { return new Response ( [ 'status' => 'Faq created' ] , 201 ) ; } throw new StoreResourceFailedException ( 'Faq couldn\'t be stored' ) ; }
Persist a newly created faq.
Persist a newly created faq .
//validation passed