wip
This commit is contained in:
@@ -6,3 +6,6 @@ create database nurmuhammetsdb;
|
|||||||
|
|
||||||
|
|
||||||
ALTER USER ahat WITH PASSWORD 'K}#zL9@}QkR>MAHMYTJ';
|
ALTER USER ahat WITH PASSWORD 'K}#zL9@}QkR>MAHMYTJ';
|
||||||
|
|
||||||
|
SELECT setval('card_orders_id_seq', (SELECT MAX(id) from card_orders));
|
||||||
|
SELECT nextval('card_orders_id_seq');
|
||||||
|
|||||||
@@ -36,13 +36,26 @@ class CardOrderForm
|
|||||||
Section::make(__('New card order'))
|
Section::make(__('New card order'))
|
||||||
->columnSpan(4)
|
->columnSpan(4)
|
||||||
->columns(4)
|
->columns(4)
|
||||||
|
->disabled(function (string $context) {
|
||||||
|
if (user()->isSystemUser()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
->hidden(function (string $context): bool {
|
||||||
|
if (user()->isSystemUser()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $context === 'create';
|
||||||
|
})
|
||||||
->components([
|
->components([
|
||||||
Select::make('status')
|
Select::make('status')
|
||||||
->label(__('Status'))
|
->label(__('Status'))
|
||||||
->options(OrderStatusRepository::statusValues())
|
->options(OrderStatusRepository::statusValues())
|
||||||
->default(OrderStatusRepository::defaultStatus())
|
->default(OrderStatusRepository::defaultStatus())
|
||||||
->native(false)
|
->native(false)
|
||||||
->required()
|
|
||||||
->columnSpan(2),
|
->columnSpan(2),
|
||||||
|
|
||||||
Toggle::make('paid')
|
Toggle::make('paid')
|
||||||
|
|||||||
@@ -29,6 +29,20 @@ class CardPinOrderForm
|
|||||||
|
|
||||||
Section::make(__('New card pin order'))
|
Section::make(__('New card pin order'))
|
||||||
->columnSpanFull()
|
->columnSpanFull()
|
||||||
|
->disabled(function (string $context) {
|
||||||
|
if (user()->isSystemUser()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
->hidden(function (string $context): bool {
|
||||||
|
if (user()->isSystemUser()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $context === 'create';
|
||||||
|
})
|
||||||
->components([
|
->components([
|
||||||
Select::make('status')
|
Select::make('status')
|
||||||
->label(__('Status'))
|
->label(__('Status'))
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class LoanForm
|
|||||||
->default(user()->getOption('passport_id')),
|
->default(user()->getOption('passport_id')),
|
||||||
|
|
||||||
TextInput::make('account_number')
|
TextInput::make('account_number')
|
||||||
|
->label(__('Account number'))
|
||||||
->required()
|
->required()
|
||||||
->string()
|
->string()
|
||||||
->maxLength(23),
|
->maxLength(23),
|
||||||
|
|||||||
22
app/Filament/Clusters/Users/UsersCluster.php
Normal file
22
app/Filament/Clusters/Users/UsersCluster.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Users;
|
||||||
|
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Clusters\Cluster;
|
||||||
|
use Filament\Pages\Enums\SubNavigationPosition;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
|
||||||
|
class UsersCluster extends Cluster
|
||||||
|
{
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedUsers;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $activeNavigationIcon = Heroicon::Users;
|
||||||
|
|
||||||
|
protected static ?SubNavigationPosition $subNavigationPosition = SubNavigationPosition::Top;
|
||||||
|
|
||||||
|
public static function getNavigationLabel(): string
|
||||||
|
{
|
||||||
|
return __('Users');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Users\Schemas;
|
namespace App\Filament\Resources\Users\Schemas;
|
||||||
|
|
||||||
|
use App\Modules\PhoneNumberVerification\Rules\PhoneNumberVerificationRule;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
@@ -13,50 +14,58 @@ class UserForm
|
|||||||
public static function configure(Schema $schema): Schema
|
public static function configure(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return $schema
|
return $schema
|
||||||
->columns(2)
|
->columns(6)
|
||||||
->components([
|
->components([
|
||||||
TextInput::make('first_name')
|
TextInput::make('name')
|
||||||
->label(__('First name'))
|
->label(__('Full Name'))
|
||||||
->required(),
|
->required()
|
||||||
|
->columnSpan(3),
|
||||||
TextInput::make('last_name')
|
|
||||||
->label(__('Last name'))
|
|
||||||
->required(),
|
|
||||||
|
|
||||||
TextInput::make('username')
|
TextInput::make('username')
|
||||||
->label(__('Username'))
|
->label(__('Username'))
|
||||||
->required()
|
->required()
|
||||||
->unique(ignoreRecord: true),
|
->unique(ignoreRecord: true)
|
||||||
|
->columnSpan(3),
|
||||||
|
|
||||||
TextInput::make('phone')
|
TextInput::make('phone')
|
||||||
->label(__('Phone number'))
|
->label(__('Phone'))
|
||||||
->unique(ignoreRecord: true),
|
->unique(ignoreRecord: true)
|
||||||
|
->mask('99 99 99 99')
|
||||||
|
->prefix('+993')
|
||||||
|
->rules([
|
||||||
|
new PhoneNumberVerificationRule,
|
||||||
|
])
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
TextInput::make('email')
|
TextInput::make('email')
|
||||||
->label(__('Email'))
|
->label(__('Email'))
|
||||||
->email()
|
->email()
|
||||||
->unique(ignoreRecord: true),
|
->unique(ignoreRecord: true)
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
TextInput::make('password')
|
TextInput::make('password')
|
||||||
->label(__('Password'))
|
->label(__('Password'))
|
||||||
->password()
|
->password()
|
||||||
->dehydrateStateUsing(fn ($state) => Hash::make($state))
|
->dehydrateStateUsing(fn ($state) => Hash::make($state))
|
||||||
->dehydrated(fn ($state) => filled($state))
|
->dehydrated(fn ($state) => filled($state))
|
||||||
->required(fn (string $context): bool => $context === 'create'),
|
->required(fn (string $context): bool => $context === 'create')
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
Select::make('roles')
|
Select::make('roles')
|
||||||
->label(__('Roles'))
|
->label(__('Roles'))
|
||||||
->relationship('roles', 'name')
|
->relationship('roles', 'name')
|
||||||
->multiple()
|
->multiple()
|
||||||
->preload()
|
->preload()
|
||||||
->native(false),
|
->native(false)
|
||||||
|
->columnSpan(3),
|
||||||
|
|
||||||
Select::make('branches')
|
Select::make('branches')
|
||||||
->label(__('Branches'))
|
->label(__('Branches'))
|
||||||
->relationship('branches', 'name', fn (Builder $query) => $query->distinct('id')->orderBy('id'))
|
->relationship('branches', 'name', fn (Builder $query) => $query->distinct('id')->orderBy('id'))
|
||||||
->multiple()
|
->multiple()
|
||||||
->preload()
|
->preload()
|
||||||
->native(false),
|
->native(false)
|
||||||
|
->columnSpan(3),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Users;
|
namespace App\Filament\Resources\Users;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Users\UsersCluster;
|
||||||
use App\Filament\Resources\Users\Pages\CreateUser;
|
use App\Filament\Resources\Users\Pages\CreateUser;
|
||||||
use App\Filament\Resources\Users\Pages\EditUser;
|
use App\Filament\Resources\Users\Pages\EditUser;
|
||||||
use App\Filament\Resources\Users\Pages\ListUsers;
|
use App\Filament\Resources\Users\Pages\ListUsers;
|
||||||
@@ -16,15 +17,15 @@ use Filament\Tables\Table;
|
|||||||
|
|
||||||
class UserResource extends Resource
|
class UserResource extends Resource
|
||||||
{
|
{
|
||||||
protected static ?int $navigationSort = 2;
|
|
||||||
|
|
||||||
protected static ?string $model = User::class;
|
protected static ?string $model = User::class;
|
||||||
|
|
||||||
|
protected static ?string $cluster = UsersCluster::class;
|
||||||
|
|
||||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedUsers;
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedUsers;
|
||||||
|
|
||||||
protected static string|BackedEnum|null $activeNavigationIcon = Heroicon::Users;
|
protected static string|BackedEnum|null $activeNavigationIcon = Heroicon::Users;
|
||||||
|
|
||||||
protected static ?string $recordTitleAttribute = 'first_name';
|
protected static ?string $recordTitleAttribute = 'phone';
|
||||||
|
|
||||||
public static function getNavigationLabel(): string
|
public static function getNavigationLabel(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,8 +16,13 @@ class RedirectIfUserPhoneIsVerfied
|
|||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next): Response
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
if (Auth::check() && ! is_null($request->user()?->phone_verified_at)) {
|
if (Auth::check()) {
|
||||||
return redirect(config()->string('module.base-auth.redirect_path'));
|
/** @var \App\Models\User */
|
||||||
|
$user = $request->user();
|
||||||
|
|
||||||
|
if (! is_null($user->phone_verified_at) || $user->isSystemUser()) {
|
||||||
|
return redirect(config()->string('module.base-auth.redirect_path'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
|
|||||||
@@ -12,11 +12,21 @@ class UserBranch extends Pivot
|
|||||||
|
|
||||||
protected $table = 'branch_user';
|
protected $table = 'branch_user';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Branch
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Branch, $this>
|
||||||
|
*/
|
||||||
public function branch(): BelongsTo
|
public function branch(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Branch::class);
|
return $this->belongsTo(Branch::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
|
||||||
|
*/
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
|
|||||||
@@ -3,8 +3,11 @@
|
|||||||
namespace App\Modules\CardPinOrder\Models;
|
namespace App\Modules\CardPinOrder\Models;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Modules\Branch\Interfaces\BelongsToBranch;
|
||||||
use App\Modules\Branch\Models\Branch;
|
use App\Modules\Branch\Models\Branch;
|
||||||
use App\Modules\CardOrder\Models\CardType;
|
use App\Modules\CardOrder\Models\CardType;
|
||||||
|
use App\Modules\LoanOrder\Repositories\LoanOrderRepository;
|
||||||
|
use App\Modules\OrderStatus\Interfaces\HasStatus;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
@@ -33,7 +36,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||||||
* @property \Illuminate\Support\Carbon|null $created_at
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
*/
|
*/
|
||||||
class CardPinOrder extends Model
|
class CardPinOrder extends Model implements BelongsToBranch, HasStatus
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The attributes that should be cast.
|
* The attributes that should be cast.
|
||||||
@@ -73,4 +76,15 @@ class CardPinOrder extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(Branch::class);
|
return $this->belongsTo(Branch::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "boot" method for model
|
||||||
|
*/
|
||||||
|
protected static function boot(): void
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
static::creating(LoanOrderRepository::creating());
|
||||||
|
static::created(LoanOrderRepository::created());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ class OrderStatusRepository
|
|||||||
self::PROCESSING => 'primary',
|
self::PROCESSING => 'primary',
|
||||||
self::COMPLETED => 'success',
|
self::COMPLETED => 'success',
|
||||||
self::CANCELLED => 'danger',
|
self::CANCELLED => 'danger',
|
||||||
|
default => 'primary',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ trait RoleCheckers
|
|||||||
*/
|
*/
|
||||||
public function isOperator(): bool
|
public function isOperator(): bool
|
||||||
{
|
{
|
||||||
return $this->hasRole('operator');
|
return $this->hasRole(['operator', 'operator_card', 'operator_loan']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,6 +57,6 @@ trait RoleCheckers
|
|||||||
*/
|
*/
|
||||||
public function isSystemUser(): bool
|
public function isSystemUser(): bool
|
||||||
{
|
{
|
||||||
return $this->hasAnyRole();
|
return $this->isAdmin() || $this->isOperator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ trait UserAdjustments
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* User branches
|
* User branches
|
||||||
|
*
|
||||||
|
* @return HasMany<UserBranch, $this>
|
||||||
*/
|
*/
|
||||||
public function userBranches(): HasMany
|
public function userBranches(): HasMany
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user