event add store test
This commit is contained in:
63
app/Http/Requests/EventRequest.php
Normal file
63
app/Http/Requests/EventRequest.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class EventRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return !!(auth()->user());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required',
|
||||
'description' => 'nullable|string',
|
||||
'category_id' => 'required|exists:event_categories,id',
|
||||
'start_date' => 'required|date',
|
||||
'end_date' => 'date|after_or_equal:start_date',
|
||||
'location' => 'string|nullable'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
'name' => 'nom',
|
||||
'start_date' => 'date de début',
|
||||
'end_date' => 'date de fin',
|
||||
'location' => 'lieu',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error messages for the defined validation rules.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'name.required' => 'A :attribute is required',
|
||||
'start_date.required' => 'A :attribute is required',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user