33 lines
908 B
PHP
33 lines
908 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Exceptions\ProhibitedAction;
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Throwable;
|
|
|
|
class ValidateStoreAccess
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param Closure(Request): (Response) $next
|
|
* @throws Throwable
|
|
*/
|
|
public function handle(Request $request, Closure $next): Response
|
|
{
|
|
$user = Auth::user();
|
|
|
|
throw_if ($user->edarate_ostani_id || is_null($user->city_id),
|
|
new ProhibitedAction('امکان ثبت این مورد برای ادارات استانی و ستادی وجود ندارد!'));
|
|
|
|
throw_if(is_null($user->edarate_shahri_id),
|
|
new ProhibitedAction('اداره شهری برای شما در سامانه ثبت نشده است!'));
|
|
|
|
return $next($request);
|
|
}
|
|
}
|