40 lines
1.5 KiB
PHP
40 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\SuperAdmin;
|
|
|
|
use App\Models\Tenant;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class StoreTenantRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$isCreate = $this->isMethod('post');
|
|
|
|
return [
|
|
'name' => ['required', 'string', 'max:191'],
|
|
'short_name' => ['required', 'string', 'max:50'],
|
|
'city_municipality_id' => ['required', 'integer', 'exists:cities_municipalities,id'],
|
|
'boundary_polygon' => ['required', 'array', 'min:3'],
|
|
'boundary_polygon.*.lat' => ['required', 'numeric'],
|
|
'boundary_polygon.*.lng' => ['required', 'numeric'],
|
|
'theme_color' => ['nullable', 'string', 'regex:/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/'],
|
|
'logo_path' => ['nullable', 'string', 'max:255'],
|
|
'contact_email' => ['required', 'email', 'max:191'],
|
|
'contact_phone' => ['required', 'string', 'max:20'],
|
|
'status' => ['nullable', Rule::in([Tenant::STATUS_ONBOARDING, Tenant::STATUS_ACTIVE, Tenant::STATUS_SUSPENDED])],
|
|
'timezone' => ['nullable', 'string', 'max:100'],
|
|
|
|
// Default Admin Account Info (Only required during creation)
|
|
'admin_email' => $isCreate ? ['required', 'email', 'max:191', 'unique:users,email'] : ['nullable'],
|
|
'admin_password' => $isCreate ? ['required', 'string', 'min:8'] : ['nullable'],
|
|
];
|
|
}
|
|
}
|