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
746 B
PHP
33 lines
746 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Data\SocialMediaPostResponseDto;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\JsonApi\JsonApiResource;
|
|
|
|
/**
|
|
* @property SocialMediaPostResponseDto $resource
|
|
*/
|
|
class GeneratedPostResource extends JsonApiResource
|
|
{
|
|
public function type(): string
|
|
{
|
|
return 'generated-posts';
|
|
}
|
|
|
|
public function resolveResourceIdentifier($request): string
|
|
{
|
|
return (string) $this->resource->id;
|
|
}
|
|
|
|
public function toAttributes(Request $request): array
|
|
{
|
|
return [
|
|
'post' => $this->resource->post,
|
|
'image' => $this->resource->image,
|
|
'createdAt' => $this->resource->createdAt->toIso8601String(),
|
|
];
|
|
}
|
|
}
|