The page about the project has been revived.

This commit is contained in:
2024-04-18 19:41:31 +05:00
parent 63ea5dac92
commit 24e0cf0eea
42 changed files with 1126 additions and 6 deletions

View File

@@ -0,0 +1,62 @@
<?php declare(strict_types=1);
namespace App\Http\Controllers\Site;
use App\Enums\Site\ProjectSection;
use App\Services\Site\ProjectService;
use Illuminate\Http\Request;
use Illuminate\View\View;
final class ProjectsController extends Controller
{
public function __construct(
private readonly ProjectService $projectService,
) { }
public function index(Request $request, ?string $language = null): View
{
$user = $request->user();
if (\is_null($request->project)) {
if (!\is_null($language)) {
abort(404);
}
$with = ['storage'];
$result = $this->projectService->getProjects($user, $with);
if ($result->isError()) {
$this->errors($result);
}
return \view('site.projects.index', $result->getData());
}
$result = $this->projectService->getAboutByProject($request->project, $language, $request->user());
if ($result->isError()) {
$this->errors($result);
}
if ($result->isTranslation()) {
return $this->viewPageWithoutTranslation($result);
}
return \view('site.projects.about', $result->getData());
}
public function about(string $project, Request $request, ?string $language = null)
{
$result = $this->projectService->getAbout($project, $language, $request->user());
if ($result->isError()) {
$this->errors($result);
}
if ($result->isTranslation()) {
return $this->viewPageWithoutTranslation($result);
}
if ($result->getProject()->http_href !== null) {
$link = ProjectSection::Home->url($result->getProject(), $result->getLanguage());
return \redirect($result->getProject()->http_href . $link, 302);
}
return \view('site.projects.about', $result->getData());
}
}