migrate to gtea from bistbucket
This commit is contained in:
35
public/restaurant/app/Http/Middleware/CheckSubscription.php
Normal file
35
public/restaurant/app/Http/Middleware/CheckSubscription.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Traits\ResponseTrait;
|
||||
use Closure;
|
||||
|
||||
class CheckSubscription
|
||||
{
|
||||
use ResponseTrait;
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$restaurant = auth()->user()->restaurant ?? null;
|
||||
|
||||
if (! $restaurant || ! $restaurant->activeSubscription()) {
|
||||
return $this->responseError([], _lang('No active subscription.'), 403);
|
||||
}
|
||||
|
||||
$subscription = $restaurant->activeSubscription();
|
||||
$plan = $subscription->plan;
|
||||
|
||||
if (! $subscription->isActive()) {
|
||||
return $this->responseError([], _lang('Subscription expired.'), 403);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user