controller reorganization

cleaned up the controller directory and renamed files to more approriate
names.

made the appropriate changes to RouteController as well as tweaking the
routing so it's simpler and easier to follow
This commit is contained in:
ro 2024-05-09 11:24:12 -06:00
parent d8ee4926b1
commit 7f1654d13b
No known key found for this signature in database
GPG key ID: 29B551CDBD4D3B50
5 changed files with 19 additions and 28 deletions

View file

@ -1,9 +1,8 @@
<?php <?php
namespace App\Http\Controllers\Dash; namespace App\Http\Controllers;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use App\Http\Controllers\Controller;
use App\Services\AuthService; use App\Services\AuthService;
use Illuminate\Http\Request; use Illuminate\Http\Request;

View file

@ -1,14 +1,13 @@
<?php <?php
namespace App\Http\Controllers\Dash; namespace App\Http\Controllers;
use App\Interfaces\PageRepositoryInterface; use App\Interfaces\PageRepositoryInterface;
use App\Services\AuthService; use App\Services\AuthService;
use App\Services\ThemeService; use App\Services\ThemeService;
use App\Services\SortingService; use App\Services\SortingService;
use App\Http\Controllers\Controller;
class IndexController extends Controller class DashController extends Controller
{ {
protected PageRepositoryInterface $pages; protected PageRepositoryInterface $pages;
protected AuthService $auth; protected AuthService $auth;
@ -45,12 +44,10 @@ class IndexController extends Controller
return $this->page($third, $fourth); return $this->page($third, $fourth);
break; break;
case 'logout': case 'logout':
session()->flush(); return $this->logout();
return redirect()->intended('dashboard');
break; break;
default: default:
return $this->start(); return $this->start();
break; break;
} }
} }
@ -58,7 +55,7 @@ class IndexController extends Controller
public function login() public function login()
{ {
if ($this->auth::status()) { if ($this->auth::status()) {
return redirect('dashboard/start'); return redirect('dashboard');
} else { } else {
return view('back.login', [ return view('back.login', [
"status" => $this->auth::status(), "status" => $this->auth::status(),
@ -121,4 +118,10 @@ class IndexController extends Controller
{ {
return view('back.settings', $this->sort->settings()); return view('back.settings', $this->sort->settings());
} }
public function logout()
{
session()->flush();
return redirect()->intended('dashboard');
}
} }

View file

@ -1,9 +1,8 @@
<?php <?php
namespace App\Http\Controllers\Front; namespace App\Http\Controllers;
use App\Services\SettingsService; use App\Services\SettingsService;
use App\Http\Controllers\Controller;
use App\Services\AuthService; use App\Services\AuthService;
use App\Interfaces\PageRepositoryInterface; use App\Interfaces\PageRepositoryInterface;
use App\Services\SortingService; use App\Services\SortingService;
@ -11,7 +10,7 @@ use App\Services\AssetService;
use function _\find; use function _\find;
class StartController extends Controller class FrontController extends Controller
{ {
protected $settings; protected $settings;
protected $auth; protected $auth;

View file

@ -2,10 +2,6 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Http\Controllers\Dash\IndexController;
use App\Http\Controllers\Dash\AuthController;
use App\Http\Controllers\Front\StartController;
use App\Http\Controllers\Theming\ThemeController;
use App\Services\AuthService; use App\Services\AuthService;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -18,16 +14,16 @@ class RouteController extends Controller
protected $auth; protected $auth;
public function __construct( public function __construct(
IndexController $indexController, DashController $dashController,
AuthController $authController, AuthController $authController,
ThemeController $themeController, ThemeController $themeController,
StartController $startContoller, FrontController $frontController,
AuthService $authService, AuthService $authService,
) { ) {
$this->dash = $indexController; $this->dash = $dashController;
$this->gate = $authController; $this->gate = $authController;
$this->theme = $themeController; $this->theme = $themeController;
$this->front = $startContoller; $this->front = $frontController;
$this->auth = $authService; $this->auth = $authService;
} }
@ -37,11 +33,7 @@ class RouteController extends Controller
switch ($first) { switch ($first) {
case 'dashboard': case 'dashboard':
if ($this->auth::status()) { if ($this->auth::status()) {
if (isset($second)) { return $this->dash->init($second, $third, $fourth);
return $this->dash->init($second, $third, $fourth);
} else {
return $this->dash->start();
}
} else { } else {
return $this->dash->login(); return $this->dash->login();
} }
@ -56,7 +48,6 @@ class RouteController extends Controller
} else { } else {
return $this->dash->login(); return $this->dash->login();
} }
break; break;
case 'tags': case 'tags':
case 'archives': case 'archives':

View file

@ -1,8 +1,7 @@
<?php <?php
namespace App\Http\Controllers\Theming; namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Interfaces\PageRepositoryInterface; use App\Interfaces\PageRepositoryInterface;
use App\Services\AuthService; use App\Services\AuthService;
use App\Services\SortingService; use App\Services\SortingService;