AlexanderKim's avatar

Need advice with CRUD update methods

Hello.

When you guys are doing CRUD update method - do you allow users to delete the image, not replacing it?

I have come with the following options:

  1. Not allowing to delete the image at all when doing an (page) edit.
  2. Allowing to replace the image (which you uploaded with a store method).
  3. Removing image with Ajax request.

When you're using the 3rd option, if a user deleted the image via ajax request and you want to force user to re-upload another image, how do you make that field required with validation?

0 likes
1 reply
Snapey's avatar

I would question why it is mandatory to have an image?

In the controller you can check if the model has reference to an image and return ->back() to the view if there is no image. Don't think that everything must be done in validation rules.

Please or to participate in this conversation.