Files
Verde-Web/app/Http/Requests/SuperAdmin/StoreTenantRequest.php
Azure_0_ ee72cd7211 feat: segregate super admin and LGU admin workflows
- Created AdminBarangayController to strictly scope barangay management to LGU boundaries
- Created AdminTenantController for LGU admins to fetch their own tenant configurations
- Updated sidebar to expose Barangays to LGU admins under the Areas menu
- Updated frontend UI to hide the City selection dropdown from LGU admins and dynamically inject their city_municipality_id
- Handled form validation issues caused by hidden required fields
- Implemented LGU dashboard routes and views
- Enforced 2 free QR code allocations on resident signup
2026-07-07 00:36:04 +08:00

43 lines
1.8 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');
$tenant = $this->route('tenant');
$admin = $tenant ? $tenant->users()->where('role', \App\Models\User::ROLE_ADMIN)->first() : null;
$adminEmailRule = $isCreate ? 'unique:users,email' : Rule::unique('users', 'email')->ignore($admin?->id);
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
'admin_email' => $isCreate ? ['required', 'email', 'max:191', 'unique:users,email'] : ['nullable', 'email', 'max:191', $adminEmailRule],
'admin_password' => $isCreate ? ['required', 'string', 'min:8'] : ['nullable', 'string', 'min:8'],
];
}
}