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/Neopoints/momsecurity.be/app/Pages/Kms/PageController.php
<?php

namespace App\Pages\Kms;

use App\Pages\Models\PageTranslation;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Komma\KMS\Core\SectionController;
use App\Pages\Models\Page;

final class PageController extends SectionController
{
    protected string $classModelName = Page::class;
    protected ?string $forTranslationModelName = PageTranslation::class;
    protected string $slug = 'pages';

    /**
     * @var PageRouteService
     */
    private $routeService;

    /**
     * Constructor
     */
    public function __construct()
    {
        $pageSection = new PageSection($this->slug);
        parent::__construct($pageSection);
        $this->routeService = new PageRouteService();
    }

    /**
     * @param Model $model
     * @param Collection|null $attributesByValueFrom
     * @return Model
     */
    protected function save(Model $model, Collection $attributesByValueFrom = null): Model
    {
        $model = parent::save($model, $attributesByValueFrom);
        $this->routeService->createOrUpdateRoutesForModelsTranslationsIfChanged($model);
        return $model;
    }

    /**
     * This method is called when a item will be deleted
     *
     * @param Model $model
     * @return mixed
     * @throws \Exception
     */
    public function destroy(Model $model)
    {
        $this->authorize('destroy', $model);
        $this->routeService->destroyForModel($model);
        return parent::destroy($model);
    }
}