create show access middleware

This commit is contained in:
2025-05-19 14:40:02 +03:30
parent 367eb55db1
commit 4ff296e476
4 changed files with 44 additions and 10 deletions

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Http\Middleware;
use App\Exceptions\ProhibitedAction;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class ValidateShowAccess
{
/**
* Handle an incoming request.
*
* @param Closure(Request): (Response) $next
* @throws Throwable
*/
public function handle(Request $request, Closure $next): Response
{
$user = Auth::user();
throw_if (is_null($user->province_id),
new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
throw_if(is_null($user->edarate_shahri_id),
new ProhibitedAction('اداره شهری برای شما در سامانه ثبت نشده است!'));
return $next($request);
}
}