webfuelcode's avatar

If condition in controller for multiple variables

I am trying to upload two images for the post. And using the if statement for checking if the post has an older image.

So here, I am not sure how to use it. I think array would be in use in the place $post->img1.

Please correct it for two or more images.

            if($post->img1){
                Storage::disk('my_files')->delete('post_img/' . $post->img1);
            }
            $request->img1->storeAs('post_img', $filename, 'my_files');
            
            $validated['img1'] = $filename;
        }
0 likes
0 replies

Please or to participate in this conversation.