2024-02-29 20:00:59 +01:00
|
|
|
<?php
|
|
|
|
|
2024-05-09 19:24:12 +02:00
|
|
|
namespace App\Http\Controllers;
|
2024-02-29 20:00:59 +01:00
|
|
|
|
2024-03-05 20:27:27 +01:00
|
|
|
use App\Interfaces\PageRepositoryInterface;
|
2024-05-13 20:06:05 +02:00
|
|
|
use App\Interfaces\MemberRepositoryInterface;
|
2024-05-13 06:14:53 +02:00
|
|
|
use App\Services\Data\ThemeService;
|
|
|
|
use App\Services\Data\SortingService;
|
2024-03-01 20:34:36 +01:00
|
|
|
|
2024-05-09 19:24:12 +02:00
|
|
|
class DashController extends Controller
|
2024-02-29 20:00:59 +01:00
|
|
|
{
|
2024-03-05 20:27:27 +01:00
|
|
|
protected PageRepositoryInterface $pages;
|
2024-05-13 20:06:05 +02:00
|
|
|
protected MemberRepositoryInterface $member;
|
2024-03-06 17:27:41 +01:00
|
|
|
protected ThemeService $themes;
|
2024-03-19 20:19:27 +01:00
|
|
|
protected SortingService $sort;
|
2024-02-29 20:00:59 +01:00
|
|
|
|
2024-03-01 20:34:36 +01:00
|
|
|
public function __construct(
|
2024-03-05 20:27:27 +01:00
|
|
|
PageRepositoryInterface $pageRepository,
|
2024-05-13 20:06:05 +02:00
|
|
|
MemberRepositoryInterface $memberRepo,
|
2024-03-06 17:27:41 +01:00
|
|
|
ThemeService $themeService,
|
2024-03-19 20:19:27 +01:00
|
|
|
SortingService $sortingService
|
2024-03-01 20:34:36 +01:00
|
|
|
) {
|
2024-03-06 17:27:41 +01:00
|
|
|
$this->pages = $pageRepository;
|
2024-05-13 20:06:05 +02:00
|
|
|
$this->member = $memberRepo;
|
2024-03-06 17:27:41 +01:00
|
|
|
$this->themes = $themeService;
|
2024-03-19 20:19:27 +01:00
|
|
|
$this->sort = $sortingService;
|
2024-02-29 20:00:59 +01:00
|
|
|
}
|
|
|
|
|
2024-07-13 22:23:01 +02:00
|
|
|
//---
|
|
|
|
// GET
|
|
|
|
//---
|
|
|
|
|
2024-05-06 21:37:26 +02:00
|
|
|
public function init($second, $third, $fourth)
|
|
|
|
{
|
|
|
|
switch ($second) {
|
|
|
|
case 'settings':
|
|
|
|
return $this->settings();
|
|
|
|
break;
|
|
|
|
case 'navigation':
|
2024-05-06 23:18:05 +02:00
|
|
|
return $this->navigation();
|
2024-05-06 21:37:26 +02:00
|
|
|
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':
|
2024-05-09 19:24:12 +02:00
|
|
|
return $this->logout();
|
2024-05-06 21:37:26 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return $this->start();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-04 02:50:14 +01:00
|
|
|
public function start()
|
2024-02-29 20:00:59 +01:00
|
|
|
{
|
2024-03-04 00:49:05 +01:00
|
|
|
$result = [];
|
2024-05-13 20:06:05 +02:00
|
|
|
if ($this->member::status()) {
|
2024-03-05 20:27:27 +01:00
|
|
|
$result = $this->pages->getGroup(1, 4);
|
2024-03-04 00:49:05 +01:00
|
|
|
}
|
2024-03-02 01:16:24 +01:00
|
|
|
return view('back.start', [
|
2024-05-13 20:06:05 +02:00
|
|
|
"status" => $this->member::status(),
|
2024-03-04 00:49:05 +01:00
|
|
|
"result" => $result,
|
2024-03-05 03:06:36 +01:00
|
|
|
"title" => "Start"
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-03-05 20:27:27 +01:00
|
|
|
public function book($pageFilter = 'all', $pageNum = 1)
|
|
|
|
{
|
|
|
|
$result = [];
|
2024-05-13 20:06:05 +02:00
|
|
|
if ($this->member::status()) {
|
2024-03-05 20:27:27 +01:00
|
|
|
$result = $this->pages->getGroup($pageNum, 4, $pageFilter);
|
|
|
|
}
|
|
|
|
return view('back.book', [
|
2024-06-04 22:58:55 +02:00
|
|
|
"status" => $this->member::status(),
|
2024-03-05 20:27:27 +01:00
|
|
|
"result" => $result,
|
|
|
|
"currentPage" => $pageNum,
|
|
|
|
"title" => "Pages"
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-03-05 22:49:30 +01:00
|
|
|
public function page($mode, $uuid)
|
2024-03-05 03:06:36 +01:00
|
|
|
{
|
2024-03-12 23:16:36 +01:00
|
|
|
$title;
|
|
|
|
$page = [];
|
|
|
|
$views = [];
|
2024-09-04 22:32:36 +02:00
|
|
|
$mode == 'edit' ? $page = $this->pages->getByUuid($uuid) : $page = [];
|
2024-03-12 23:16:36 +01:00
|
|
|
$mode == 'edit' ? $title = $page['title'] : $title = 'Add New';
|
|
|
|
$mode == 'edit' ? $views = $this->themes->getCustomViews($page['layout']) : $views[] = 'page';
|
2024-03-15 22:18:10 +01:00
|
|
|
|
2024-03-05 22:49:30 +01:00
|
|
|
return view('back.page', [
|
2024-05-13 20:06:05 +02:00
|
|
|
"status" => $this->member::status(),
|
2024-03-05 22:49:30 +01:00
|
|
|
"mode" => $mode,
|
|
|
|
"page" => $page,
|
2024-03-12 23:16:36 +01:00
|
|
|
"views" => $views,
|
|
|
|
"title" => $title,
|
2024-03-02 01:16:24 +01:00
|
|
|
]);
|
2024-02-29 20:00:59 +01:00
|
|
|
}
|
2024-03-19 20:19:27 +01:00
|
|
|
|
2024-03-22 21:35:44 +01:00
|
|
|
public function navigation()
|
|
|
|
{
|
|
|
|
return view('back.navigation', $this->sort->navigation());
|
|
|
|
}
|
|
|
|
|
2024-03-19 20:19:27 +01:00
|
|
|
public function settings()
|
|
|
|
{
|
|
|
|
return view('back.settings', $this->sort->settings());
|
|
|
|
}
|
2024-05-09 19:24:12 +02:00
|
|
|
|
2024-07-13 22:23:01 +02:00
|
|
|
//---
|
|
|
|
// POST
|
|
|
|
//---
|
|
|
|
|
|
|
|
//---
|
|
|
|
// PUT
|
|
|
|
//---
|
|
|
|
|
|
|
|
//---
|
|
|
|
// AUTH
|
|
|
|
//---
|
|
|
|
|
|
|
|
public function login()
|
|
|
|
{
|
|
|
|
if ($this->member::status()) {
|
|
|
|
return redirect('dashboard');
|
|
|
|
} else {
|
|
|
|
return view('back.login', [
|
|
|
|
"status" => $this->member::status(),
|
|
|
|
"title" => "Hi!"
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-09 19:24:12 +02:00
|
|
|
public function logout()
|
|
|
|
{
|
|
|
|
session()->flush();
|
|
|
|
return redirect()->intended('dashboard');
|
|
|
|
}
|
2024-02-29 20:00:59 +01:00
|
|
|
}
|