fix slider
This commit is contained in:
parent
bfeb2d3c56
commit
c7549c225f
12
app/modules/slider/SliderModule.php
Normal file
12
app/modules/slider/SliderModule.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace app\modules\slider;
|
||||
|
||||
use kernel\Module;
|
||||
use kernel\modules\menu\service\MenuService;
|
||||
use kernel\services\MigrationService;
|
||||
|
||||
class SliderModule extends \kernel\app_modules\slider\SliderModule
|
||||
{
|
||||
|
||||
}
|
8
app/modules/slider/controllers/SliderController.php
Normal file
8
app/modules/slider/controllers/SliderController.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace app\modules\slider\controllers;
|
||||
|
||||
class SliderController extends \kernel\app_modules\slider\controllers\SliderController
|
||||
{
|
||||
|
||||
}
|
@ -5,9 +5,9 @@
|
||||
"slug": "slider",
|
||||
"type": "entity",
|
||||
"description": "Slider module",
|
||||
"module_class": "kernel\\app_modules\\slider\\SliderModule",
|
||||
"module_class_file": "{KERNEL_APP_MODULES}/slider/SliderModule.php",
|
||||
"app_module_path": "{APP}/modules/{slug}",
|
||||
"module_class": "app\\modules\\slider\\SliderModule",
|
||||
"module_class_file": "{APP}/modules/slider/SliderModule.php",
|
||||
"routs": "routs/slider.php",
|
||||
"migration_path": "migrations",
|
||||
"dependence": "menu"
|
||||
}
|
2
app/modules/slider/routs/slider.php
Normal file
2
app/modules/slider/routs/slider.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
include KERNEL_APP_MODULES_DIR . "/slider/routs/slider.php";
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\modules\slider;
|
||||
namespace kernel\app_modules\slider;
|
||||
|
||||
use kernel\Module;
|
||||
use kernel\modules\menu\service\MenuService;
|
||||
|
@ -18,7 +18,7 @@ class SliderController extends AdminController
|
||||
protected function init(): void
|
||||
{
|
||||
parent::init();
|
||||
$this->cgView->viewPath = KERNEL_MODULES_DIR . "/slider/views/";
|
||||
$this->cgView->viewPath = KERNEL_APP_MODULES_DIR . "/slider/views/";
|
||||
$this->sliderService = new SliderService();
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ class SliderController extends AdminController
|
||||
$slider = $this->sliderService->create($sliderForm);
|
||||
|
||||
$entityRelation = new EntityRelation();
|
||||
$entityRelation->saveEntityRelation(entity: "post", model: $slider, request: new Request());
|
||||
$entityRelation->saveEntityRelation(entity: "slider", model: $slider, request: new Request());
|
||||
|
||||
if ($slider) {
|
||||
$this->redirect("/admin/slider/view/" . $slider->id);
|
||||
|
@ -18,9 +18,9 @@ class Slider extends Model
|
||||
const int ACTIVE_STATUS = 1;
|
||||
|
||||
protected $table = "slider";
|
||||
protected $fillable = ['title', 'additional_information', 'content', 'link'];
|
||||
protected $fillable = ['title', 'additional_information', 'content', 'link', 'status'];
|
||||
|
||||
public static function labels()
|
||||
public static function labels(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Заголовок',
|
||||
|
@ -4,8 +4,6 @@ namespace kernel\app_modules\slider\services;
|
||||
|
||||
use kernel\app_modules\slider\models\Slider;
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\helpers\Slug;
|
||||
use kernel\modules\post\models\Post;
|
||||
use kernel\FormModel;
|
||||
|
||||
class SliderService
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @var Slider $slider
|
||||
* @var Slider $model
|
||||
*/
|
||||
|
||||
use kernel\app_modules\slider\models\Slider;
|
||||
|
@ -23,6 +23,15 @@ $table->beforePrint(function () {
|
||||
return IconBtnCreateWidget::create(['url' => '/admin/slider/create'])->run();
|
||||
});
|
||||
|
||||
$entityRelation = new \kernel\EntityRelation();
|
||||
$additionals = $entityRelation->getEntityRelationsBySlug("slider");
|
||||
|
||||
foreach ($additionals as $additional) {
|
||||
$table->addColumn($additional, $additional, function ($id) use ($entityRelation, $additional) {
|
||||
return $entityRelation->getAdditionalPropertyByEntityId("slider", $id, $additional);
|
||||
});
|
||||
}
|
||||
|
||||
$table->columns([
|
||||
"status" => [
|
||||
"value" => function ($cell) {
|
||||
|
@ -20,6 +20,16 @@ $table->beforePrint(function () use ($slider) {
|
||||
$btn .= \kernel\widgets\IconBtn\IconBtnDeleteWidget::create(['url' => "/admin/slider/delete/" . $slider->id])->run();
|
||||
return $btn;
|
||||
});
|
||||
|
||||
$entityRelation = new \kernel\EntityRelation();
|
||||
$additionals = $entityRelation->getEntityAdditionalProperty("slider", $slider);
|
||||
|
||||
foreach ($additionals as $key => $additional) {
|
||||
$table->addRow($key, function () use ($additional) {
|
||||
return $additional;
|
||||
}, ['after' => 'status']);
|
||||
}
|
||||
|
||||
$table->rows([
|
||||
'status' => (function ($data) {
|
||||
return \kernel\app_modules\slider\models\Slider::getStatus()[$data];
|
||||
|
Loading…
Reference in New Issue
Block a user