The page about the project has been revived.
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user