1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace App\Http\Resources\API;
- use App\Models\Project;
- use Illuminate\Http\Request;
- use App\Models\Enums\ApprovalFlowType;
- use Illuminate\Http\Resources\Json\JsonResource;
- class ApprovalFlowResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @return array<string, mixed>
- */
- public function toArray(Request $request): array
- {
- $projecName=$this->object_type==ApprovalFlowType::TASK->value?null:Project::query()->where('id',$this->object_id)->first();
- return [
- 'id' => $this->id,
- 'name' => $this->name,
- 'type' => $this->type,
- 'object_type' => $this->object_type,
- 'object_id' => $this->object_id==0?null:$this->object_id,
- 'link_project'=>$projecName==null?null:$projecName->name,
- 'created_at' => (string)$this->created_at,
- 'created_by' => new UserProfileResource($this->createdBy),
- 'display_id' =>$this->display_id,
- ];
- }
- }
|