crud menu
This commit is contained in:
77
views/admin/menu/form.php
Normal file
77
views/admin/menu/form.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* @var Menu $model
|
||||
*/
|
||||
|
||||
use kernel\models\Menu;
|
||||
|
||||
$form = new \itguild\forms\ActiveForm();
|
||||
$form->beginForm(isset($model) ? "/admin/menu/edit/" . $model->id : "/admin/menu");
|
||||
|
||||
$form->field(class: \itguild\forms\inputs\Select::class, name: "parent_id", params: [
|
||||
'class' => "form-control",
|
||||
'value' => $model->parent_id ?? ''
|
||||
])
|
||||
->setLabel("Родительский пункт меню")
|
||||
->setOptions(\app\services\MenuService::createLabelArr())
|
||||
->render();
|
||||
|
||||
$form->field(class: \itguild\forms\inputs\TextInput::class, name: "icon_file", params: [
|
||||
'class' => "form-control",
|
||||
'value' => $model->icon_file ?? ''
|
||||
])
|
||||
->setLabel("Путь к иконке")
|
||||
->render();
|
||||
|
||||
$form->field(class: \itguild\forms\inputs\TextInput::class, name: "icon_font", params: [
|
||||
'class' => "form-control",
|
||||
'value' => $model->icon_font ?? ''
|
||||
])
|
||||
->setLabel("Иконка")
|
||||
->render();
|
||||
|
||||
$form->field(class: \itguild\forms\inputs\TextInput::class, name: "label", params: [
|
||||
'class' => "form-control",
|
||||
'value' => $model->label ?? ''
|
||||
])
|
||||
->setLabel("Заголовок")
|
||||
->render();
|
||||
|
||||
$form->field(class: \itguild\forms\inputs\TextInput::class, name: "url", params: [
|
||||
'class' => "form-control",
|
||||
'value' => $model->url ?? ''
|
||||
])
|
||||
->setLabel("URL")
|
||||
->render();
|
||||
|
||||
$form->field(class: \itguild\forms\inputs\TextInput::class, name: "status", params: [
|
||||
'class' => "form-control",
|
||||
'value' => strval($model->status) ?? '1'
|
||||
])
|
||||
->setLabel("Статус")
|
||||
->render();
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
<?php
|
||||
$form->field(\itguild\forms\inputs\Button::class, name: "btn-submit", params: [
|
||||
'class' => "btn btn-primary ",
|
||||
'value' => 'Отправить',
|
||||
'typeInput' => 'submit'
|
||||
])
|
||||
->render();
|
||||
?>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<?php
|
||||
$form->field(\itguild\forms\inputs\Button::class, name: "btn-reset", params: [
|
||||
'class' => "btn btn-warning",
|
||||
'value' => 'Сбросить',
|
||||
'typeInput' => 'reset'
|
||||
])
|
||||
->render();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$form->endForm();
|
49
views/admin/menu/index.php
Normal file
49
views/admin/menu/index.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \Illuminate\Database\Eloquent\Collection $menuItem
|
||||
* @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;
|
||||
use kernel\models\Menu;
|
||||
|
||||
$table = new ListEloquentTable(new EloquentDataProvider(Menu::class, [
|
||||
'currentPage' => $page_number,
|
||||
'perPage' => 3,
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
'baseUrl' => "/admin/menu",
|
||||
]));
|
||||
$table->columns([
|
||||
'parent_id' => (function ($data) {
|
||||
if ($data == 0) return null;
|
||||
return Menu::find($data)->label;
|
||||
}),
|
||||
'created_at' => function ($data) {
|
||||
if (!$data){
|
||||
return null;
|
||||
}
|
||||
|
||||
return (new DateTimeImmutable($data))->format("d-m-Y");
|
||||
},
|
||||
'updated_at' => function ($data) {
|
||||
if (!$data){
|
||||
return null;
|
||||
}
|
||||
|
||||
return (new DateTimeImmutable($data))->format("d-m-Y");
|
||||
}
|
||||
]);
|
||||
$table->beforePrint(function () {
|
||||
return PrimaryBtn::create("Создать", "/admin/menu/create")->fetch();
|
||||
//return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch();
|
||||
});
|
||||
$table->addAction(MenuViewActionColumn::class);
|
||||
$table->addAction(MenuEditActionColumn::class);
|
||||
$table->addAction(MenuDeleteActionColumn::class);
|
||||
$table->create();
|
||||
$table->render();
|
46
views/admin/menu/view.php
Normal file
46
views/admin/menu/view.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Database\Eloquent\Collection $menu
|
||||
*/
|
||||
|
||||
use app\models\User;
|
||||
use Itguild\EloquentTable\ViewEloquentTable;
|
||||
use Itguild\EloquentTable\ViewJsonTableEloquentModel;
|
||||
use kernel\IGTabel\btn\DangerBtn;
|
||||
use kernel\IGTabel\btn\PrimaryBtn;
|
||||
use kernel\IGTabel\btn\SuccessBtn;
|
||||
use kernel\models\Menu;
|
||||
|
||||
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($menu, [
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
'baseUrl' => "/admin/menu",
|
||||
]));
|
||||
$table->beforePrint(function () use ($menu) {
|
||||
$btn = PrimaryBtn::create("Список", "/admin/menu")->fetch();
|
||||
$btn .= SuccessBtn::create("Редактировать", "/admin/menu/update/" . $menu->id)->fetch();
|
||||
$btn .= DangerBtn::create("Удалить", "/admin/menu/delete/" . $menu->id)->fetch();
|
||||
return $btn;
|
||||
});
|
||||
$table->rows([
|
||||
'parent_id' => (function ($data) {
|
||||
if ($data == 0) return null;
|
||||
return Menu::find($data)->label;
|
||||
}),
|
||||
'created_at' => function ($data) {
|
||||
if (!$data){
|
||||
return null;
|
||||
}
|
||||
|
||||
return (new DateTimeImmutable($data))->format("d-m-Y");
|
||||
},
|
||||
'updated_at' => function ($data) {
|
||||
if (!$data){
|
||||
return null;
|
||||
}
|
||||
|
||||
return (new DateTimeImmutable($data))->format("d-m-Y");
|
||||
}
|
||||
]);
|
||||
$table->create();
|
||||
$table->render();
|
@ -4,7 +4,6 @@
|
||||
*/
|
||||
|
||||
use app\models\Post;
|
||||
use app\models\User;
|
||||
|
||||
$form = new \itguild\forms\ActiveForm();
|
||||
$form->beginForm(isset($model) ? "/admin/post/edit/" . $model->id : "/admin/post");
|
||||
@ -18,7 +17,6 @@ $form->field(class: \itguild\forms\inputs\TextArea::class, name: "content", para
|
||||
->setLabel("Пост")
|
||||
->render();
|
||||
$form->field(class: \itguild\forms\inputs\Select::class, name: "user_id", params: [
|
||||
//$form->field(class: \itguild\forms\inputs\Select::class, name: "username", params: [
|
||||
'class' => "form-control",
|
||||
'value' => $model->user_id ?? ''
|
||||
])
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
use app\models\Post;
|
||||
use app\models\User;
|
||||
use app\tables\columns\PostDeleteActionColumn;
|
||||
use app\tables\columns\PostEditActionColumn;
|
||||
use app\tables\columns\PostViewActionColumn;
|
||||
use app\tables\columns\post\PostDeleteActionColumn;
|
||||
use app\tables\columns\post\PostEditActionColumn;
|
||||
use app\tables\columns\post\PostViewActionColumn;
|
||||
use Itguild\EloquentTable\EloquentDataProvider;
|
||||
use Itguild\EloquentTable\ListEloquentTable;
|
||||
use kernel\IGTabel\btn\PrimaryBtn;
|
||||
|
@ -11,20 +11,6 @@ use kernel\IGTabel\btn\DangerBtn;
|
||||
use kernel\IGTabel\btn\PrimaryBtn;
|
||||
use kernel\IGTabel\btn\SuccessBtn;
|
||||
|
||||
//$dataProvider = new ViewJsonTableEloquentModel($content, [
|
||||
// 'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
// 'baseUrl' => "/admin/user",
|
||||
//]);
|
||||
//$table = new ViewJsonTable($dataProvider->getJson());
|
||||
//$table->beforeTable(function () use ($content) {
|
||||
// $btn = PrimaryBtn::create("Список", "/admin/post")->fetch();
|
||||
// $btn .= SuccessBtn::create("Редактировать", "/admin/post/update/" . $content->id)->fetch();
|
||||
// $btn .= DangerBtn::create("Удалить", "/admin/post/delete/" . $content->id)->fetch();
|
||||
// return $btn;
|
||||
//});
|
||||
//$table->create();
|
||||
//$table->render();
|
||||
|
||||
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($content, [
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
'baseUrl' => "/admin/post",
|
||||
|
@ -1 +0,0 @@
|
||||
<?php
|
@ -5,9 +5,9 @@
|
||||
*/
|
||||
|
||||
use app\models\User;
|
||||
use app\tables\columns\UserDeleteActionColumn;
|
||||
use app\tables\columns\UserEditActionColumn;
|
||||
use app\tables\columns\UserViewActionColumn;
|
||||
use app\tables\columns\user\UserDeleteActionColumn;
|
||||
use app\tables\columns\user\UserEditActionColumn;
|
||||
use app\tables\columns\user\UserViewActionColumn;
|
||||
use Itguild\EloquentTable\EloquentDataProvider;
|
||||
use Itguild\EloquentTable\ListEloquentTable;
|
||||
use kernel\IGTabel\btn\PrimaryBtn;
|
||||
|
@ -11,20 +11,6 @@ use kernel\IGTabel\btn\DangerBtn;
|
||||
use kernel\IGTabel\btn\PrimaryBtn;
|
||||
use kernel\IGTabel\btn\SuccessBtn;
|
||||
|
||||
//$dataProvider = new ViewJsonTableEloquentModel($user, [
|
||||
// 'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
// 'baseUrl' => "/admin/user",
|
||||
//]);
|
||||
//$table = new ViewJsonTable($dataProvider->getJson());
|
||||
//$table->beforeTable(function () use ($user) {
|
||||
// $btn = PrimaryBtn::create("Список", "/admin/user")->fetch();
|
||||
// $btn .= SuccessBtn::create("Редактировать", "/admin/user/update/" . $user->id)->fetch();
|
||||
// $btn .= DangerBtn::create("Удалить", "/admin/user/delete/" . $user->id)->fetch();
|
||||
// return $btn;
|
||||
//});
|
||||
//$table->create();
|
||||
//$table->render();
|
||||
|
||||
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($user, [
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
'baseUrl' => "/admin/user",
|
||||
|
Reference in New Issue
Block a user