oauth response array

This commit is contained in:
xiaomlove
2024-04-05 22:40:06 +08:00
parent 8d07ad98f7
commit ff1b88a25f
15 changed files with 418 additions and 3 deletions

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class TopicResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'subject' => $this->subject,
'locked' => $this->locked,
'forumid' => $this->forumid,
'sticky' => $this->sticky,
'hlcolor' => $this->hlcolor,
'views' => $this->views,
'user' => new UserResource($this->whenLoaded('user')),
'lastPost' => new PostResource($this->whenLoaded('lastPost')),
'firstPost' => new PostResource($this->whenLoaded('firstPost')),
];
}
}