From 043364042600557fd5dadbe5882735f1c4b29029 Mon Sep 17 00:00:00 2001 From: RafficMohammed Date: Sun, 8 Jan 2023 02:16:25 +0530 Subject: [PATCH] laravel-8 changes --- .../Middleware/RedirectIfAuthenticated.php | 43 +++++-------- public/index.php | 64 +++++++++---------- routes/web.php | 33 +++++----- 3 files changed, 63 insertions(+), 77 deletions(-) diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index feb4fb63c..8a7e290bb 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -2,44 +2,31 @@ namespace App\Http\Middleware; +use App\Providers\RouteServiceProvider; use Closure; -use Illuminate\Contracts\Auth\Guard; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; class RedirectIfAuthenticated { - /** - * The Guard implementation. - * - * @var Guard - */ - protected $auth; - - /** - * Create a new filter instance. - * - * @param Guard $auth - * - * @return void - */ - public function __construct(Guard $auth) - { - $this->auth = $auth; - } - /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * - * @return mixed + * @param \Illuminate\Http\Request $request + * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next + * @param string|null ...$guards + * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ - public function handle($request, Closure $next) + public function handle(Request $request, Closure $next, ...$guards) { - if ($this->auth->check()) { - return redirect(url('dashboard')); + $guards = empty($guards) ? [null] : $guards; + + foreach ($guards as $guard) { + if (Auth::guard($guard)->check()) { + return redirect(url('dashboard')); + } } return $next($request); } -} +} \ No newline at end of file diff --git a/public/index.php b/public/index.php index 5c2fb420c..c3c0fd200 100644 --- a/public/index.php +++ b/public/index.php @@ -1,10 +1,24 @@ - */ +use Illuminate\Contracts\Http\Kernel; +use Illuminate\Http\Request; + +define('LARAVEL_START', microtime(true)); + +/* +|-------------------------------------------------------------------------- +| Check If The Application Is Under Maintenance +|-------------------------------------------------------------------------- +| +| If the application is in maintenance / demo mode via the "down" command +| we will load this file so that any pre-rendered content can be shown +| instead of starting the framework, which could cause an exception. +| +*/ + +if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) { + require $maintenance; +} /* |-------------------------------------------------------------------------- @@ -12,46 +26,30 @@ |-------------------------------------------------------------------------- | | Composer provides a convenient, automatically generated class loader for -| our application. We just need to utilize it! We'll simply require it -| into the script here so that we don't have to worry about manual -| loading any of our classes later on. It feels nice to relax. +| this application. We just need to utilize it! We'll simply require it +| into the script here so we don't need to manually load our classes. | */ -require __DIR__.'/../bootstrap/autoload.php'; - -/* -|-------------------------------------------------------------------------- -| Turn On The Lights -|-------------------------------------------------------------------------- -| -| We need to illuminate PHP development, so let us turn on the lights. -| This bootstraps the framework and gets it ready for use, then it -| will load up this application so that we can run it and send -| the responses back to the browser and delight our users. -| -*/ - -$app = require_once __DIR__.'/../bootstrap/app.php'; +require __DIR__.'/../vendor/autoload.php'; /* |-------------------------------------------------------------------------- | Run The Application |-------------------------------------------------------------------------- | -| Once we have the application, we can handle the incoming request -| through the kernel, and send the associated response back to -| the client's browser allowing them to enjoy the creative -| and wonderful application we have prepared for them. +| Once we have the application, we can handle the incoming request using +| the application's HTTP kernel. Then, we will send the response back +| to this client's browser, allowing them to enjoy our application. | */ -$kernel = $app->make('Illuminate\Contracts\Http\Kernel'); +$app = require_once __DIR__.'/../bootstrap/app.php'; + +$kernel = $app->make(Kernel::class); $response = $kernel->handle( - $request = Illuminate\Http\Request::capture() -); + $request = Request::capture() +)->send(); -$response->send(); - -$kernel->terminate($request, $response); +$kernel->terminate($request, $response); \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index c63c4a786..2db7e6af0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -10,7 +10,8 @@ use App\Http\Controllers\Job; use App\Http\Controllers\Update; use Illuminate\Support\Facades\Request; use Illuminate\Support\Facades\Route; - +use DaveJamesMiller\Breadcrumbs\Facades\Breadcrumbs; +use Illuminate\Support\Facades\Lang; /* |-------------------------------------------------------------------------- | Application Routes @@ -23,7 +24,7 @@ use Illuminate\Support\Facades\Route; */ Route::middleware('web')->group(function () { Route::middleware('install', 'update')->group(function () { - Auth::routes(); + \Illuminate\Support\Facades\Auth::routes(); Route::post('login', [Auth\AuthController::class, 'postLogin'])->name('post.login'); Route::post('auth/register', [Auth\AuthController::class, 'postRegister'])->name('post.register'); Route::post('password/reset', [Auth\PasswordController::class, 'reset'])->name('post.reset'); @@ -277,8 +278,8 @@ Route::middleware('web')->group(function () { */ Route::resource('labels', 'Admin\helpdesk\Label\LabelController'); - Route::get('labels-ajax', [Admin\helpdesk\Label\LabelController::class, 'ajaxTable'])->name('labels.ajax'); - Route::get('labels/delete/{id}', [Admin\helpdesk\Label\LabelController::class, 'destroy'])->name('labels.destroy'); +// Route::get('labels-ajax', [Admin\helpdesk\Label\LabelController::class, 'ajaxTable'])->name('labels.ajax'); +// Route::get('labels/delete/{id}', [Admin\helpdesk\Label\LabelController::class, 'destroy'])->name('labels.destroy'); Route::get('clean-dummy-data', [Admin\helpdesk\SettingsController::class, 'getCleanUpView'])->name('clean-database'); Route::post('post-clean-dummy-data', [Admin\helpdesk\SettingsController::class, 'postCleanDummyData'])->name('post-clean-database'); @@ -378,12 +379,12 @@ Route::middleware('web')->group(function () { Route::get('/get-parent-tickets/{id}', [Agent\helpdesk\TicketController::class, 'getParentTickets'])->name('get.parent.ticket'); Route::patch('/merge-tickets/{id}', [Agent\helpdesk\TicketController::class, 'mergeTickets'])->name('merge.tickets'); //To get department tickets data - //open tickets of department - Route::get('/get-open-tickets/{id}', [Agent\helpdesk\Ticket2Controller::class, 'getOpenTickets'])->name('get.dept.open'); - //close tickets of deartment - Route::get('/get-closed-tickets/{id}', [Agent\helpdesk\Ticket2Controller::class, 'getCloseTickets'])->name('get.dept.close'); - //in progress ticket of department - Route::get('/get-under-process-tickets/{id}', [Agent\helpdesk\Ticket2Controller::class, 'getInProcessTickets'])->name('get.dept.inprocess'); +// //open tickets of department +// Route::get('/get-open-tickets/{id}', [Agent\helpdesk\Ticket2Controller::class, 'getOpenTickets'])->name('get.dept.open'); +// //close tickets of deartment +// Route::get('/get-closed-tickets/{id}', [Agent\helpdesk\Ticket2Controller::class, 'getCloseTickets'])->name('get.dept.close'); +// //in progress ticket of department +// Route::get('/get-under-process-tickets/{id}', [Agent\helpdesk\Ticket2Controller::class, 'getInProcessTickets'])->name('get.dept.inprocess'); // route for graphical reporting Route::get('report', [Agent\helpdesk\ReportController::class, 'index'])->name('report.index'); /* To show dashboard pages */ @@ -399,14 +400,14 @@ Route::middleware('web')->group(function () { /* * Label */ - Route::get('labels-ticket', [Admin\helpdesk\Label\LabelController::class, 'attachTicket'])->name('labels.ticket'); - Route::get('json-labels', [Admin\helpdesk\Label\LabelController::class, 'getLabel'])->name('labels.json'); +// Route::get('labels-ticket', [Admin\helpdesk\Label\LabelController::class, 'attachTicket'])->name('labels.ticket'); +// Route::get('json-labels', [Admin\helpdesk\Label\LabelController::class, 'getLabel'])->name('labels.json'); /* * Tags */ - Route::get('add-tag', [Agent\helpdesk\Filter\TagController::class, 'addToFilter'])->name('tag.add'); - Route::get('get-tag', [Agent\helpdesk\Filter\TagController::class, 'getTag'])->name('tag.get'); +// Route::get('add-tag', [Agent\helpdesk\Filter\TagController::class, 'addToFilter'])->name('tag.add'); +// Route::get('get-tag', [Agent\helpdesk\Filter\TagController::class, 'getTag'])->name('tag.get'); Route::middleware('force.option', 'role.agent')->group(function () { Route::get('tickets', [Agent\helpdesk\TicketController::class, 'getTicketsView'])->name('tickets-view'); @@ -729,12 +730,12 @@ Route::middleware('web')->group(function () { /* * Webhook */ - \Event::listen('ticket.details', function ($details) { + \Illuminate\Support\Facades\Event::listen('ticket.details', function ($details) { $api_control = new \App\Http\Controllers\Common\ApiSettings(); $api_control->ticketDetailEvent($details); }); - Route::get('test', [Common\PushNotificationController::class, 'response'])->name('test'); +// Route::get('test', [Common\PushNotificationController::class, 'response'])->name('test'); Route::get('mail/config/service', [Job\MailController::class, 'serviceForm'])->name('mail.config.service'); /*