Replaced Moment with Carbon #84

Merged
Ghost merged 148 commits from develop into beta 2022-09-22 05:53:36 +02:00
6 changed files with 111 additions and 21 deletions
Showing only changes of commit 177f29802b - Show all commits

View file

@ -2,16 +2,16 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Services\PaginateService; use App\Interfaces\PageRepositoryInterface;
class DashController extends Controller class DashController extends Controller
{ {
protected $pages; protected PageRepositoryInterface $pages;
public function __construct( public function __construct(
PaginateService $paginateService, PageRepositoryInterface $pageRepository,
) { ) {
$this->pages = $paginateService; $this->pages = $pageRepository;
} }
public function start() public function start()
@ -19,7 +19,7 @@ class DashController extends Controller
$status = session('handle') !== null ? true : false; $status = session('handle') !== null ? true : false;
$result = []; $result = [];
if ($status) { if ($status) {
$result = $this->pages->getPage(1, 4); $result = $this->pages->getGroup(1, 4);
} }
return view('back.start', [ return view('back.start', [
"status" => $status, "status" => $status,
@ -28,7 +28,22 @@ class DashController extends Controller
]); ]);
} }
public function book($pageFilter = 'all', $pageNum = '1') public function book($pageFilter = 'all', $pageNum = 1)
{
$status = session('handle') !== null ? true : false;
$result = [];
if ($status) {
$result = $this->pages->getGroup($pageNum, 4, $pageFilter);
}
return view('back.book', [
"status" => $status,
"result" => $result,
"currentPage" => $pageNum,
"title" => "Pages"
]);
}
public function page($uuid)
{ {
$status = session('handle') !== null ? true : false; $status = session('handle') !== null ? true : false;
$result = []; $result = [];

View file

@ -0,0 +1,18 @@
<?php
namespace App\Interfaces;
interface PageRepositoryInterface
{
public function getAll();
public function getByID($uuid);
public function delete($uuid);
public function create(array $page);
public function update($uuid, array $page);
public function getGroup($num, $limit, $filter);
}

View file

@ -3,6 +3,8 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use App\Repositories\PageRepository;
use App\Interfaces\PageRepositoryInterface;
use App\Services\SettingsService; use App\Services\SettingsService;
use App\Services\AuthService; use App\Services\AuthService;
use App\Services\ContentService; use App\Services\ContentService;
@ -15,6 +17,7 @@ class FipamoServiceProvider extends ServiceProvider
*/ */
public function register(): void public function register(): void
{ {
//services
$this->app->bind(SettingsService::class, function ($app) { $this->app->bind(SettingsService::class, function ($app) {
return new SettingsService(); return new SettingsService();
}); });
@ -37,6 +40,6 @@ class FipamoServiceProvider extends ServiceProvider
*/ */
public function boot(): void public function boot(): void
{ {
// $this->app->bind(PageRepositoryInterface::class, PageRepository::class);
} }
} }

View file

@ -0,0 +1,53 @@
<?php
namespace App\Repositories;
use App\Interfaces\PageRepositoryInterface;
use App\Services\SettingsService;
use App\Services\ContentService;
use App\Services\PaginateService;
class PageRepository implements PageRepositoryInterface
{
protected $content;
protected $setttings;
protected $paginate;
protected $pages;
public function __construct(
ContentService $contentService,
SettingsService $settingsService,
PaginateService $paginateService
) {
$this->content = $contentService;
$this->settings = $settingsService;
$this->paginate = $paginateService;
$this->pages = $this->content->loadAllPages();
}
public function getAll()
{
return $this->pages;
}
public function getById($uuid)
{
}
public function delete($uuid)
{
}
public function create(array $page)
{
}
public function update($uuid, array $page)
{
}
public function getGroup($num, $limit, $sort = "all")
{
return $this->paginate->getPage($num, $limit, $sort);
}
}

View file

@ -28,5 +28,6 @@ Route::post("/login", [AuthController::class, 'enter']);
Route::group(['prefix' => 'dashboard'], function () { Route::group(['prefix' => 'dashboard'], function () {
Route::get("/", [DashController::class, 'start']); Route::get("/", [DashController::class, 'start']);
Route::get("/pages/{pageFilter?}/{pageNum?}", [DashController::class, 'book']); Route::get("/pages/{pageFilter?}/{pageNum?}", [DashController::class, 'book']);
Route::get("/page/{uuid}", [DashController::class, 'page']);
Route::get("/logout", [AuthController::class, 'exit']); Route::get("/logout", [AuthController::class, 'exit']);
}); });