File: D:/HostingSpaces/SBogers95/rentman.io/app/Komma/ProductGroups/Kms/ProductGroupService.php
<?php
namespace App\Komma\ProductGroups\Kms;
use App\Komma\Kms\Core\Sections\SectionService;
use App\Komma\ProductGroups\Models\ProductGroup;
use Illuminate\Database\Eloquent\Model;
class ProductGroupService extends SectionService
{
protected $sortable = false;
public function __construct()
{
$this->forModelName = ProductGroup::class;
parent::__construct();
}
public function destroyModel(Model $model)
{
// Remove the current bind models
$products = $model->products;
foreach ($products as $product) {
$product->product_group_id = null;
$product->save();
}
parent::destroyModel($model);
}
}