Files
nexusphp/app/Http/Resources/CommentResource.php

28 lines
785 B
PHP
Raw Normal View History

2021-05-15 19:29:44 +08:00
<?php
namespace App\Http\Resources;
use Carbon\CarbonInterface;
use Illuminate\Http\Resources\Json\JsonResource;
class CommentResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
2026-01-23 13:01:16 +07:00
'text' => bbcode_attach_to_img($this->text),
2025-12-30 17:49:56 +07:00
'updated_at' => format_datetime($this->editdate),
'created_at' => format_datetime($this->added),
2021-05-15 19:29:44 +08:00
'create_user' => new UserResource($this->whenLoaded('create_user')),
2025-12-30 17:49:56 +07:00
'update_user' => $this->when($this->editedby > 0, new UserResource($this->whenLoaded('update_user'))),
2021-05-15 19:29:44 +08:00
];
}
}