forked from projects/fipamo
ro
36d04c8f68
service classes are beginning to swell as there functionality is being fleshed out, so a new organizational structure was needed to make sure class sizes don't become too large and to increase site managability and legibilty as more features get added and the code base grows. data is for retrieving, managing site information, assets interact with external files and upkeep is for maintenance. some additional tweaks were also made to the options menu template to prep it for it's transition to a toolbar component
128 lines
3.5 KiB
PHP
128 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Interfaces\PageRepositoryInterface;
|
|
use App\Services\Data\AuthService;
|
|
use App\Services\Data\ThemeService;
|
|
use App\Services\Data\SortingService;
|
|
|
|
class DashController extends Controller
|
|
{
|
|
protected PageRepositoryInterface $pages;
|
|
protected AuthService $auth;
|
|
protected ThemeService $themes;
|
|
protected SortingService $sort;
|
|
|
|
public function __construct(
|
|
PageRepositoryInterface $pageRepository,
|
|
AuthService $authService,
|
|
ThemeService $themeService,
|
|
SortingService $sortingService
|
|
) {
|
|
$this->pages = $pageRepository;
|
|
$this->auth = $authService;
|
|
$this->themes = $themeService;
|
|
$this->sort = $sortingService;
|
|
}
|
|
|
|
public function init($second, $third, $fourth)
|
|
{
|
|
switch ($second) {
|
|
case 'settings':
|
|
return $this->settings();
|
|
break;
|
|
case 'navigation':
|
|
return $this->navigation();
|
|
break;
|
|
case 'pages':
|
|
($third == null) ? $third = 'all' : $third = $third;
|
|
($fourth == null) ? $fourth = 1 : $fourth = $fourth;
|
|
return $this->book($third, $fourth);
|
|
break;
|
|
case 'page':
|
|
return $this->page($third, $fourth);
|
|
break;
|
|
case 'logout':
|
|
return $this->logout();
|
|
break;
|
|
default:
|
|
return $this->start();
|
|
break;
|
|
}
|
|
}
|
|
|
|
public function login()
|
|
{
|
|
if ($this->auth::status()) {
|
|
return redirect('dashboard');
|
|
} else {
|
|
return view('back.login', [
|
|
"status" => $this->auth::status(),
|
|
"title" => "Hi!"
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function start()
|
|
{
|
|
$result = [];
|
|
if ($this->auth::status()) {
|
|
$result = $this->pages->getGroup(1, 4);
|
|
}
|
|
return view('back.start', [
|
|
"status" => $this->auth::status(),
|
|
"result" => $result,
|
|
"title" => "Start"
|
|
]);
|
|
}
|
|
|
|
public function book($pageFilter = 'all', $pageNum = 1)
|
|
{
|
|
$result = [];
|
|
if ($this->auth::status()) {
|
|
$result = $this->pages->getGroup($pageNum, 4, $pageFilter);
|
|
}
|
|
return view('back.book', [
|
|
"status" => $this->auth::status(),
|
|
"result" => $result,
|
|
"currentPage" => $pageNum,
|
|
"title" => "Pages"
|
|
]);
|
|
}
|
|
|
|
public function page($mode, $uuid)
|
|
{
|
|
$title;
|
|
$page = [];
|
|
$views = [];
|
|
$mode == 'edit' ? $page = $this->pages->getById($uuid) : $page = [];
|
|
$mode == 'edit' ? $title = $page['title'] : $title = 'Add New';
|
|
$mode == 'edit' ? $views = $this->themes->getCustomViews($page['layout']) : $views[] = 'page';
|
|
|
|
return view('back.page', [
|
|
"status" => $this->auth::status(),
|
|
"mode" => $mode,
|
|
"page" => $page,
|
|
"views" => $views,
|
|
"title" => $title,
|
|
]);
|
|
}
|
|
|
|
public function navigation()
|
|
{
|
|
return view('back.navigation', $this->sort->navigation());
|
|
}
|
|
|
|
public function settings()
|
|
{
|
|
return view('back.settings', $this->sort->settings());
|
|
}
|
|
|
|
public function logout()
|
|
{
|
|
session()->flush();
|
|
return redirect()->intended('dashboard');
|
|
}
|
|
}
|