42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Site;
|
|
|
|
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): View
|
|
{
|
|
$user = $request->user();
|
|
$project = $request->get('project');
|
|
$websiteTranslations = $request->get('websiteTranslations');
|
|
|
|
if (\is_null($project)) {
|
|
$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($project, $websiteTranslations, $request->user());
|
|
if ($result->isError()) {
|
|
$this->errors($result);
|
|
}
|
|
if ($result->isTranslation()) {
|
|
return $this->viewPageWithoutTranslation($result);
|
|
}
|
|
|
|
return \view('site.projects.about', $result->getData());
|
|
}
|
|
}
|