first
This commit is contained in:
36
modules/Task/Http/Resources/TaskResource.php
Normal file
36
modules/Task/Http/Resources/TaskResource.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Task\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Jason\Api\Api;
|
||||
|
||||
class TaskResource extends JsonResource
|
||||
{
|
||||
|
||||
public function toArray($request): array
|
||||
{
|
||||
$user = Api::user();
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'ico' => $this->ico_url,
|
||||
'key' => $this->key,
|
||||
'cover' => $this->cover_url,
|
||||
'title' => $this->title,
|
||||
'sub_title' => $this->sub_title,
|
||||
'remark' => $this->remark,
|
||||
'tips' => $this->tips,
|
||||
'url' => $this->linker,
|
||||
'category' => new CategoryResource($this->category),
|
||||
'rule' => [
|
||||
'id' => $this->rule->id,
|
||||
'name' => $this->rule->name,
|
||||
'title' => $this->rule->title,
|
||||
],
|
||||
'user' => $this->getUserTask($user),
|
||||
'content' => $this->description,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user