1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace App\Http\Resources\API;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\JsonResource;
- class FolderDetailResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @return array<string, mixed>
- */
- public function toArray(Request $request): array
- {
- return [
- 'id' => $this->id,
- 'object_type' => $this->object_type,
- 'object_id' => $this->object_id,
- 'name' => $this->name,
- 'parent_id' => $this->parent_id,
- 'sequence' => $this->sequence,
- 'created_at' => (string)$this->created_at,
- 'updated_at' => (string)$this->updated_at,
- 'created_by' => $this->createdBy ? new UserProfileResource($this->createdBy) : null,
- 'updated_by' => $this->updatedBy ? new UserProfileResource($this->updatedBy) : null,
- 'type' => 'folder',
- 'itemCount' => $this->children()->count() + $this->files()->where('is_latest_version', 1)->count(),
- 'uniId' => 'folder_' . $this->id,
- 'display_id'=>(string)$this->display_id,
- 'naming_rule' => new NamingRuleSimpleResource($this->namingRule),
- ];
- }
- }
|