XetaIO /
Xetaravel
| 1 | <?php |
||||
| 2 | |||||
| 3 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | namespace Xetaravel\Http\Middleware; |
||||
| 6 | |||||
| 7 | use Closure; |
||||
| 8 | use Illuminate\Http\RedirectResponse; |
||||
| 9 | use Illuminate\Http\Request; |
||||
| 10 | use Illuminate\Support\Facades\Auth; |
||||
| 11 | use Masmerise\Toaster\Toaster; |
||||
| 12 | use Psr\Container\ContainerExceptionInterface; |
||||
| 13 | use Psr\Container\NotFoundExceptionInterface; |
||||
| 14 | |||||
| 15 | class DiscussMaintenance |
||||
| 16 | { |
||||
| 17 | /** |
||||
| 18 | * Handle an incoming request. |
||||
| 19 | * |
||||
| 20 | * @param Request $request |
||||
| 21 | * @param Closure $next |
||||
| 22 | * |
||||
| 23 | * @return RedirectResponse|mixed |
||||
| 24 | * |
||||
| 25 | * @throws ContainerExceptionInterface |
||||
| 26 | * @throws NotFoundExceptionInterface |
||||
| 27 | */ |
||||
| 28 | public function handle(Request $request, Closure $next): mixed |
||||
| 29 | { |
||||
| 30 | // If discuss is disabled and the user is not admin. |
||||
| 31 | if ((!Auth::user() && !settings('discuss_enabled')) || |
||||
| 32 | (!settings('discuss_enabled') && !Auth::user()->hasPermissionTo('manage discuss conversation')) |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 33 | ) { |
||||
| 34 | return redirect() |
||||
| 35 | ->route('page.index') |
||||
|
0 ignored issues
–
show
The method
route() does not exist on Illuminate\Routing\Redirector.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 36 | ->error('The discuss system is temporarily disabled.'); |
||||
| 37 | } |
||||
| 38 | |||||
| 39 | // If discuss is disabled and the user is admin. |
||||
| 40 | if (!settings('discuss_enabled') && Auth::user()->hasPermissionTo('manage discuss conversation')) { |
||||
| 41 | Toaster::error('The discuss system is temporarily disabled.'); |
||||
| 42 | } |
||||
| 43 | |||||
| 44 | return $next($request); |
||||
| 45 | } |
||||
| 46 | } |
||||
| 47 |