This commit is contained in:
2022-11-01 11:07:41 +08:00
commit c23de98690
131 changed files with 14088 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Api\Resources;
use App\Api\Resources\UserInfoBaseResource;
use Illuminate\Http\Resources\Json\JsonResource;
use Jason\Api\Api;
class CommentResource extends JsonResource
{
public function toArray($request): array
{
$user = Api::user();
return [
'comment_id' => $this->id,
'user' => new UserInfoBaseResource($this->user),
'parent' => $this->when($this->parent_id, function () {
return new UserInfoBaseResource($this->parent->user);
}, function () {
return null;
}),
'is_me' => ! $this->user()->isNot($user),
'content' => $this->content,
];
}
}