umbrellio /
laravel-ltree
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Umbrellio\LTree\Resources; |
||
| 6 | |||
| 7 | use Illuminate\Http\Resources\Json\JsonResource; |
||
| 8 | use Umbrellio\LTree\Helpers\LTreeNode; |
||
| 9 | use Umbrellio\LTree\Interfaces\LTreeInterface; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @property LTreeNode $resource |
||
| 13 | */ |
||
| 14 | abstract class LTreeResource extends JsonResource |
||
| 15 | { |
||
| 16 | 1 | final public function toArray($request) |
|
| 17 | { |
||
| 18 | 1 | return array_merge($this->toTreeArray($request, $this->resource->model), [ |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 19 | 1 | 'children' => static::collection($this->resource->getChildren())->toArray($request), |
|
| 20 | 1 | ]); |
|
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @param LTreeInterface $model |
||
| 25 | */ |
||
| 26 | abstract protected function toTreeArray($request, $model); |
||
| 27 | } |
||
| 28 |