Implement Authentication States, show logout options in auth store and services. Make DB and controllers to make messages grouped by chats. Refactor backend code to use DTO.
33 lines
742 B
PHP
33 lines
742 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Data\ChatResponseDto;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\JsonApi\JsonApiResource;
|
|
|
|
/**
|
|
* @property ChatResponseDto $resource
|
|
*/
|
|
class ChatResponseResource extends JsonApiResource
|
|
{
|
|
public function type(): string
|
|
{
|
|
return 'chats';
|
|
}
|
|
|
|
public function resolveResourceIdentifier($request): string
|
|
{
|
|
return (string) $this->resource->id;
|
|
}
|
|
|
|
public function toAttributes(Request $request): array
|
|
{
|
|
return [
|
|
'title' => $this->resource->title,
|
|
'createdAt' => $this->resource->createdAt->toIso8601String(),
|
|
'updatedAt' => $this->resource->updatedAt->toIso8601String(),
|
|
];
|
|
}
|
|
}
|