HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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);
    }
}