The helper is a good idea I would simply use a date/time field then you could search on that field if older than 7 days.
Removing user-uploaded files that are older than 7 days
Hey guys. I have a website where users are able to upload files. I'd like to automatically delete files that are older than 7 days. The file information such as the name and path of file is stored in database and the files are stored in the storage directory.
I was thinking of checking for files that were uploaded more than 7 days ago and deleting them manually when the user makes request to my site (by placing the code in a helper and calling the helper from all my controllers). However, this can make my site load very slowly.
So what is the best way to take care of this job? I'm not familiar with jobs and queues with laravel so it would be pretty confusing for me.
I have the code ready, I just need a best way to do it. Therefore, I'm kindly asking for your input as to what you guys think.
Cheers!
Please or to participate in this conversation.