29 lines
780 B
PHP
29 lines
780 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Peidikeji\Keywords\Http\Resources\KeywordResource;
|
|
|
|
class CropResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'parent_id' => $this->parent_id,
|
|
'name' => $this->name,
|
|
'is_end' => $this->is_end,
|
|
'unit' => $this->unit ?? '',
|
|
'extends' => $this->extends ?? [],
|
|
'category' => KeywordResource::make($this->whenloaded('category')),
|
|
];
|
|
}
|
|
}
|