*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'name' => $this->name, 'display_id'=>$this->display_id, 'begin' => $this->begin, 'end' => $this->end, 'asset'=> $this->when($this->assets->isNotEmpty(),function (){ return $this->assets->map(function ($asset){ return new SimpleAssetResource($asset); })->all(); }), ]; } }