add all controllers logic

This commit is contained in:
root
2026-03-11 17:53:15 -04:00
parent 3e6c577085
commit 2ef71cc92b
421 changed files with 12009 additions and 5211 deletions
@@ -0,0 +1,31 @@
<?php
namespace App\Http\Resources\Staff;
use Illuminate\Http\Resources\Json\ResourceCollection;
class StaffCollection extends ResourceCollection
{
public function toArray($request): array
{
return $this->collection->map(function ($item) use ($request) {
return (new StaffResource($item))->toArray($request);
})->all();
}
public function with($request): array
{
if (!method_exists($this->resource, 'total')) {
return [];
}
return [
'meta' => [
'total' => $this->resource->total() ?? null,
'per_page' => $this->resource->perPage() ?? null,
'current_page' => $this->resource->currentPage() ?? null,
'last_page' => $this->resource->lastPage() ?? null,
],
];
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Http\Resources\Staff;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class StaffResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id ?? null,
'user_id' => $this->user_id ?? null,
'firstname' => $this->firstname ?? null,
'lastname' => $this->lastname ?? null,
'email' => $this->email ?? null,
'phone' => $this->phone ?? null,
'role_name' => $this->role_name ?? null,
'active_role' => $this->active_role ?? null,
'school_year' => $this->school_year ?? null,
'class_section' => $this->class_section ?? null,
'verification_issue' => (bool) ($this->verification_issue ?? false),
'school_id' => $this->school_id ?? null,
'created_at' => optional($this->created_at)->toDateTimeString(),
'updated_at' => optional($this->updated_at)->toDateTimeString(),
];
}
}