wip
This commit is contained in:
@@ -16,8 +16,13 @@ class RedirectIfUserPhoneIsVerfied
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (Auth::check() && ! is_null($request->user()?->phone_verified_at)) {
|
||||
return redirect(config()->string('module.base-auth.redirect_path'));
|
||||
if (Auth::check()) {
|
||||
/** @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);
|
||||
|
||||
@@ -12,11 +12,21 @@ class UserBranch extends Pivot
|
||||
|
||||
protected $table = 'branch_user';
|
||||
|
||||
/**
|
||||
* Branch
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Branch, $this>
|
||||
*/
|
||||
public function branch(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Branch::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* User
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
namespace App\Modules\CardPinOrder\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Modules\Branch\Interfaces\BelongsToBranch;
|
||||
use App\Modules\Branch\Models\Branch;
|
||||
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\Relations\BelongsTo;
|
||||
|
||||
@@ -33,7 +36,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* @property \Illuminate\Support\Carbon|null $created_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.
|
||||
@@ -73,4 +76,15 @@ class CardPinOrder extends Model
|
||||
{
|
||||
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::COMPLETED => 'success',
|
||||
self::CANCELLED => 'danger',
|
||||
default => 'primary',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ trait RoleCheckers
|
||||
*/
|
||||
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
|
||||
{
|
||||
return $this->hasAnyRole();
|
||||
return $this->isAdmin() || $this->isOperator();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,8 @@ trait UserAdjustments
|
||||
|
||||
/**
|
||||
* User branches
|
||||
*
|
||||
* @return HasMany<UserBranch, $this>
|
||||
*/
|
||||
public function userBranches(): HasMany
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user