'array', ]; /* |-------------------------------------------------------------------------- | FUNCTIONS |-------------------------------------------------------------------------- */ public static function boot() { parent::boot(); static::deleting(function($obj) { if (count((array)$obj->photos)) { foreach ($obj->photos as $item) { \Storage::disk('public')->delete($item['file_path']); } } }); } /* |-------------------------------------------------------------------------- | RELATIONS |-------------------------------------------------------------------------- */ public function productRelateds() { return $this->belongsToMany(Product::class, 'product_product_related', 'product_id', 'product_related_id'); } public function productCatalog() { return $this->belongsTo(ProductCatalog::class, 'product_catalog_id'); } public function productApplications() { return $this->belongsToMany(ProductApplication::class, 'product_product_application'); } /* |-------------------------------------------------------------------------- | SCOPES |-------------------------------------------------------------------------- */ /* |-------------------------------------------------------------------------- | ACCESSORS |-------------------------------------------------------------------------- */ /* |-------------------------------------------------------------------------- | MUTATORS |-------------------------------------------------------------------------- */ public function setPhotosAttribute($value) { $attribute_name = "photos"; $disk = "public"; $destination_path = "products"; $this->uploadImgMultipleFilesToDisk($value, $attribute_name, $disk, $destination_path); } }