previously all the of the page routing was handlede through controller organized by CRUD methods. it worked, but organizing by CRUD and not purpose resulted in more time spent looking for a specific task through controllers, so it turned out not to an effecient way of organizing. so routing has been completely reorganized into laravel's web routing section and methods have been moved to their appropriate controller so tasks are much easier to find front facing page routing turned out to be a bit more tricky that anticipated do the overap of routing paths, but it only affects dynamic page rendering and there's a patch in place that handles that issue until a better solution is found. Rendered HTML pages works fine. whew!
98 lines
2.4 KiB
PHP
98 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Interfaces\PageRepositoryInterface;
|
|
use App\Interfaces\MemberRepositoryInterface;
|
|
use App\Services\Assets\FileUploadService;
|
|
use Illuminate\Http\Request;
|
|
|
|
class DashController extends Controller
|
|
{
|
|
protected PageRepositoryInterface $pages;
|
|
protected MemberRepositoryInterface $member;
|
|
protected FileUploadService $upload;
|
|
|
|
public function __construct(
|
|
PageRepositoryInterface $pageRepository,
|
|
MemberRepositoryInterface $memberRepo,
|
|
FileUploadService $fileUploadService,
|
|
) {
|
|
$this->pages = $pageRepository;
|
|
$this->member = $memberRepo;
|
|
$this->upload = $fileUploadService;
|
|
}
|
|
|
|
//---
|
|
// GET
|
|
//---
|
|
|
|
public function start()
|
|
{
|
|
$result = [];
|
|
|
|
if ($this->member::status()) {
|
|
$result = $this->pages->getGroup(1, 4);
|
|
}
|
|
if ($this->member::status()) {
|
|
return view('back.start', [
|
|
"status" => $this->member::status(),
|
|
"result" => $result,
|
|
"title" => "Start"
|
|
]);
|
|
} else {
|
|
return view('back.login', [
|
|
"status" => $this->member::status(),
|
|
"title" => "Hi!"
|
|
]);
|
|
}
|
|
}
|
|
|
|
//---
|
|
// POST
|
|
//---
|
|
public function uploads(Request $request)
|
|
{
|
|
$result = $result = $this->upload->handleFile($request);
|
|
//update configs for specfic uploads
|
|
switch ($request['source']) {
|
|
case 'avatar-upload':
|
|
$member = [];
|
|
$member = session('member');
|
|
$member['avatar'] = $result['filePath'];
|
|
$member = (object) $member;
|
|
$this->member->update($member);
|
|
break;
|
|
case 'background-upload':
|
|
$this->settings->updateGlobalData('background', $result['filePath']);
|
|
break;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
//---
|
|
// PUT
|
|
//---
|
|
|
|
//---
|
|
// AUTH
|
|
//---
|
|
|
|
public function login()
|
|
{
|
|
if ($this->member::status()) {
|
|
return redirect('dashboard/start');
|
|
} else {
|
|
return view('back.login', [
|
|
"status" => $this->member::status(),
|
|
"title" => "Hi!"
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function logout()
|
|
{
|
|
session()->flush();
|
|
return redirect()->intended('dashboard');
|
|
}
|
|
}
|