This commit is contained in:
Билай Станислав 2024-12-26 14:04:35 +03:00
parent b5b7befd34
commit 28c8e24847
7 changed files with 70 additions and 15 deletions

View File

@ -26,12 +26,8 @@
<div class="wrapper d-flex align-items-stretch"> <div class="wrapper d-flex align-items-stretch">
<nav id="sidebar"> <nav id="sidebar">
<div class="p-4 pt-5"> <div class="p-4 pt-5">
<a href="#" class="img logo rounded-circle mb-5" <a href="<?= '/admin/user/view/' . \kernel\modules\user\service\UserService::getAuthUser()->id ?>" class="img logo rounded-circle mb-5"
style="background-image: url(<?= \kernel\modules\user\service\UserService::getAuthUserPhoto() ?? '/resources/images/noPhoto.png' ?>);"></a> style="background-image: url(<?= \kernel\modules\user\service\UserService::getAuthUserPhoto() ?? '/resources/images/noPhoto.png' ?>);"></a>
<!-- style="background-image: url(/resources/images/noPhoto.png);"></a>-->
<p> <p>
<?= \kernel\modules\user\service\UserService::getAuthUsername() ?> <?= \kernel\modules\user\service\UserService::getAuthUsername() ?>
</p> </p>

View File

@ -0,0 +1,23 @@
<?php
namespace kernel\filters;
use itguild\forms\builders\SelectBuilder;
use Itguild\Tables\Filter\Filter;
use kernel\helpers\Debug;
class BootstrapSelectFilterWithPrompt extends Filter
{
public function fetch(): string
{
$select = SelectBuilder::build($this->name, [
'class' => 'form-control',
'options' => $this->param,
'value' => $this->value,
'prompt' => "Не выбрано"
]);
return "<td>" . $select->create()->fetch() . "</td>";
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace kernel\filters;
use itguild\forms\builders\TextInputBuilder;
use Itguild\Tables\Filter\Filter;
class BootstrapTextFilter extends Filter
{
public function fetch()
{
$textInput = TextInputBuilder::build($this->name, [
'value' => $this->value,
'class' => "form-control"
]);
return "<td>" . $textInput->create()->fetch() . "</td>";
}
}

View File

@ -42,7 +42,7 @@ $table->addAction(function ($row, $url) use ($moduleService) {
$table->columns([ $table->columns([
'type' => [ 'type' => [
'filter' => [ 'filter' => [
'class' => \kernel\filters\BootstrapSelectFilter::class, 'class' => \kernel\filters\BootstrapSelectFilterWithPrompt::class,
'param' => [ 'param' => [
'kernel' => 'kernel', 'kernel' => 'kernel',
'entity' => 'entity', 'entity' => 'entity',

View File

@ -23,7 +23,7 @@ $table = new ListEloquentTable(new EloquentDataProvider(Post::class, [
'params' => ["class" => "table table-bordered", "border" => "2"], 'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/post", 'baseUrl' => "/admin/post",
'searchPrefix' => "", 'searchPrefix' => "",
'searchParams' => $get 'searchParams' => $get,
])); ]));
//\kernel\helpers\Debug::dd((new \kernel\Request())->get()); //\kernel\helpers\Debug::dd((new \kernel\Request())->get());
@ -47,13 +47,13 @@ foreach ($additionals as $additional) {
$table->columns([ $table->columns([
'title' => [ 'title' => [
'filter' => [ 'filter' => [
'class' => \Itguild\Tables\Filter\InputTextFilter::class, 'class' => \kernel\filters\BootstrapTextFilter::class,
'value' => $get['title'] ?? '' 'value' => $get['title'] ?? ''
] ]
], ],
'content' => [ 'content' => [
'filter' => [ 'filter' => [
'class' => \Itguild\Tables\Filter\InputTextFilter::class, 'class' => \kernel\filters\BootstrapTextFilter::class,
'value' => $get['content'] ?? '' 'value' => $get['content'] ?? ''
] ]
], ],
@ -72,10 +72,12 @@ $table->columns([
return User::find($data)->username; return User::find($data)->username;
}, },
'filter' => [ 'filter' => [
'class' => \kernel\filters\BootstrapSelectFilter::class, 'class' => \kernel\filters\BootstrapSelectFilterWithPrompt::class,
'param' => \kernel\modules\user\service\UserService::createUsernameArr(), 'param' => \kernel\modules\user\service\UserService::createUsernameArr(),
'value' => $get['user_id'] ?? '' 'value' => $get['user_id'] ?? '',
] 'prompt' => 'dsds'
],
'prompt' => 'dsds'
] ]
]); ]);

View File

@ -82,6 +82,16 @@ class UserService
return ''; return '';
} }
public static function getAuthUserId(): string
{
$user = self::getAuthUser();
if ($user){
return $user->id;
}
return '';
}
public static function getAuthUserPhoto(): string|null public static function getAuthUserPhoto(): string|null
{ {
$user = self::getAuthUser(); $user = self::getAuthUser();

View File

@ -17,13 +17,15 @@ use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget; use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnViewWidget; use kernel\widgets\IconBtn\IconBtnViewWidget;
$get = (new \kernel\Request())->get();
$table = new ListEloquentTable(new EloquentDataProvider(User::class, [ $table = new ListEloquentTable(new EloquentDataProvider(User::class, [
'currentPage' => $page_number, 'currentPage' => $page_number,
'perPage' => 3, 'perPage' => 3,
'params' => ["class" => "table table-bordered", "border" => "2"], 'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/user", 'baseUrl' => "/admin/user",
'filters' => ['email'], 'searchPrefix' => "",
])); 'searchParams' => $get,]));
$entityRelation = new \kernel\EntityRelation(); $entityRelation = new \kernel\EntityRelation();
$additionals = $entityRelation->getEntityRelationsBySlug("user"); $additionals = $entityRelation->getEntityRelationsBySlug("user");
@ -37,7 +39,8 @@ foreach ($additionals as $additional) {
$table->columns([ $table->columns([
'username' => [ 'username' => [
"filter" => [ "filter" => [
'class' => \Itguild\Tables\Filter\InputTextFilter::class 'class' => \kernel\filters\BootstrapTextFilter::class,
'value' => $get['username'] ?? null,
] ]
], ],
'user_photo' => function ($data) { 'user_photo' => function ($data) {