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/SBogers10/reiskick.komma.nl/app/Countries/Kms/CountryController.php
<?php

namespace App\Countries\Kms;

use App\Countries\Country;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Komma\KMS\Core\SectionController;

final class CountryController extends SectionController
{
    protected string $slug = "countries";
    protected string $classModelName = Country::class;

    function __construct()
    {
        $countrySection = new CountrySection($this->slug);
        parent::__construct($countrySection);
    }

    protected function save(Model $model, Collection $attributesByValueFrom = null): Model
    {
        $model = parent::save($model, $attributesByValueFrom); // TODO: Change the autogenerated stub

        Country::where('id','!=',$model->id)
            ->where('home_grid_position', $model->home_grid_position)
            ->update(['home_grid_position' => null]);

        return $model;
    }
}