app/Api/V1/Controllers/ResponseController.php
/**
     * create new Response
     *
     * @param Request $request
     * @return Response
     * @throws \Illuminate\Validation\ValidationException
     */
create new Response
@param Request $request
@return Response
@throws \Illuminate\Validation\ValidationException
create new Response @param Request $request @return Response @throws \ Illuminate \ Validation \ ValidationException
public function store(Request $request) {
        $this->validate($request, [
            'feedback_id' => 'required|exists:feedbacks,id',
            'content' => 'required|string'
        ]);
        $data = $request->only('feedback_id', 'content');
        $data['created_by'] = auth()->id();
        $response = new Response($data);
        if ($response->save()) {
            if ($request->feedback_status === 'resolved' || $request->feedback_status === 'closed') {
                $feedback = $response->feedback()->first();
                $feedback->status = $request->feedback_status;
                $feedback->save();
            }
            event(new FeedbackRespondedTo($response->feedback()->first(), $response));
            return $response;
        }
        throw new StoreResourceFailedException('Response couldn\'t be stored');
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'feedback_id' => 'required|exists:feedbacks,id' , 'content' => 'required|string' ] ) ; $ data = $ request -> only ( 'feedback_id' , 'content' ) ; $ data [ 'created_by' ] = auth ( ) -> id ( ) ; $ response = new Response ( $ data ) ; if ( $ response -> save ( ) ) { if ( $ request -> feedback_status === 'resolved' || $ request -> feedback_status === 'closed' ) { $ feedback = $ response -> feedback ( ) -> first ( ) ; $ feedback -> status = $ request -> feedback_status ; $ feedback -> save ( ) ; } event ( new FeedbackRespondedTo ( $ response -> feedback ( ) -> first ( ) , $ response ) ) ; return $ response ; } throw new StoreResourceFailedException ( 'Response couldn\'t be stored' ) ; }
create new Response
 @param Request $request
 @return Response
 @throws \Illuminate\Validation\ValidationException
create new Response @param Request $request @return Response @throws \ Illuminate \ Validation \ ValidationException
//if request has feedback_status, save it //send email to feedback owner