Hello @bgeneto ,
Unfortunately there is not any out of the box way to do that in Grocery CRUD since the filename prefix is hardcoded currently with the below code:
if (file_exists($this->_uploadPath . '/' . $newFileName . '.' . $fileExtension)) {
$newFileName = $newFileName . '-' .substr(uniqid(), -5);
}
I am working currently in having the callbackBeforeUpload, callbackUpload and callbackAfterUpload and I am going to release that very soon (e.g. this week). Maybe what are you looking for is a callbackUpload or a callbackAfterUpload so you can change the filename? I will inform you once the functions are available to see if this fits your needs. Also what about using the callbackAfterUpdate instead?
For example having something like this:
$crud->callbackAfterUpdate(function ($stateParameters) use ($callbackAfterUpdateModel) {
$prefix = 'test-';
if (!empty($stateParameters->data['photo_url']) && !strstr($stateParameters->data['photo_url'], $prefix)) {
$photoUrlWithPrefix = $prefix .$stateParameters->data['photo_url'];
// Create your own model and update the photo url
$callbackAfterUpdateModel->updatePhotoUrl($stateParameters->primaryKeyValue, $photoUrlWithPrefix);
}
return $stateParameters;
});
What do you think? I hope this helped
Regards
Johnny