add more controller
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\EmergencyContacts;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class EmergencyContactGroupResource extends JsonResource
|
||||
{
|
||||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
'parent_id' => (int) ($this['parent_id'] ?? 0),
|
||||
'parent_name' => (string) ($this['parent_name'] ?? ''),
|
||||
'parent_phones' => array_values($this['parent_phones'] ?? []),
|
||||
'students' => EmergencyContactStudentResource::collection($this['students'] ?? []),
|
||||
'contacts' => EmergencyContactResource::collection($this['contacts'] ?? []),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\EmergencyContacts;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class EmergencyContactResource extends JsonResource
|
||||
{
|
||||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
'id' => (int) ($this['id'] ?? 0),
|
||||
'parent_id' => (int) ($this['parent_id'] ?? 0),
|
||||
'name' => (string) ($this['emergency_contact_name'] ?? ''),
|
||||
'cellphone' => (string) ($this['cellphone'] ?? ''),
|
||||
'email' => $this['email'] ?? null,
|
||||
'relation' => $this['relation'] ?? null,
|
||||
'semester' => $this['semester'] ?? null,
|
||||
'school_year' => $this['school_year'] ?? null,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\EmergencyContacts;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class EmergencyContactStudentResource extends JsonResource
|
||||
{
|
||||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
'id' => (int) ($this['id'] ?? 0),
|
||||
'firstname' => (string) ($this['firstname'] ?? ''),
|
||||
'lastname' => (string) ($this['lastname'] ?? ''),
|
||||
'school_id' => $this['school_id'] ?? null,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user