wip
This commit is contained in:
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Filament\Clusters\Cards\Cards;
|
namespace App\Filament\Clusters\Cards\Cards;
|
||||||
|
|
||||||
use App\Filament\Clusters\Cards\Cards\Pages\ManageCards;
|
|
||||||
use App\Filament\Clusters\Cards\CardsCluster;
|
use App\Filament\Clusters\Cards\CardsCluster;
|
||||||
|
use App\Filament\Clusters\Cards\Cards\Pages\ManageCards;
|
||||||
use App\Modules\AppHelpers\Repositories\DateHelper;
|
use App\Modules\AppHelpers\Repositories\DateHelper;
|
||||||
use App\Modules\Card\Models\Card;
|
|
||||||
use App\Modules\CardBalance\Repositories\CardBalanceRepository;
|
use App\Modules\CardBalance\Repositories\CardBalanceRepository;
|
||||||
use App\Modules\CardRequisite\Repositories\CardRequisiteRepository;
|
use App\Modules\CardRequisite\Repositories\CardRequisiteRepository;
|
||||||
use App\Modules\CardTransaction\Repositories\CardTransactionRepository;
|
use App\Modules\CardTransaction\Repositories\CardTransactionRepository;
|
||||||
|
use App\Modules\Card\Models\Card;
|
||||||
use BackedEnum;
|
use BackedEnum;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
@@ -25,6 +25,7 @@ use Filament\Support\Icons\Heroicon;
|
|||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class CardResource extends Resource
|
class CardResource extends Resource
|
||||||
@@ -92,6 +93,9 @@ class CardResource extends Resource
|
|||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
|
->modifyQueryUsing(function (Builder $query) {
|
||||||
|
$query->where('user_id', user()->id);
|
||||||
|
})
|
||||||
->columns([
|
->columns([
|
||||||
TextColumn::make('number')
|
TextColumn::make('number')
|
||||||
->label(__('Card number'))
|
->label(__('Card number'))
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Modules\UserAdjustments\Traits\UserAdjustments;
|
use App\Modules\UserAdjustments\Traits\UserAdjustments;
|
||||||
|
use Filament\Models\Contracts\FilamentUser;
|
||||||
use Filament\Panel;
|
use Filament\Panel;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Illuminate\Support\Facades\Date;
|
use Illuminate\Support\Facades\Date;
|
||||||
use Filament\Models\Contracts\FilamentUser;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@@ -20,10 +20,11 @@ use Filament\Models\Contracts\FilamentUser;
|
|||||||
* @property Date|null $created_at
|
* @property Date|null $created_at
|
||||||
* @property Date|null $updated_at
|
* @property Date|null $updated_at
|
||||||
*/
|
*/
|
||||||
class User extends Authenticatable implements FilamentUser
|
class User extends Authenticatable implements FilamentUser
|
||||||
{
|
{
|
||||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
use Notifiable;
|
use Notifiable;
|
||||||
use UserAdjustments;
|
use UserAdjustments;
|
||||||
|
|
||||||
|
|||||||
@@ -29,5 +29,5 @@ return [
|
|||||||
'change_phone_label' => 'Telefon belgini üýtgetmek',
|
'change_phone_label' => 'Telefon belgini üýtgetmek',
|
||||||
'go_back' => 'Yza',
|
'go_back' => 'Yza',
|
||||||
'successfully_changed_phone' => 'Telefon belgiňiz üýtgedildi',
|
'successfully_changed_phone' => 'Telefon belgiňiz üýtgedildi',
|
||||||
'resend' => 'Täze tassyklaýyş belgi ugratmak'
|
'resend' => 'Täze tassyklaýyş belgi ugratmak',
|
||||||
];
|
];
|
||||||
|
|||||||
62
app/Modules/UserAdjustments/Traits/RoleCheckers.php
Normal file
62
app/Modules/UserAdjustments/Traits/RoleCheckers.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\UserAdjustments\Traits;
|
||||||
|
|
||||||
|
trait RoleCheckers
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Check if user is me.
|
||||||
|
*/
|
||||||
|
public function isMe(): bool
|
||||||
|
{
|
||||||
|
return $this->email === 'nurmuhammet@mail.com';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if user is super admin.
|
||||||
|
*/
|
||||||
|
public function isSuperAdmin(): bool
|
||||||
|
{
|
||||||
|
if ($this->isMe()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hasRole('superadmin');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if user is admin.
|
||||||
|
*/
|
||||||
|
public function isAdmin(): bool
|
||||||
|
{
|
||||||
|
if ($this->isMe()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hasRole(['king', 'superadmin', 'admin']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if user is operator.
|
||||||
|
*/
|
||||||
|
public function isOperator(): bool
|
||||||
|
{
|
||||||
|
return $this->hasRole('operator');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if user is a currency maintainer.
|
||||||
|
*/
|
||||||
|
public function isCurrencyMaintainer(): bool
|
||||||
|
{
|
||||||
|
return $this->hasRole('currency_maintainer');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is System User
|
||||||
|
*/
|
||||||
|
public function isSystemUser(): bool
|
||||||
|
{
|
||||||
|
return $this->isAdmin() || $this->isOperator() || $this->isCurrencyMaintainer();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Modules\UserAdjustments\Traits;
|
namespace App\Modules\UserAdjustments\Traits;
|
||||||
|
|
||||||
use Spatie\Permission\Traits\HasRoles;
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
use Filament\Panel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property string $username [unique]
|
* @property string $username [unique]
|
||||||
@@ -19,6 +18,7 @@ use Filament\Panel;
|
|||||||
trait UserAdjustments
|
trait UserAdjustments
|
||||||
{
|
{
|
||||||
use HasRoles;
|
use HasRoles;
|
||||||
|
use RoleCheckers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the attributes that should be cast.
|
* Get the attributes that should be cast.
|
||||||
|
|||||||
Reference in New Issue
Block a user