action btns icon widgets add
This commit is contained in:
parent
22f7ecff6a
commit
265300f345
@ -3,6 +3,7 @@
|
||||
namespace App\Widgets;
|
||||
|
||||
use Arrilot\Widgets\AbstractWidget;
|
||||
use itguild\forms\debug\Debug;
|
||||
|
||||
class IconBtnCreateWidget extends AbstractWidget
|
||||
{
|
||||
@ -17,17 +18,17 @@ class IconBtnCreateWidget extends AbstractWidget
|
||||
* Treat this method as a controller action.
|
||||
* Return view() or other content to display.
|
||||
*/
|
||||
public function run(): void
|
||||
public function run(): \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory|\Illuminate\Foundation\Application
|
||||
{
|
||||
$url = $this->config['url'];
|
||||
|
||||
$btn = new ActionButtonWidget([
|
||||
// 'label' => "<i class='fa-regular fa-square-plus'></i>",
|
||||
'label' => "Создать",
|
||||
return (new ActionButtonWidget([
|
||||
// 'label' => "class='fa-regular fa-square-plus'",
|
||||
'label' => "fa-regular fa-square-plus",
|
||||
// 'label' => "Создать",
|
||||
'url' => $url,
|
||||
'btn_type' => "success",
|
||||
'title' => "Создать"
|
||||
]);
|
||||
$btn->run();
|
||||
]))->run();
|
||||
}
|
||||
}
|
||||
|
24
app/Widgets/IconBtnDeleteWidget.php
Normal file
24
app/Widgets/IconBtnDeleteWidget.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Widgets;
|
||||
|
||||
use Arrilot\Widgets\AbstractWidget;
|
||||
|
||||
class IconBtnDeleteWidget extends AbstractWidget
|
||||
{
|
||||
/**
|
||||
* Treat this method as a controller action.
|
||||
* Return view() or other content to display.
|
||||
*/
|
||||
public function run(): \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory|\Illuminate\Foundation\Application
|
||||
{
|
||||
$url = $this->config['url'];
|
||||
|
||||
return (new ActionButtonWidget([
|
||||
'label' => "fa-regular fa-trash-can",
|
||||
'url' => $url,
|
||||
'btn_type' => "danger",
|
||||
'title' => "Удалить"
|
||||
]))->run();
|
||||
}
|
||||
}
|
25
app/Widgets/IconBtnEditWidget.php
Normal file
25
app/Widgets/IconBtnEditWidget.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Widgets;
|
||||
|
||||
use Arrilot\Widgets\AbstractWidget;
|
||||
|
||||
class IconBtnEditWidget extends AbstractWidget
|
||||
{
|
||||
/**
|
||||
* Treat this method as a controller action.
|
||||
* Return view() or other content to display.
|
||||
*/
|
||||
public function run(): \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory|\Illuminate\Foundation\Application
|
||||
{
|
||||
$url = $this->config['url'];
|
||||
|
||||
|
||||
return (new ActionButtonWidget([
|
||||
'label' => "fa-solid fa-pen",
|
||||
'url' => $url,
|
||||
'btn_type' => "success",
|
||||
'title' => "Редактировать"
|
||||
]))->run();
|
||||
}
|
||||
}
|
24
app/Widgets/IconBtnListWidget.php
Normal file
24
app/Widgets/IconBtnListWidget.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Widgets;
|
||||
|
||||
use Arrilot\Widgets\AbstractWidget;
|
||||
|
||||
class IconBtnListWidget extends AbstractWidget
|
||||
{
|
||||
/**
|
||||
* Treat this method as a controller action.
|
||||
* Return view() or other content to display.
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$url = $this->config['url'];
|
||||
|
||||
return (new ActionButtonWidget([
|
||||
'label' => "fa-regular fa-rectangle-list",
|
||||
'url' => $url,
|
||||
'btn_type' => "primary",
|
||||
'title' => "Список"
|
||||
]))->run();
|
||||
}
|
||||
}
|
24
app/Widgets/IconBtnViewWidget.php
Normal file
24
app/Widgets/IconBtnViewWidget.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Widgets;
|
||||
|
||||
use Arrilot\Widgets\AbstractWidget;
|
||||
|
||||
class IconBtnViewWidget extends AbstractWidget
|
||||
{
|
||||
/**
|
||||
* Treat this method as a controller action.
|
||||
* Return view() or other content to display.
|
||||
*/
|
||||
public function run(): \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory|\Illuminate\Foundation\Application
|
||||
{
|
||||
$url = $this->config['url'];
|
||||
|
||||
return (new ActionButtonWidget([
|
||||
'btn_type' => "primary",
|
||||
'label' => "fa-regular fa-eye",
|
||||
'url' => $url,
|
||||
'title' => "Просмотреть"
|
||||
]))->run();
|
||||
}
|
||||
}
|
@ -35,20 +35,21 @@ $table->columns([
|
||||
return (new DateTimeImmutable($data))->format("d-m-Y");
|
||||
}
|
||||
]);
|
||||
//$table->beforePrint(function () {
|
||||
// return IconBtnCreateWidget::create(['url' => '/admin/user/create'])->run();
|
||||
//});
|
||||
$table->beforePrint(function () {
|
||||
return "<a title='Создать' class='btn btn-success' href='/admin/user/create' style='margin: 3px' ><i class='fa-regular fa-square-plus'></i></a>";
|
||||
return (new \App\Widgets\IconBtnCreateWidget(['url' => '/admin/user/create']))->run();
|
||||
});
|
||||
//$table->beforePrint(function () {
|
||||
// return "<a title='Создать' class='btn btn-success' href='/admin/user/create' style='margin: 3px' ><i class='fa-regular fa-square-plus'></i></a>";
|
||||
//});
|
||||
$table->addAction(function($row) {
|
||||
return (new \App\Widgets\IconBtnViewWidget(['url' => '/admin/user/view/' . $row['id']]))->run();
|
||||
});
|
||||
$table->addAction(function($row) {
|
||||
return "<a title='Просмотреть' class='btn btn-primary' href='/admin/user/view/" . $row['id'] . "' style='margin: 3px' ><i class='<i class='fa-regular fa-eye'></i></a>";
|
||||
return (new \App\Widgets\IconBtnEditWidget(['url' => '/admin/user/update/' . $row['id']]))->run();
|
||||
});
|
||||
$table->addAction(function($row) {
|
||||
return "<a title='Редактировать' class='btn btn-success' href='/admin/user/update/" . $row['id'] . "' style='margin: 3px' ><i class='fa-solid fa-pen'></i></a>";
|
||||
});
|
||||
$table->addAction(function($row) {
|
||||
return "<a title='Удалить' class='btn btn-danger' href='/admin/user/delete/" . $row['id'] . "' style='margin: 3px' ><i class='fa-regular fa-trash-can'></i></a>";
|
||||
// return "<a title='Удалить' class='btn btn-danger' href='/admin/user/delete/" . $row['id'] . "' style='margin: 3px' ><i class='fa-regular fa-trash-can'></i></a>";
|
||||
return (new \App\Widgets\IconBtnDeleteWidget(['url' => '/admin/user/delete/' . $row['id']]))->run();
|
||||
});
|
||||
$table->create();
|
||||
|
||||
|
@ -4,6 +4,9 @@
|
||||
* @var App\Models\User $user
|
||||
*/
|
||||
|
||||
use App\Widgets\IconBtnDeleteWidget;
|
||||
use App\Widgets\IconBtnEditWidget;
|
||||
use App\Widgets\IconBtnListWidget;
|
||||
use Itguild\EloquentTable\ViewEloquentTable;
|
||||
use Itguild\EloquentTable\ViewJsonTableEloquentModel;
|
||||
|
||||
@ -11,6 +14,14 @@ $table = new ViewEloquentTable(new ViewJsonTableEloquentModel($user, [
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
'baseUrl' => "/admin/user",
|
||||
]));
|
||||
|
||||
$table->beforePrint(function () use ($user) {
|
||||
$btn = (new IconBtnListWidget(['url' => '/admin/user']))->run();
|
||||
$btn .= (new IconBtnEditWidget(['url' => '/admin/user/update/' . $user->id]))->run();
|
||||
$btn .= (new IconBtnDeleteWidget(['url' => '/admin/user/delete/' . $user->id]))->run();
|
||||
return $btn;
|
||||
});
|
||||
|
||||
$table->rows([
|
||||
'user_photo' => function ($data) {
|
||||
return $data ? "<img src='$data' width='300px'>" : "";
|
||||
@ -35,11 +46,11 @@ $table->create();
|
||||
|
||||
<x-main>
|
||||
<x-slot:title>
|
||||
Custom Title
|
||||
</x-slot>
|
||||
Custom Title
|
||||
</x-slot>
|
||||
|
||||
@php
|
||||
$table->render();
|
||||
@endphp
|
||||
@php
|
||||
$table->render();
|
||||
@endphp
|
||||
|
||||
</x-main>
|
||||
|
@ -1,13 +1 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<x-main>
|
||||
<x-slot:title>
|
||||
Custom Title
|
||||
</x-slot>
|
||||
|
||||
<a title="{{ $title }}" class='btn btn-{{ $btn_type }}' href='{{ $url }}' style='margin: 3px' >{{ $label }}</a>
|
||||
|
||||
</x-main>
|
||||
<a title="{{ $title }}" class='btn btn-{{ $btn_type }}' href='{{ $url }}' style='margin: 3px' ><i class='{{ $label }}'></i></a>
|
||||
|
@ -1 +0,0 @@
|
||||
<a title="{{ $title }}" class='btn btn-{{ $btn_type }}' href='{{ $url }}' style='margin: 3px' >{{ $label }}</a>
|
Loading…
x
Reference in New Issue
Block a user