|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Http\Resources\API;
|
|
|
|
|
|
+use App\Models\ProjectAsset;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
|
@@ -14,6 +15,7 @@ class ProjectResource extends JsonResource
|
|
|
*/
|
|
|
public function toArray(Request $request): array
|
|
|
{
|
|
|
+ $project_ids = ProjectAsset::select('project_id')->distinct()->pluck('project_id')->all();
|
|
|
return [
|
|
|
'id' => $this->id,
|
|
|
'name' => $this->name,
|
|
@@ -22,6 +24,7 @@ class ProjectResource extends JsonResource
|
|
|
'const' => $this->const,
|
|
|
'begin' => $this->begin,
|
|
|
'end' => $this->end,
|
|
|
+ 'has_asset' =>in_array($this->id,$project_ids),
|
|
|
|
|
|
];
|
|
|
}
|