app/Http/Controllers/SurveyController.php
/**
     * Remove the specified resource from storage.
     *
     * @param  \App\Models\Survey  $survey
     * @return \Illuminate\Http\Response
     */
Remove the specified resource from storage.
Remove the specified resource from storage .
public function destroy(Survey $survey, Request $request)
    {
        $user = $request->user();
        if ($user->id !== $survey->user_id) {
            return abort(403, 'Unauthorized action.');
        }
        if ($survey->image) {
            $absolutePath = public_path($survey->image);
            File::delete($absolutePath);
        }
        $survey->delete();
        if ($survey->image) {
            $absolutePath = public_path($survey->image);
            File::delete($absolutePath);
        }
        return response('', 204);
    }
public function destroy ( Survey $ survey , Request $ request ) { $ user = $ request -> user ( ) ; if ( $ user -> id !== $ survey -> user_id ) { return abort ( 403 , 'Unauthorized action.' ) ; } if ( $ survey -> image ) { $ absolutePath = public_path ( $ survey -> image ) ; File :: delete ( $ absolutePath ) ; } $ survey -> delete ( ) ; if ( $ survey -> image ) { $ absolutePath = public_path ( $ survey -> image ) ; File :: delete ( $ absolutePath ) ; } return response ( '' , 204 ) ; }
Remove the specified resource from storage.
Remove the specified resource from storage .