for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Install GitHub App
<?php
namespace Backpack\CRUD\app\Library\Uploaders\Support;
use Backpack\CRUD\app\Library\Uploaders\Support\Interfaces\FileNameGeneratorInterface;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Str;
class FileNameGenerator implements FileNameGeneratorInterface
{
/**
* Generate a unique file name.
*
* @param string|UploadedFile $file
* @return string
*/
public function generate($file)
return $this->getFileName($file).'.'.$this->getExtensionFromFile($file);
}
* Return the file extension.
* @param mixed $file
private function getExtensionFromFile($file)
return is_a($file, UploadedFile::class, true) ? $file->extension() : Str::after(mime_content_type($file), '/');
* Return the file name.
private function getFileName($file)
if (is_file($file)) {
return Str::of($file->getClientOriginalName())->beforeLast('.')->slug()->append('-'.Str::random(4));
return Str::random(40);