movepixels's avatar

Laravel Upload Validation

I cant seem to figure out how to validate an image with a condition. Scenario: User can upload 3 images, each image is a specific type so say images A, B, C.

They can upload any of these 3 as many times as they want if not happy with the file. But once admin approves the image then thats it they cant upload anymore. So if A, and C are approved then only B image can accept upload.

I can simply disable the upload for A, C on the front end but that still not secure since Postman can still simply bypass the frontend form and try to upload directly.

So basically how can a FormRequest ensure that it's allowed if there is no record of that A,B, or C that is approved?

Image is upload 1 at a time so its not a group of objects. Data would be media and type ( media is the image, type is A, B or C) Thanks

0 likes
3 replies
Sinnbeck's avatar

How do you tell them apart in the backend?

But it sounds like a case for a custom rule

movepixels's avatar

There is a type column, thats where A, B, or C would be stored.

So if user uploads A the type => A , verified => false by default but once admin reviews the file if its updated to verified => true then user cant upload any A file anymore.

movepixels's avatar

I suppose thinking I could use Rule::exists and query where type => $this->type and verified => false

Maybe i was overthinking the complexity of it and its rather simple and just needed to think about the column values and your question may have solved my issue :)

Please or to participate in this conversation.