priority menu item
This commit is contained in:
parent
a48088581f
commit
cb2c719b1b
@ -49,7 +49,7 @@ class AdminConsoleController extends ConsoleController
|
||||
|
||||
$this->optionService->createFromParams(
|
||||
key: "active_admin_theme",
|
||||
value: "/home/kavlar/php/MicroFrameWork/kernel/admin_themes/default",
|
||||
value: "{KERNEL_ADMIN_THEMES}/default",
|
||||
label: "Активная тема админпанели"
|
||||
);
|
||||
$this->out->r("create option active_admin_theme", "green");
|
||||
@ -57,7 +57,7 @@ class AdminConsoleController extends ConsoleController
|
||||
$this->optionService->createFromParams(
|
||||
key: "module_paths",
|
||||
value: "{\"paths\": [\"{KERNEL_MODULES}\", \"{APP}/modules\"]}",
|
||||
label: "Пути к модулям "
|
||||
label: "Пути к модулям"
|
||||
);
|
||||
$this->out->r("create option module_paths", "green");
|
||||
|
||||
@ -72,6 +72,8 @@ class AdminConsoleController extends ConsoleController
|
||||
"label" => "Модули",
|
||||
"url" => "/admin",
|
||||
"slug" => "module",
|
||||
"priority" => 1,
|
||||
"status" => 2
|
||||
]);
|
||||
$this->out->r("create item menu module", "green");
|
||||
|
||||
|
@ -13,6 +13,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property string url
|
||||
* @property int status
|
||||
* @property string slug
|
||||
* @property string priority
|
||||
* @method static find($id)
|
||||
*/
|
||||
|
||||
@ -22,7 +23,7 @@ class Menu extends Model
|
||||
const ACTIVE_STATUS = 1;
|
||||
|
||||
protected $table = 'menu';
|
||||
protected $fillable = ['parent_id', 'icon_file', 'icon_font', 'label', 'url', 'status', 'slug'];
|
||||
protected $fillable = ['parent_id', 'icon_file', 'icon_font', 'label', 'url', 'status', 'slug', 'priority'];
|
||||
protected array $dates = ['deleted_at'];
|
||||
|
||||
public static function labels(): array
|
||||
@ -35,6 +36,8 @@ class Menu extends Model
|
||||
'url' => 'URL',
|
||||
'status' => 'Статус',
|
||||
'slug' => 'Slug',
|
||||
'priority' => 'Приоритет'
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -90,8 +90,6 @@ class MenuController extends AdminController
|
||||
*/
|
||||
public function actionEdit($id): void
|
||||
{
|
||||
// Debug::prn($_REQUEST);
|
||||
// Debug::prn($_FILES);
|
||||
$menuItem = Menu::find($id);
|
||||
if (!$menuItem){
|
||||
throw new Exception(message: "The menu item not found");
|
||||
|
@ -20,6 +20,7 @@ return new class extends Migration
|
||||
$table->string('url', 255);
|
||||
$table->string('slug', 255)->unique();
|
||||
$table->integer('status')->default(1);
|
||||
$table->integer('priority')->default(5);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property string label
|
||||
* @property string url
|
||||
* @property int status
|
||||
* @property int priority
|
||||
* @method static find($id)
|
||||
*/
|
||||
|
||||
@ -21,7 +22,7 @@ class Menu extends Model
|
||||
const ACTIVE_STATUS = 1;
|
||||
|
||||
protected $table = 'menu';
|
||||
protected $fillable = ['parent_id', 'icon_file', 'icon_font', 'label', 'url', 'status', 'slug'];
|
||||
protected $fillable = ['parent_id', 'icon_file', 'icon_font', 'label', 'url', 'status', 'slug', 'priority'];
|
||||
protected array $dates = ['deleted_at'];
|
||||
|
||||
public static function labels(): array
|
||||
@ -34,6 +35,7 @@ class Menu extends Model
|
||||
'url' => 'URL',
|
||||
'status' => 'Статус',
|
||||
'slug' => 'Slug',
|
||||
'priority' => 'Приоритет'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ use kernel\FormModel;
|
||||
* @property string $label
|
||||
* @property string $url
|
||||
* @property int $status
|
||||
* @property int priority
|
||||
* @property string $slug
|
||||
* @property string $parent_slug
|
||||
*/
|
||||
@ -26,7 +27,8 @@ class CreateMenuForm extends FormModel
|
||||
'url' => 'required|min-str-len:1',
|
||||
'status' => '',
|
||||
'slug' => 'required|min-str-len:1|max-str-len:50',
|
||||
'parent_slug' => ''
|
||||
'parent_slug' => '',
|
||||
'priority' => ''
|
||||
];
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ class MenuService
|
||||
$model->url = $form_model->getItem('url');
|
||||
$model->status = $form_model->getItem('status') ?? 1;
|
||||
$model->slug = $form_model->getItem('slug');
|
||||
$model->priority = $form_model->getItem('priority') ?? 5;
|
||||
if ($model->save()){
|
||||
return $model;
|
||||
}
|
||||
@ -70,6 +71,7 @@ class MenuService
|
||||
$menuItem->url = $form_model->getItem('url');
|
||||
$menuItem->status = $form_model->getItem('status');
|
||||
$menuItem->slug = $form_model->getItem('slug');
|
||||
$menuItem->priority = $form_model->getItem('priority') ?? 5;
|
||||
if ($menuItem->save()){
|
||||
return $menuItem;
|
||||
}
|
||||
@ -90,7 +92,7 @@ class MenuService
|
||||
}
|
||||
public static function getChild(int $id)
|
||||
{
|
||||
$collection = Menu::where("parent_id", $id)->get();
|
||||
$collection = Menu::where("parent_id", $id)->get()->sortBy('priority');
|
||||
if (!$collection->isEmpty()){
|
||||
return $collection;
|
||||
}
|
||||
|
@ -4,9 +4,6 @@
|
||||
* @var int $page_number
|
||||
*/
|
||||
|
||||
//use app\tables\columns\menu\MenuDeleteActionColumn;
|
||||
//use app\tables\columns\menu\MenuEditActionColumn;
|
||||
//use app\tables\columns\menu\MenuViewActionColumn;
|
||||
use Itguild\EloquentTable\EloquentDataProvider;
|
||||
use Itguild\EloquentTable\ListEloquentTable;
|
||||
use kernel\IGTabel\btn\PrimaryBtn;
|
||||
|
@ -4,7 +4,6 @@
|
||||
* @var \Illuminate\Database\Eloquent\Collection $menu
|
||||
*/
|
||||
|
||||
use app\models\User;
|
||||
use Itguild\EloquentTable\ViewEloquentTable;
|
||||
use Itguild\EloquentTable\ViewJsonTableEloquentModel;
|
||||
use kernel\IGTabel\btn\DangerBtn;
|
||||
|
@ -24,6 +24,13 @@ $table->beforePrint(function () {
|
||||
//return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch();
|
||||
});
|
||||
|
||||
$table->columns([
|
||||
"status" => [
|
||||
"value" => function ($cell) {
|
||||
return Option::getStatus()[$cell];
|
||||
}]
|
||||
]);
|
||||
|
||||
$table->addAction(OptionViewActionColumn::class);
|
||||
$table->addAction(OptionEditActionColumn::class);
|
||||
$table->addAction(OptionDeleteActionColumn::class);
|
||||
|
@ -32,7 +32,8 @@ class AdminThemeService
|
||||
public function setActiveAdminTheme(string $theme): void
|
||||
{
|
||||
$active_admin_theme = Option::where("key", "active_admin_theme")->first();
|
||||
$active_admin_theme->value = $theme;
|
||||
Debug::prn(getConst($theme));
|
||||
$active_admin_theme->value = getConst($theme);
|
||||
$active_admin_theme->save();
|
||||
}
|
||||
|
||||
@ -44,6 +45,7 @@ class AdminThemeService
|
||||
public function getAdminThemeInfo(string $theme): false|array|string
|
||||
{
|
||||
$info = [];
|
||||
$theme = getConst($theme);
|
||||
$info['path'] = $theme;
|
||||
if (file_exists($theme . "/manifest.json")){
|
||||
$manifest = file_get_contents($theme . "/manifest.json");
|
||||
|
@ -10,7 +10,7 @@ class MenuWidget extends Widget
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
$menu = Menu::where("parent_id", 0)->get();
|
||||
$menu = Menu::where("parent_id", 0)->get()->sortBy("priority");
|
||||
$this->cgView->render('/admin/menu.php', ['menu' => $menu]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user