jeudi 28 juillet 2016

Unique validation of a substring in Laravel

I am storing filenames + their extensions under filename column in the files table. My problem is, that since only the name is present in the $request object without it's corresponding extension, I can't validate the filename using unique validation rule without tinkering with the input data first. Example:

// . . .
$this->validate($request, [
    //   Suppose the name of uploaded file is 'file'.
    // The below rule will NEVER fail, because in the 
    // database, similar file will be stored as 'file.txt',
    // thus 'file' != 'file.txt'
    'filename' => 'unique:files'
]);
// . . .

Is there a way to validate the filename ignoring it's suffix (extension) in the database?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2aldSyU
via IFTTT

Aucun commentaire:

Enregistrer un commentaire