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">
<nav id="sidebar">
<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(/resources/images/noPhoto.png);"></a>-->
<p>
<?= \kernel\modules\user\service\UserService::getAuthUsername() ?>
</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([
'type' => [
'filter' => [
'class' => \kernel\filters\BootstrapSelectFilter::class,
'class' => \kernel\filters\BootstrapSelectFilterWithPrompt::class,
'param' => [
'kernel' => 'kernel',
'entity' => 'entity',

View File

@ -23,7 +23,7 @@ $table = new ListEloquentTable(new EloquentDataProvider(Post::class, [
'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/post",
'searchPrefix' => "",
'searchParams' => $get
'searchParams' => $get,
]));
//\kernel\helpers\Debug::dd((new \kernel\Request())->get());
@ -47,13 +47,13 @@ foreach ($additionals as $additional) {
$table->columns([
'title' => [
'filter' => [
'class' => \Itguild\Tables\Filter\InputTextFilter::class,
'class' => \kernel\filters\BootstrapTextFilter::class,
'value' => $get['title'] ?? ''
]
],
'content' => [
'filter' => [
'class' => \Itguild\Tables\Filter\InputTextFilter::class,
'class' => \kernel\filters\BootstrapTextFilter::class,
'value' => $get['content'] ?? ''
]
],
@ -72,10 +72,12 @@ $table->columns([
return User::find($data)->username;
},
'filter' => [
'class' => \kernel\filters\BootstrapSelectFilter::class,
'class' => \kernel\filters\BootstrapSelectFilterWithPrompt::class,
'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 '';
}
public static function getAuthUserId(): string
{
$user = self::getAuthUser();
if ($user){
return $user->id;
}
return '';
}
public static function getAuthUserPhoto(): string|null
{
$user = self::getAuthUser();

View File

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