fix post crud
This commit is contained in:
@ -8,21 +8,21 @@ use app\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: "post", params: [
|
||||
$form->field(class: \itguild\forms\inputs\TextArea::class, name: "content", params: [
|
||||
'class' => "form-control",
|
||||
'placeholder' => 'Пост',
|
||||
'placeholder' => 'Контент',
|
||||
'rows' => '10',
|
||||
'value' => $model->post ?? ''
|
||||
'value' => $model->content ?? ''
|
||||
])
|
||||
->setLabel("Пост")
|
||||
->render();
|
||||
|
||||
$form->field(class: \itguild\forms\inputs\TextInput::class, name: "username", params: [
|
||||
$form->field(class: \itguild\forms\inputs\TextInput::class, name: "user_id", params: [
|
||||
'class' => "form-control",
|
||||
'placeholder' => 'Логин',
|
||||
'value' => $model->username ?? ''
|
||||
'placeholder' => 'id',
|
||||
'value' => $model->user_id ?? ''
|
||||
])
|
||||
->setLabel("Имя пользователя")
|
||||
->setLabel("id пользователя")
|
||||
->render();
|
||||
?>
|
||||
<div class="row">
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Database\Eloquent\Collection $posts
|
||||
* @var \Illuminate\Database\Eloquent\Collection $contents
|
||||
*/
|
||||
|
||||
use app\models\Post;
|
||||
@ -12,7 +12,7 @@ use Itguild\Tables\ListJsonTable;
|
||||
use kernel\IGTabel\btn\PrimaryBtn;
|
||||
use kernel\IGTabel\ListJsonTableEloquentCollection;
|
||||
|
||||
$dataProvider = new ListJsonTableEloquentCollection($posts, [
|
||||
$dataProvider = new ListJsonTableEloquentCollection($contents, [
|
||||
'model' => Post::class,
|
||||
'perPage' => 5,
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Database\Eloquent\Collection $post
|
||||
* @var \Illuminate\Database\Eloquent\Collection $content
|
||||
*/
|
||||
use Itguild\Tables\ViewJsonTable;
|
||||
use kernel\IGTabel\btn\DangerBtn;
|
||||
@ -9,15 +9,15 @@ use kernel\IGTabel\btn\PrimaryBtn;
|
||||
use kernel\IGTabel\btn\SuccessBtn;
|
||||
use kernel\IGTabel\ViewJsonTableEloquentModel;
|
||||
|
||||
$dataProvider = new ViewJsonTableEloquentModel($post, [
|
||||
$dataProvider = new ViewJsonTableEloquentModel($content, [
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
'baseUrl' => "/admin/user",
|
||||
]);
|
||||
$table = new ViewJsonTable($dataProvider->getJson());
|
||||
$table->beforeTable(function () use ($post) {
|
||||
$table->beforeTable(function () use ($content) {
|
||||
$btn = PrimaryBtn::create("Список", "/admin/post")->fetch();
|
||||
$btn .= SuccessBtn::create("Редактировать", "/admin/post/update/" . $post->id)->fetch();
|
||||
$btn .= DangerBtn::create("Удалить", "/admin/post/delete/" . $post->id)->fetch();
|
||||
$btn .= SuccessBtn::create("Редактировать", "/admin/post/update/" . $content->id)->fetch();
|
||||
$btn .= DangerBtn::create("Удалить", "/admin/post/delete/" . $content->id)->fetch();
|
||||
return $btn;
|
||||
});
|
||||
$table->create();
|
||||
|
Reference in New Issue
Block a user