add all controllers logic
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Support;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ContactMessageResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'email_sent' => (bool) ($this->resource['email_sent'] ?? false),
|
||||
'recipient' => $this->resource['recipient'] ?? null,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Support;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class SupportRequestCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request): array
|
||||
{
|
||||
return $this->collection->map(function ($item) use ($request) {
|
||||
return (new SupportRequestResource($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,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Support;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class SupportRequestResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id ?? null,
|
||||
'user_id' => $this->user_id ?? null,
|
||||
'subject' => $this->subject ?? null,
|
||||
'message' => $this->message ?? null,
|
||||
'status' => $this->status ?? null,
|
||||
'semester' => $this->semester ?? null,
|
||||
'school_year' => $this->school_year ?? null,
|
||||
'created_at' => optional($this->created_at)->toDateTimeString(),
|
||||
'updated_at' => optional($this->updated_at)->toDateTimeString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user