|
@@ -2,6 +2,9 @@
|
|
|
|
|
|
namespace App\Http\Resources\API;
|
|
|
|
|
|
+use App\Models\Asset;
|
|
|
+use App\Models\Library;
|
|
|
+use App\Models\Project;
|
|
|
use App\Models\User;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
@@ -20,6 +23,14 @@ class ContainerDetailResource extends JsonResource
|
|
|
$whitelistName=User::query()->whereIn('id',$whitelist)->get();
|
|
|
$mailto=$this->mailto;
|
|
|
$mailtoName=User::query()->whereIn('id',$mailto)->get();
|
|
|
+// $library = Library::query()->where('id',$this->library_id)->first();
|
|
|
+ if ($this->library->type == 'project'){
|
|
|
+ $project = Project::query()->where('id',$this->library->project_id)->first();
|
|
|
+ }else if($this->library->type == 'asset'){
|
|
|
+ $asset = Asset::query()->where('id',$this->library->asset_id)->first();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return [
|
|
|
'id' => $this->id,
|
|
|
'name' => $content?->name,
|
|
@@ -39,6 +50,8 @@ class ContainerDetailResource extends JsonResource
|
|
|
"created_at" => (string)$this->created_at,
|
|
|
"created_by" => new UserProfileResource($this->createdBy),
|
|
|
'approval_status'=>$this->approval_status,
|
|
|
+ 'project' => isset($project) ? ['id' => $project?->id ,'name' => $project?->name] : [],
|
|
|
+ 'asset' => isset($asset) ? ['id' => $asset?->id ,'name' => $asset?->name] : [],
|
|
|
];
|
|
|
}
|
|
|
}
|