|
@@ -175,16 +175,17 @@ class AssetController extends Controller
|
|
|
public function tree()
|
|
|
{
|
|
|
$attachmentArray = [];
|
|
|
- $assets = Asset::allowed()->get(['id', 'name', 'parent_id'])->each(function ($assets)use (&$attachmentArray){
|
|
|
- $attachmentArray[]=[
|
|
|
- 'parent_id'=>$assets->id,
|
|
|
- 'type'=>'attachment',
|
|
|
- 'name'=>'attachment',
|
|
|
- 'uuId'=>'attachment_'.$assets->id,
|
|
|
- 'id'=>'asset_id_'.$assets->id,
|
|
|
- ];
|
|
|
- $assets->type='asset';
|
|
|
- $assets->uniId=$assets->type.'_'.$assets->id;
|
|
|
+ $assets = Asset::withCount('library')->allowed()->get(['id', 'name', 'parent_id'])
|
|
|
+ ->each(function ($assets) use (&$attachmentArray) {
|
|
|
+ $attachmentArray[]=[
|
|
|
+ 'parent_id'=>$assets->id,
|
|
|
+ 'type'=>'attachment',
|
|
|
+ 'name'=>'attachment',
|
|
|
+ 'uuId'=>'attachment_'.$assets->id,
|
|
|
+ 'id'=>'asset_id_'.$assets->id,
|
|
|
+ ];
|
|
|
+ $assets->type='asset';
|
|
|
+ $assets->uniId=$assets->type.'_'.$assets->id;
|
|
|
});
|
|
|
|
|
|
return $this->success([
|