2024-12-09 12:57:12 +03:00
|
|
|
<?php
|
|
|
|
|
2024-12-09 16:26:12 +03:00
|
|
|
namespace kernel\app_modules\slider\services;
|
2024-12-09 12:57:12 +03:00
|
|
|
|
2024-12-09 16:26:12 +03:00
|
|
|
use kernel\app_modules\slider\models\Slider;
|
2024-12-09 12:57:12 +03:00
|
|
|
use kernel\helpers\Debug;
|
|
|
|
use kernel\helpers\Slug;
|
|
|
|
use kernel\modules\post\models\Post;
|
|
|
|
use kernel\FormModel;
|
|
|
|
|
|
|
|
class SliderService
|
|
|
|
{
|
|
|
|
public function create(FormModel $form_model): false|Slider
|
|
|
|
{
|
|
|
|
$model = new Slider();
|
|
|
|
$model->title = $form_model->getItem('title');
|
|
|
|
$model->content = $form_model->getItem('content');
|
|
|
|
$model->additional_information = $form_model->getItem('additional_information');
|
|
|
|
$model->link = $form_model->getItem('link');
|
|
|
|
if ($model->save()){
|
|
|
|
return $model;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function update(FormModel $form_model, Slider $slider): false|Slider
|
|
|
|
{
|
|
|
|
$slider->title = $form_model->getItem('title');
|
|
|
|
$slider->content = $form_model->getItem('content');
|
|
|
|
$slider->additional_information = $form_model->getItem('additional_information');
|
|
|
|
$slider->link = $form_model->getItem('link');
|
|
|
|
if ($slider->save()){
|
|
|
|
return $slider;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|