add modules and upload file
This commit is contained in:
51
kernel/modules/post/views/form.php
Normal file
51
kernel/modules/post/views/form.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @var Post $model
|
||||
*/
|
||||
|
||||
use kernel\modules\post\models\Post;
|
||||
|
||||
$form = new \itguild\forms\ActiveForm();
|
||||
$form->beginForm(isset($model) ? "/admin/post/edit/" . $model->id : "/admin/post");
|
||||
|
||||
$form->field(class: \itguild\forms\inputs\TextArea::class, name: "content", params: [
|
||||
'class' => "form-control",
|
||||
'placeholder' => 'Контент',
|
||||
'rows' => '10',
|
||||
'value' => $model->content ?? ''
|
||||
])
|
||||
->setLabel("Пост")
|
||||
->render();
|
||||
$form->field(class: \itguild\forms\inputs\Select::class, name: "user_id", params: [
|
||||
'class' => "form-control",
|
||||
'value' => $model->user_id ?? ''
|
||||
])
|
||||
->setLabel("Пользователи")
|
||||
->setOptions(\kernel\modules\user\service\UserService::createUsernameArr())
|
||||
->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();
|
50
kernel/modules/post/views/index.php
Normal file
50
kernel/modules/post/views/index.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Database\Eloquent\Collection $contents
|
||||
* @var int $page_number
|
||||
*/
|
||||
|
||||
use kernel\modules\post\models\Post;
|
||||
use kernel\modules\user\models\User;
|
||||
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;
|
||||
|
||||
$table = new ListEloquentTable(new EloquentDataProvider(Post::class, [
|
||||
'currentPage' => $page_number,
|
||||
'perPage' => 3,
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
'baseUrl' => "/admin/post"
|
||||
]));
|
||||
$table->columns([
|
||||
'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");
|
||||
},
|
||||
'user_id' => (function ($data) {
|
||||
return User::find($data)->username;
|
||||
})
|
||||
]);
|
||||
$table->beforePrint(function () {
|
||||
return PrimaryBtn::create("Создать", "/admin/post/create")->fetch();
|
||||
//return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch();
|
||||
});
|
||||
$table->addAction(PostViewActionColumn::class);
|
||||
$table->addAction(PostEditActionColumn::class);
|
||||
$table->addAction(PostDeleteActionColumn::class);
|
||||
$table->create();
|
||||
$table->render();
|
42
kernel/modules/post/views/view.php
Normal file
42
kernel/modules/post/views/view.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Database\Eloquent\Collection $content
|
||||
*/
|
||||
|
||||
use kernel\modules\user\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;
|
||||
|
||||
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($content, [
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
'baseUrl' => "/admin/post",
|
||||
]));
|
||||
$table->beforePrint(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->rows([
|
||||
'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");
|
||||
},
|
||||
'user_id' => (function ($data) {
|
||||
return User::find($data)->username;
|
||||
})
|
||||
]);
|
||||
$table->create();
|
||||
$table->render();
|
Reference in New Issue
Block a user