ldc-portsalaries/app/Http/Requests/ImportEmployeesCsvFile.php
2021-06-07 18:28:25 +02:00

42 lines
1.2 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class ImportEmployeesCsvFile extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// max 50 Mo
'file' => [
'required',
// phpcs:ignore Generic.Files.LineLength.TooLong
'mimetypes:text/csv,text/plain,application/csv,text/comma-separated-values,text/anytext,application/octet-stream,application/txt',
'max:51200',
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
function ($attribute, $value, $fail) {
if ($this->file->getClientMimeType() !== 'application/vnd.ms-excel') {
$fail(__('Le fichier doit être d\'un mime type application/vnd.ms-excel'));
}
}
]
];
}
}