File: D:/HostingSpaces/debout/debout.nl/app/Vacancies/Kms/VacancyController.php
<?php
namespace App\Vacancies\Kms;
/**
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma
*/
use App\Base\SectionControllerWithComponentAreas;
use App\Vacancies\Models\VacancyTranslation;
use App\Vacancies\Models\Vacancy;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Komma\KMS\Core\Tree\NestedSets\Nodes\AbstractTranslatableTreeModel;
final class VacancyController extends SectionControllerWithComponentAreas
{
protected $sortable = true;
protected $slug = "vacancies";
protected $classModelName = Vacancy::class;
protected $forTranslationModelName = VacancyTranslation::class;
function __construct()
{
$section = new VacancySection($this->slug);
parent::__construct($section);
}
protected function save(Model $model, Collection $attributesByValueFrom = null): Model
{
/** @var AbstractTranslatableTreeModel $model */
if(!$model->exists) {
$rootModel = $this->classModelName::allRoot()->first();
$model->makeLastChildOf($rootModel);
}
$model = parent::save($model, $attributesByValueFrom);
return $model;
}
}