44 lines
1.2 KiB
PHP
Executable File
44 lines
1.2 KiB
PHP
Executable File
<?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.',
|
|
];
|
|
}
|
|
}
|