2021-08-12 16:26:35 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Users;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
|
|
|
|
|
|
class ImportRequest extends FormRequest
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*
|
2022-09-29 10:09:43 +02:00
|
|
|
* @return boolean
|
2021-08-12 16:26:35 +02:00
|
|
|
*/
|
|
|
|
|
public function authorize()
|
|
|
|
|
{
|
|
|
|
|
return Auth::check();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function rules()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'import' => [
|
|
|
|
|
'required',
|
|
|
|
|
'file',
|
|
|
|
|
'mimes:csv,txt',
|
|
|
|
|
'mimetypes:text/csv,text/plain,application/csv,text/comma-separated-values,text/anytext,application/octet-stream,application/txt',
|
|
|
|
|
function ($attribute, $value, $fail) {
|
|
|
|
|
if ($this->import->getClientMimeType() !== 'text/csv' && $this->import->getClientMimeType() !== 'application/vnd.ms-excel') {
|
|
|
|
|
$fail(__('Le fichier doit être d\'un mime type text/csv ou application/vnd.ms-excel'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|