2024-02-29 20:00:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2024-03-05 20:27:27 +01:00
|
|
|
use App\Interfaces\PageRepositoryInterface;
|
2024-03-06 16:50:09 +01:00
|
|
|
use App\Services\AuthService;
|
2024-03-06 17:27:41 +01:00
|
|
|
use App\Services\ThemeService;
|
2024-03-01 20:34:36 +01:00
|
|
|
|
2024-02-29 20:00:59 +01:00
|
|
|
class DashController extends Controller
|
|
|
|
{
|
2024-03-05 20:27:27 +01:00
|
|
|
protected PageRepositoryInterface $pages;
|
2024-03-06 16:50:09 +01:00
|
|
|
protected AuthService $auth;
|
2024-03-06 17:27:41 +01:00
|
|
|
protected ThemeService $themes;
|
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-03-06 16:50:09 +01:00
|
|
|
AuthService $authService,
|
2024-03-06 17:27:41 +01:00
|
|
|
ThemeService $themeService,
|
2024-03-01 20:34:36 +01:00
|
|
|
) {
|
2024-03-06 17:27:41 +01:00
|
|
|
$this->pages = $pageRepository;
|
|
|
|
$this->auth = $authService;
|
|
|
|
$this->themes = $themeService;
|
2024-02-29 20:00:59 +01:00
|
|
|
}
|
|
|
|
|
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-03-06 16:50:09 +01:00
|
|
|
if ($this->auth::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-03-06 16:50:09 +01:00
|
|
|
"status" => $this->auth::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-03-06 16:50:09 +01:00
|
|
|
if ($this->auth::status()) {
|
2024-03-05 20:27:27 +01:00
|
|
|
$result = $this->pages->getGroup($pageNum, 4, $pageFilter);
|
|
|
|
}
|
|
|
|
return view('back.book', [
|
2024-03-06 16:50:09 +01:00
|
|
|
"status" => $this->auth::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-06 16:50:09 +01:00
|
|
|
$page = $this->pages->getById($uuid)->first();
|
2024-03-05 22:49:30 +01:00
|
|
|
return view('back.page', [
|
2024-03-06 16:50:09 +01:00
|
|
|
"status" => $this->auth::status(),
|
2024-03-05 22:49:30 +01:00
|
|
|
"mode" => $mode,
|
|
|
|
"page" => $page,
|
2024-03-06 17:27:41 +01:00
|
|
|
"views" => $this->themes->getCustomViews($page['layout']),
|
2024-03-05 22:49:30 +01:00
|
|
|
"title" => 'Editing ' . $page['title']
|
2024-03-02 01:16:24 +01:00
|
|
|
]);
|
2024-02-29 20:00:59 +01:00
|
|
|
}
|
|
|
|
}
|