validate([ 'code' => ['required', 'string', 'max:64'], ]); $tenant = Tenant::where('code', strtoupper($data['code']))->first(); if (! $tenant) { return $this->fail('Unknown LGU code', null, 404); } if ($tenant->status !== Tenant::STATUS_ACTIVE) { return $this->fail('LGU is not currently active', null, 403); } return $this->ok([ 'id' => $tenant->uuid, 'code' => $tenant->code, 'name' => $tenant->name, 'short_name' => $tenant->short_name, 'theme_color' => $tenant->theme_color, 'logo_path' => $tenant->logo_path, 'timezone' => $tenant->timezone, 'contact_email' => $tenant->contact_email, 'contact_phone' => $tenant->contact_phone, ]); } public function index(): JsonResponse { $tenants = Tenant::where('status', Tenant::STATUS_ACTIVE)->get(); return $this->ok($tenants->map(fn ($t) => [ 'id' => $t->uuid, 'code' => $t->code, 'name' => $t->name, 'short_name' => $t->short_name, 'theme_color' => $t->theme_color, 'logo_path' => $t->logo_path, ])); } }