ldc-portsalaries/app/Http/Requests/ImportPlanningXlsFile.php

43 lines
1.2 KiB
PHP
Raw Normal View History

2021-05-08 06:50:19 +02:00
<?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'));
}
}
]
];
}
}