option CRUD

This commit is contained in:
2024-09-23 15:33:48 +03:00
parent f4971f1c7d
commit 0f05bc2391
35 changed files with 737 additions and 147 deletions

View File

@ -0,0 +1,68 @@
<?php
/**
* @var Option $model
*/
use itguild\forms\ActiveForm;
use kernel\modules\option\models\Option;
$form = new ActiveForm();
$form->beginForm(isset($model) ? "/admin/option/edit/" . $model->id : "/admin/option");
$form->field(\itguild\forms\inputs\TextInput::class, 'key', [
'class' => "form-control",
'placeholder' => 'Ключ',
'value' => $model->key ?? ''
])
->setLabel("Ключ")
->render();
$form->field(\itguild\forms\inputs\TextInput::class, 'value', [
'class' => "form-control",
'placeholder' => 'Значение',
'value' => $model->value ?? ''
])
->setLabel("Значение")
->render();
$form->field(\itguild\forms\inputs\TextInput::class, 'label', [
'class' => "form-control",
'placeholder' => "Заголовок",
'value' => $model->label ?? ''
])
->setLabel("Заголовок")
->render();
$form->field(\itguild\forms\inputs\Select::class, 'status', [
'class' => "form-control",
'value' => $model->status ?? ''
])
->setLabel("Статус")
->setOptions(['1', '2'])
->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();

View File

@ -0,0 +1,31 @@
<?php
/**
* @var \Illuminate\Database\Eloquent\Collection $options
* @var int $page_number
*/
use Itguild\EloquentTable\EloquentDataProvider;
use Itguild\EloquentTable\ListEloquentTable;
use kernel\IGTabel\btn\PrimaryBtn;
use kernel\modules\option\models\Option;
use kernel\modules\option\table\columns\OptionDeleteActionColumn;
use kernel\modules\option\table\columns\OptionEditActionColumn;
use kernel\modules\option\table\columns\OptionViewActionColumn;
$table = new ListEloquentTable(new EloquentDataProvider(Option::class, [
'current_page' => $page_number,
'per_page' => 5,
'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/option",
]));
$table->beforePrint(function () {
return PrimaryBtn::create("Создать", "/admin/option/create")->fetch();
//return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch();
});
$table->addAction(OptionViewActionColumn::class);
$table->addAction(OptionEditActionColumn::class);
$table->addAction(OptionDeleteActionColumn::class);
$table->create();
$table->render();

View File

@ -0,0 +1,23 @@
<?php
/**
* @var \Illuminate\Database\Eloquent\Collection $option
*/
use Itguild\EloquentTable\ViewEloquentTable;
use Itguild\EloquentTable\ViewJsonTableEloquentModel;
use kernel\IGTabel\btn\DangerBtn;
use kernel\IGTabel\btn\PrimaryBtn;
use kernel\IGTabel\btn\SuccessBtn;
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($option, [
'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/user",
]));
$table->beforePrint(function () use ($option) {
$btn = PrimaryBtn::create("Список", "/admin/option")->fetch();
$btn .= SuccessBtn::create("Редактировать", "/admin/option/update/" . $option->id)->fetch();
$btn .= DangerBtn::create("Удалить", "/admin/option/delete/" . $option->id)->fetch();
return $btn;
});
$table->create();
$table->render();