mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-16 14:00:56 +08:00
oauth response array
This commit is contained in:
30
app/Http/Resources/TopicResource.php
Normal file
30
app/Http/Resources/TopicResource.php
Normal 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')),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user