Initial commit: Lash Vanshy - Complete project with admin panel, gallery, products, and contact
This commit is contained in:
43
app/Http/Requests/GaleriaRequest.php
Executable file
43
app/Http/Requests/GaleriaRequest.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class GaleriaRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'titulo' => ['required', 'string', 'max:255'],
|
||||
'descripcion' => ['nullable', 'string', 'max:1000'],
|
||||
'tipo' => ['required', 'in:imagen,video'],
|
||||
'archivo' => ['required', 'file', 'max:102400'],
|
||||
'thumbnail' => ['nullable', 'image', 'max:10240'],
|
||||
'orden' => ['nullable', 'integer', 'min:0'],
|
||||
'activo' => ['nullable', 'boolean'],
|
||||
];
|
||||
|
||||
if ($this->isMethod('PUT') || $this->isMethod('PATCH')) {
|
||||
$rules['archivo'] = ['nullable', 'file', 'max:102400'];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'titulo.required' => 'El titulo es obligatorio.',
|
||||
'tipo.required' => 'Debes seleccionar el tipo (imagen o video).',
|
||||
'archivo.required' => 'Debes subir un archivo.',
|
||||
'archivo.mimes' => 'El formato del archivo no es valido.',
|
||||
'archivo.max' => 'El archivo no puede exceder 100MB.',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user