app/Http/Controllers/SurveyController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \App\Http\Requests\StoreSurveyRequest  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(StoreSurveyRequest $request)
    {
        $data = $request->validated();
        if (isset($data['image'])) {
            $relativePath = $this->saveImage($data['image']);
            $data['image'] = $relativePath;
        }
        $result = Survey::create($data);
        return new SurveyResource($result);
    }
public function store ( StoreSurveyRequest $ request ) { $ data = $ request -> validated ( ) ; if ( isset ( $ data [ 'image' ] ) ) { $ relativePath = $ this -> saveImage ( $ data [ 'image' ] ) ; $ data [ 'image' ] = $ relativePath ; } $ result = Survey :: create ( $ data ) ; return new SurveyResource ( $ result ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .