56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Zoomyboy\Event\Components;
|
|
|
|
use Cms\Classes\ComponentBase;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Support\Facades\Lang;
|
|
use Input;
|
|
use Winter\Storm\Support\Facades\Validator;
|
|
|
|
class EventForm extends ComponentBase
|
|
{
|
|
public function componentDetails()
|
|
{
|
|
return [
|
|
'name' => 'EventForm Component',
|
|
'description' => 'No description provided yet...',
|
|
];
|
|
}
|
|
|
|
public function defineProperties()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function onSubmit(): JsonResponse
|
|
{
|
|
$validator = Validator::make(Input::all(), [
|
|
'activity' => 'required|max:255',
|
|
'gender' => 'required|max:255',
|
|
'firstname' => 'required|max:255',
|
|
'lastname' => 'required|max:255',
|
|
'birthday' => 'required|date|before_or_equal:'.now()->format('Y-m-d'),
|
|
'address' => 'required|max:255',
|
|
'zip' => 'required|numeric',
|
|
'location' => 'required|max:255',
|
|
'phone' => 'required|max:255',
|
|
'email' => 'required|max:255|email',
|
|
'agegroup' => 'required|max:255',
|
|
'group' => 'nullable|max:255',
|
|
'agegroup_leader' => 'nullable|max:255',
|
|
'emergency_phone' => 'required|max:255',
|
|
'food_preferences' => 'array',
|
|
'misc' => '',
|
|
'foto' => '',
|
|
], [], Lang::get('zoomyboy.event::validation.attributes'));
|
|
|
|
if ($validator->fails()) {
|
|
return response()->json($validator->errors(), 422);
|
|
}
|
|
|
|
$fields = $validator->validated();
|
|
dd($fields);
|
|
}
|
|
}
|