Merge remote-tracking branch 'origin/master'
commit
d4cb9921c7
|
|
@ -5,14 +5,11 @@ namespace App\Http\Controllers\Api\Publications;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Pages\Page;
|
||||
use App\Models\Publications\Publication;
|
||||
use App\Models\Publications\PublicationType;
|
||||
use App\Services\Filters\FiltersService;
|
||||
use App\Transformers\Publications\PublicationTransformer;
|
||||
use App\Transformers\Registries\RegistryTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
|
||||
class PublicationsController extends Controller {
|
||||
protected Publication $model;
|
||||
|
|
@ -29,9 +26,17 @@ class PublicationsController extends Controller {
|
|||
public function index(Request $request): JsonResponse {
|
||||
$filters = collect($request->has('filters') ? json_decode($request->get('filters'), true) : [])->filter(function($val) {return $val;});
|
||||
$query = $this->model->query()->orderBy('published_at', 'desc');
|
||||
if ($page = Page::byUuid($request->get('page_id'))->first()) {
|
||||
$query->where(['page_id' => $page->id]);
|
||||
} elseif ($page = Page::query()->where(['sub_type' => 'publication-' . $request->get('type')])->first()) {
|
||||
$query->where('page_id', $page->id);
|
||||
}
|
||||
$service = FiltersService::getService('publications');
|
||||
$service->applyFilters($query, $filters);
|
||||
$paginator = $query->paginate(config('app.pagination_limit'));
|
||||
$paginator = $query->paginate($request->get('limit', config('app.pagination_limit')));
|
||||
if ($request->has('limit')) {
|
||||
$paginator->appends('limit', $request->get('limit'));
|
||||
}
|
||||
return fractal($paginator, new PublicationTransformer())->respond();
|
||||
}
|
||||
|
||||
|
|
@ -56,10 +61,9 @@ class PublicationsController extends Controller {
|
|||
|
||||
public function published(Request $request, $uuid): JsonResponse {
|
||||
$model = $this->model->byUuid($uuid)->firstOrFail();
|
||||
$data = [
|
||||
'is_published' => $request->get('publish')
|
||||
];
|
||||
$model->update($data);
|
||||
if ($request->has('publish')) {
|
||||
$model->update(['is_published' => $request->get('publish')]);
|
||||
}
|
||||
return fractal($model, new PublicationTransformer())->respond();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ class PagesTableSeeder extends Seeder
|
|||
'Консультационные услуги' => [],
|
||||
]
|
||||
],
|
||||
'ТК 465 “Строительство”' => [
|
||||
'ТК 465 «Строительство»' => [
|
||||
'children' => [
|
||||
'Руководство' => [],
|
||||
'Структура' => ['type' => PageType::TK_STRUCTURE],
|
||||
'Состав' => [],
|
||||
'Документы' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED],
|
||||
'АИС ТК 465 “Строительство”' => []
|
||||
'АИС ТК 465 «Строительство»' => []
|
||||
]
|
||||
],
|
||||
'Реестр требований ФЗ-63' => [],
|
||||
|
|
@ -60,7 +60,7 @@ class PagesTableSeeder extends Seeder
|
|||
'Международная деятельность' => [
|
||||
'children' => [
|
||||
'ISO' => [],
|
||||
'МТК 465 “Строительство”' => [],
|
||||
'МТК 465 «Строительство»' => [],
|
||||
'Межправительственный совет' => [],
|
||||
'Базовая организация СНГ' => [],
|
||||
'Разработка ТР ЕАЭС' => [],
|
||||
|
|
|
|||
Loading…
Reference in New Issue