wip
This commit is contained in:
@@ -16,8 +16,18 @@ class RedirectIfUserPhoneIsUnVerfied
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (Auth::check() && is_null($request->user()?->phone_verified_at)) {
|
||||
return redirect()->route('sms-verification');
|
||||
if (Auth::check()) {
|
||||
/** @var \App\Models\User */
|
||||
$user = $request->user();
|
||||
|
||||
// Skip if user is system user...
|
||||
if ($user->isSystemUser()) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
if (is_null($user->phone_verified_at)) {
|
||||
return redirect()->route('sms-verification');
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
24
app/Modules/Branch/Models/UserBranch.php
Normal file
24
app/Modules/Branch/Models/UserBranch.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Branch\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
|
||||
class UserBranch extends Pivot
|
||||
{
|
||||
public $incrementing = true;
|
||||
|
||||
protected $table = 'branch_user';
|
||||
|
||||
public function branch(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Branch::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace App\Modules\UserAdjustments\Traits;
|
||||
|
||||
use App\Modules\Branch\Models\Branch;
|
||||
use App\Modules\Branch\Models\UserBranch;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
/**
|
||||
@@ -71,4 +73,12 @@ trait UserAdjustments
|
||||
{
|
||||
return $this->belongsToMany(Branch::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* User branches
|
||||
*/
|
||||
public function userBranches(): HasMany
|
||||
{
|
||||
return $this->hasMany(UserBranch::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user