Версия 0.3.0 #3
@ -11,7 +11,6 @@
|
|||||||
use App\Dto\Builder\DocumentationCategory as DocumentationCategoryBuilderDto;
|
use App\Dto\Builder\DocumentationCategory as DocumentationCategoryBuilderDto;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
final readonly class DocumentationCategoryRepository
|
final readonly class DocumentationCategoryRepository
|
||||||
@ -63,7 +62,7 @@ public function isExistsSlug(int $versionId, string $slug, ?int $exceptId = null
|
|||||||
->exists();
|
->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getForSelect(?ProjectLanguage $defaultLanguage, ?DocumentationCategory $exceptCategory = null, array $withExcepts = []): array
|
public function getForSelect(DocumentationVersion $version, ?ProjectLanguage $defaultLanguage, ?DocumentationCategory $exceptCategory = null, array $withExcepts = []): array
|
||||||
{
|
{
|
||||||
$with = [
|
$with = [
|
||||||
'content' => function (HasOne $hasOne) use ($defaultLanguage) {
|
'content' => function (HasOne $hasOne) use ($defaultLanguage) {
|
||||||
@ -73,7 +72,7 @@ public function getForSelect(?ProjectLanguage $defaultLanguage, ?DocumentationCa
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
$categories = DocumentationCategory::query()
|
$categories = $version->categories()
|
||||||
->with($with)
|
->with($with)
|
||||||
->when($exceptCategory, function (Builder $query, DocumentationCategory $exceptCategory) {
|
->when($exceptCategory, function (Builder $query, DocumentationCategory $exceptCategory) {
|
||||||
$query->whereNotIn(
|
$query->whereNotIn(
|
||||||
|
@ -89,7 +89,7 @@ public function create(int $projectId, int $versionId, User $user): ServiceResul
|
|||||||
'version' => $version,
|
'version' => $version,
|
||||||
'project' => $project,
|
'project' => $project,
|
||||||
'category' => new DocumentationCategory(),
|
'category' => new DocumentationCategory(),
|
||||||
'categories' => $this->documentationCategoryRepository->getForSelect($defaultLanguage),
|
'categories' => $this->documentationCategoryRepository->getForSelect($version, $defaultLanguage),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ public function edit(int $projectId, int $versionId, int $categoryId, User $user
|
|||||||
'version' => $version,
|
'version' => $version,
|
||||||
'project' => $project,
|
'project' => $project,
|
||||||
'category' => $category,
|
'category' => $category,
|
||||||
'categories' => $this->documentationCategoryRepository->getForSelect($defaultLanguage, $category, $withCategories),
|
'categories' => $this->documentationCategoryRepository->getForSelect($version, $defaultLanguage, $category, $withCategories),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
use App\Dto\Builder\Documentation as DocumentationBuilderDto;
|
use App\Dto\Builder\Documentation as DocumentationBuilderDto;
|
||||||
use App\Dto\QuerySettingsDto;
|
use App\Dto\QuerySettingsDto;
|
||||||
use App\Dto\Service\Admin\Project\Documentation\StoreUpdate;
|
use App\Dto\Service\Admin\Project\Documentation\StoreUpdate;
|
||||||
|
use App\Exceptions\Services\DocumentationContent\StorageCommandException;
|
||||||
use App\Models\Documentation;
|
use App\Models\Documentation;
|
||||||
use App\Models\ProjectLanguage;
|
use App\Models\ProjectLanguage;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Repositories\DocumentationCategoryRepository;
|
use App\Repositories\DocumentationCategoryRepository;
|
||||||
use App\Repositories\DocumentationRepository;
|
use App\Repositories\DocumentationRepository;
|
||||||
use App\Repositories\DocumentationVersionRepository;
|
use App\Repositories\DocumentationVersionRepository;
|
||||||
use App\Repositories\ProjectRepository;
|
|
||||||
use App\ServiceResults\ServiceResultArray;
|
use App\ServiceResults\ServiceResultArray;
|
||||||
use App\ServiceResults\ServiceResultError;
|
use App\ServiceResults\ServiceResultError;
|
||||||
use App\ServiceResults\ServiceResultSuccess;
|
use App\ServiceResults\ServiceResultSuccess;
|
||||||
@ -89,7 +89,7 @@ public function create(int $projectId, int $versionId, User $user): ServiceResul
|
|||||||
'version' => $version,
|
'version' => $version,
|
||||||
'project' => $project,
|
'project' => $project,
|
||||||
'documentation' => new Documentation(),
|
'documentation' => new Documentation(),
|
||||||
'categories' => $this->documentationCategoryRepository->getForSelect($defaultLanguage),
|
'categories' => $this->documentationCategoryRepository->getForSelect($version, $defaultLanguage),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ public function edit(int $projectId, int $versionId, int $documentationId, User
|
|||||||
'version' => $version,
|
'version' => $version,
|
||||||
'project' => $project,
|
'project' => $project,
|
||||||
'documentation' => $documentation,
|
'documentation' => $documentation,
|
||||||
'categories' => $this->documentationCategoryRepository->getForSelect($defaultLanguage, null, $withCategories),
|
'categories' => $this->documentationCategoryRepository->getForSelect($version, $defaultLanguage, null, $withCategories),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,6 +150,8 @@ public function store(int $projectId, int $versionId, StoreUpdate $data, User $u
|
|||||||
|
|
||||||
return $documentation;
|
return $documentation;
|
||||||
});
|
});
|
||||||
|
} catch (StorageCommandException $e) {
|
||||||
|
return $e->getResultError();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
report($e);
|
report($e);
|
||||||
return $this->errService(__('Server Error'));
|
return $this->errService(__('Server Error'));
|
||||||
@ -190,6 +192,8 @@ public function update(int $projectId, int $versionId, int $documentationId, Sto
|
|||||||
|
|
||||||
return $documentation;
|
return $documentation;
|
||||||
});
|
});
|
||||||
|
} catch (StorageCommandException $e) {
|
||||||
|
return $e->getResultError();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
report($e);
|
report($e);
|
||||||
return $this->errService(__('Server Error'));
|
return $this->errService(__('Server Error'));
|
||||||
|
Loading…
Reference in New Issue
Block a user