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);
}
}