Add file upload function. modify paramiter FILESYSTEM_DISK=public in file .env
This commit is contained in:
42
app/Http/Requests/FileRequest.php
Normal file
42
app/Http/Requests/FileRequest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\File;
|
||||
|
||||
|
||||
class FileRequest extends FormRequest
|
||||
{
|
||||
public $filetoinsert;
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'filetoinsert' => ['required', 'mimes:txt']//, File::types(['csv'])]
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'filetoinsert.required' => 'ERROR: csv file not selected!',
|
||||
'filetoinsert.mimes'=> "ERRORE: select only csv format"
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,19 @@ class WordRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'name' => ['required'],
|
||||
'translation' => ['required'],
|
||||
'translation' => ['required', 'unique:words,translation'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => 'Insert italian Word',
|
||||
'translation.required' => 'Insert dialect Word',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user