43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Requests;
|
||
|
|
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
|
||
|
|
class ImportPlanningXlsFile 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:application/vnd.ms-excel,application/vnd.ms-office,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,text/xml',
|
||
|
|
'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'));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
]
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|