feat: add persistent mobile notifications
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class NotificationResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$data = is_array($this->data) ? $this->data : [];
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'type' => $data['type'] ?? $this->type,
|
||||
'category' => $data['category'] ?? 'account',
|
||||
'title' => $data['title'] ?? __('api.notifications.default_title'),
|
||||
'body' => $data['body'] ?? '',
|
||||
'url' => $data['url'] ?? null,
|
||||
'readAt' => $this->read_at?->toISOString(),
|
||||
'createdAt' => $this->created_at?->toISOString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user