parent
562690e6f7
commit
edccbbf5f9
|
|
@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
||||||
use App\Models\Registries\Category;
|
use App\Models\Registries\Category;
|
||||||
use App\Models\Registries\Entry;
|
use App\Models\Registries\Entry;
|
||||||
use App\Models\Registries\Registry;
|
use App\Models\Registries\Registry;
|
||||||
|
use App\Services\Filters\FiltersService;
|
||||||
use App\Transformers\Registries\EntryTransformer;
|
use App\Transformers\Registries\EntryTransformer;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
@ -18,9 +19,13 @@ class EntriesController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(Request $request): JsonResponse {
|
public function index(Request $request): JsonResponse {
|
||||||
|
$filters = collect($request->has('filters') ? json_decode($request->get('filters'), true) : [])->filter(function($val) {return $val;});
|
||||||
$registry = Registry::byUuid($request->get('registry'))->first();
|
$registry = Registry::byUuid($request->get('registry'))->first();
|
||||||
$category = Category::byUuid($request->get('category'))->first();
|
$category = Category::byUuid($request->get('category'))->first();
|
||||||
$query = $this->model->query()->where(['registry_id' => $registry->id ?? 0, 'category_id' => $category->id ?? 0]);
|
$query = $this->model->query()->where(['registry_id' => $registry->id ?? 0]);
|
||||||
|
if ($filters->isEmpty()) $query->where(['category_id' => $category->id ?? 0]);
|
||||||
|
$service = FiltersService::getService('registryEntries');
|
||||||
|
$service->applyFilters($query, $filters);
|
||||||
$paginator = $query->paginate(config('app.pagination_limit'));
|
$paginator = $query->paginate(config('app.pagination_limit'));
|
||||||
return fractal($paginator, new EntryTransformer())->respond();
|
return fractal($paginator, new EntryTransformer())->respond();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class SendFeedbackMessage {
|
||||||
try {
|
try {
|
||||||
Mail::to($event->email)->send(new FeedbackSender($event->data));
|
Mail::to($event->email)->send(new FeedbackSender($event->data));
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
mail('sergey@bodin.ru', 'Error', $exception->getMessage());
|
var_dump($exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,10 @@ class Entry extends Model {
|
||||||
|
|
||||||
protected $dates = [
|
protected $dates = [
|
||||||
'active_since',
|
'active_since',
|
||||||
'active_till'
|
'active_till',
|
||||||
|
'suspended_since',
|
||||||
|
'suspended_till',
|
||||||
|
'cancelled_at'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
|
|
@ -29,7 +32,10 @@ class Entry extends Model {
|
||||||
'number',
|
'number',
|
||||||
'name',
|
'name',
|
||||||
'active_since',
|
'active_since',
|
||||||
'active_till'
|
'active_till',
|
||||||
|
'suspended_since',
|
||||||
|
'suspended_till',
|
||||||
|
'cancelled_at'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
|
|
@ -50,7 +56,24 @@ class Entry extends Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function operations(): MorphToMany {
|
public function operations(): MorphToMany {
|
||||||
return $this->objects()->reorder()->applyOrders(['order-date' => 'desc']);
|
return $this->objectsByGroup('operations')->reorder()->applyOrders(['order-date' => 'desc']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getPropertiesAttribute(): ?Model {
|
||||||
|
return ($type = $this->registry->parsedType['options']['properties'] ?? null) ? $this->getObject($type, 'properties') : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStateAttribute(): ?array {
|
||||||
|
$state = null;
|
||||||
|
if ($this->active_since) {
|
||||||
|
$state = ($this->active_since <= now()) ? EntryState::ACTIVE : EntryState::AWAITING;
|
||||||
|
if ($this->active_till && ($this->active_till <= now())) $state = EntryState::EXPIRED;
|
||||||
|
elseif ($this->suspended_since && ($this->suspended_since <= now())) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $state ? ['name' => $state, 'title' => EntryState::TITLES[$state] ?? null] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Registries;
|
||||||
|
|
||||||
|
class EntryState {
|
||||||
|
public const AWAITING = 'awaiting';
|
||||||
|
public const ACTIVE = 'active';
|
||||||
|
public const EXPIRED = 'expired';
|
||||||
|
public const SUSPENDED = 'suspended';
|
||||||
|
public const CANCELLED = 'cancelled';
|
||||||
|
|
||||||
|
public const TITLES = [
|
||||||
|
self::AWAITING => 'Вводится в действие',
|
||||||
|
self::ACTIVE => 'Действует',
|
||||||
|
self::EXPIRED => 'Архив',
|
||||||
|
self::SUSPENDED => 'Приостановлено',
|
||||||
|
self::CANCELLED => 'Отменено'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -19,8 +19,7 @@ class Registry extends Model {
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'uuid',
|
'uuid',
|
||||||
'page_id',
|
'page_id',
|
||||||
'type',
|
'type'
|
||||||
'name'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
|
|
@ -47,7 +46,7 @@ class Registry extends Model {
|
||||||
|
|
||||||
|
|
||||||
public function getParsedTypeAttribute(): array {
|
public function getParsedTypeAttribute(): array {
|
||||||
return ['name' => $this->type, 'title' => RegistryType::TITLES[$this->type] ?? null];
|
return ['name' => $this->type, 'title' => RegistryType::TITLES[$this->type] ?? null, 'options' => RegistryType::OPTIONS[$this->type] ?? []];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,28 @@
|
||||||
namespace App\Models\Registries;
|
namespace App\Models\Registries;
|
||||||
|
|
||||||
class RegistryType {
|
class RegistryType {
|
||||||
public const DOCUMENTS = 'documents';
|
public const SIMPLE = 'simple';
|
||||||
|
public const RULESET = 'ruleset';
|
||||||
|
public const LABORATORIES = 'laboratories';
|
||||||
|
public const CERTIFIERS = 'certifiers';
|
||||||
|
public const EXPERTS = 'experts';
|
||||||
|
public const CERTIFICATES = 'certificates';
|
||||||
|
|
||||||
public const TITLES = [
|
public const TITLES = [
|
||||||
self::DOCUMENTS => 'Реестр документов'
|
self::SIMPLE => 'Простой реестр',
|
||||||
|
self::RULESET => 'Реестр сводов правил',
|
||||||
|
self::LABORATORIES => 'Реестр испытательных лабораторий',
|
||||||
|
self::CERTIFIERS => 'Реестр органов по сертификации',
|
||||||
|
self::EXPERTS => 'Реестр экспертов',
|
||||||
|
self::CERTIFICATES => 'Реестр сертификатов соответствия'
|
||||||
|
];
|
||||||
|
|
||||||
|
public const OPTIONS = [
|
||||||
|
self::SIMPLE => [],
|
||||||
|
self::RULESET => ['categories' => true, 'operations' => true, 'states' => true],
|
||||||
|
self::LABORATORIES => ['properties' => 'entry-properties-laboratory', 'states' => true],
|
||||||
|
self::CERTIFIERS => ['properties' => 'entry-properties-certifier', 'states' => true],
|
||||||
|
self::EXPERTS => ['categories' => true, 'properties' => 'entry-properties-expert', 'states' => true],
|
||||||
|
self::CERTIFICATES => ['categories' => true, 'properties' => 'entry-properties-certificate', 'states' => true]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -42,7 +42,7 @@ class AppServiceProvider extends ServiceProvider
|
||||||
public function boot() {
|
public function boot() {
|
||||||
Carbon::setLocale(config('app.locale'));
|
Carbon::setLocale(config('app.locale'));
|
||||||
|
|
||||||
if ($this->app->environment('local')) Mail::alwaysTo('panabonic@yandex.ru');
|
// if ($this->app->environment('local')) Mail::alwaysTo('panabonic@yandex.ru');
|
||||||
|
|
||||||
Relation::enforceMorphMap([
|
Relation::enforceMorphMap([
|
||||||
'asset' => Asset::class,
|
'asset' => Asset::class,
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,14 @@
|
||||||
|
|
||||||
namespace App\Services\Filters;
|
namespace App\Services\Filters;
|
||||||
|
|
||||||
|
use App\Services\Filters\Registries\RegistryFiltersServices;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Date;
|
use Illuminate\Support\Facades\Date;
|
||||||
|
|
||||||
class FiltersService {
|
class FiltersService {
|
||||||
public static array $services = [
|
public static array $services = [
|
||||||
|
RegistryFiltersServices::class
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Filters\Registries;
|
||||||
|
|
||||||
|
use App\Models\Dictionaries\Dictionary;
|
||||||
|
use App\Models\Dictionaries\DictionaryItem;
|
||||||
|
use App\Models\Objects\FieldType;
|
||||||
|
use App\Models\Registries\Entry;
|
||||||
|
use App\Services\Filters\FiltersService;
|
||||||
|
use App\Transformers\Dictionaries\DictionaryItemTransformer;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Spatie\Fractal\Fractal;
|
||||||
|
|
||||||
|
class EntryFilters extends FiltersService {
|
||||||
|
public function get(Collection $filters): array {
|
||||||
|
$groups = [
|
||||||
|
[
|
||||||
|
'name' => 'common',
|
||||||
|
'title' => 'Общие параметры',
|
||||||
|
'fields' => $this->nativeFields($filters)
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$query = Entry::query();
|
||||||
|
$this->applyFilters($query, $filters);
|
||||||
|
return ['groups' => ['data' => $groups], 'total' => $query->count()];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nativeFields(Collection $filters): array {
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'name' => 'listings',
|
||||||
|
'title' => 'Вхождение в перечень ПП',
|
||||||
|
'type' => FieldType::RELATION,
|
||||||
|
'represented' => $this->getListings($filters),
|
||||||
|
'value' => ($val = $filters->get('listings')) ? fractal(DictionaryItem::byUuids($val)->get(), new DictionaryItemTransformer()) : null
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getListings(Collection $filters): Fractal {
|
||||||
|
return fractal(Dictionary::byName('listings')->first()->items, new DictionaryItemTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function applyFilters(Builder $query, Collection $filters) {
|
||||||
|
$this->applyNativeFilters($query, $filters);
|
||||||
|
$this->applyPermissionsFilters($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyNativeFilters(Builder $query, Collection $filters) {
|
||||||
|
$filters->each(function($value, $prop) use($query) {
|
||||||
|
$this->applyNativeFilter($query, $prop, $value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyNativeFilter(Builder $query, $prop, $value) {
|
||||||
|
if ($value) {
|
||||||
|
if ($prop === 'search') $this->applySearchFilter($query, $value, ['name', 'number']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function applyPermissionsFilters(Builder $query) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Filters\Registries;
|
||||||
|
|
||||||
|
class RegistryFiltersServices {
|
||||||
|
public static array $services = [
|
||||||
|
'registryEntries' => EntryFilters::class
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -23,9 +23,7 @@ class FeedbackForms extends FormsService {
|
||||||
|
|
||||||
|
|
||||||
public function store(array $data) {
|
public function store(array $data) {
|
||||||
var_dump($data);
|
event(new FeedbackSender($data['mailto'], $data));
|
||||||
$email = 'sergey@bodin.ru';
|
|
||||||
event(new FeedbackSender($email, $data));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,14 @@ namespace App\Services\Forms\Registries;
|
||||||
|
|
||||||
use App\Models\Asset;
|
use App\Models\Asset;
|
||||||
use App\Models\Objects\FieldType;
|
use App\Models\Objects\FieldType;
|
||||||
|
use App\Models\Objects\ObjectType;
|
||||||
use App\Models\Registries\Category;
|
use App\Models\Registries\Category;
|
||||||
use App\Models\Registries\Entry;
|
use App\Models\Registries\Entry;
|
||||||
use App\Models\Registries\Registry;
|
use App\Models\Registries\Registry;
|
||||||
use App\Services\Forms\FormsService;
|
use App\Services\Forms\FormsService;
|
||||||
use App\Transformers\Assets\AssetTransformer;
|
use App\Transformers\Assets\AssetTransformer;
|
||||||
|
use App\Transformers\Objects\FieldTransformer;
|
||||||
|
use App\Transformers\Objects\ObjectPropertyTransformer;
|
||||||
use App\Transformers\Registries\EntryTransformer;
|
use App\Transformers\Registries\EntryTransformer;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
|
@ -16,40 +19,48 @@ class EntryForms extends FormsService {
|
||||||
public array $formTitles = ['create' => 'Создание записи', 'update' => 'Редактирование записи'];
|
public array $formTitles = ['create' => 'Создание записи', 'update' => 'Редактирование записи'];
|
||||||
|
|
||||||
public function form(?string $id = null, array $data = []): array {
|
public function form(?string $id = null, array $data = []): array {
|
||||||
|
$registry = Registry::byUuid($data['registry'] ?? null)->firstOrFail();
|
||||||
$model = Entry::byUuid($id)->first();
|
$model = Entry::byUuid($id)->first();
|
||||||
$groups = [
|
$groups = [
|
||||||
['name' => 'common', 'fields' => $this->commonGroupFields($model)]
|
['name' => 'common', 'title' => 'Общие сведения', 'fields' => $this->commonGroupFields($model)]
|
||||||
];
|
];
|
||||||
|
if ($registry->parsedType['options']['states'] ?? null) $groups[] = ['name' => 'dates', 'title' => 'Сроки действия', 'fields' => $this->datesGroupFields($model)];
|
||||||
|
if ($objectType = $registry->parsedType['options']['properties'] ?? null) $groups[] = ['name' => 'specific', 'title' => 'Подробности', 'fields' => $this->specificGroupFields($objectType, $model)];
|
||||||
return ['title' => $this->formTitle($model), 'data' => $groups];
|
return ['title' => $this->formTitle($model), 'data' => $groups];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function commonGroupFields(?Entry $model): array {
|
public function commonGroupFields(?Entry $model): array {
|
||||||
$fields = [
|
$fields = [
|
||||||
[
|
|
||||||
'name' => 'number',
|
|
||||||
'title' => 'Номер записи',
|
|
||||||
'type' => FieldType::STRING,
|
|
||||||
'required' => true,
|
|
||||||
'value' => $model->number ?? null
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'title' => 'Название',
|
'title' => 'Наименование записи',
|
||||||
'type' => FieldType::STRING,
|
'type' => FieldType::STRING,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'value' => $model->name ?? null
|
'value' => $model->name ?? null
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'name' => 'number',
|
||||||
|
'title' => 'Номер записи',
|
||||||
|
'type' => FieldType::STRING,
|
||||||
|
'value' => $model->number ?? null
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'name' => 'asset',
|
'name' => 'asset',
|
||||||
'title' => 'Документ',
|
'title' => 'Документ',
|
||||||
'type' => FieldType::DOCUMENT,
|
'type' => FieldType::DOCUMENT,
|
||||||
'required' => true,
|
|
||||||
'value' => ($asset = $model->asset ?? null) ? fractal($asset, new AssetTransformer()) : null
|
'value' => ($asset = $model->asset ?? null) ? fractal($asset, new AssetTransformer()) : null
|
||||||
],
|
]
|
||||||
|
];
|
||||||
|
return ['data' => $fields];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function datesGroupFields(?Entry $model): array {
|
||||||
|
$fields = [
|
||||||
[
|
[
|
||||||
'name' => 'active_since',
|
'name' => 'active_since',
|
||||||
'title' => 'Дата начала действия',
|
'title' => 'Дата начала действия',
|
||||||
'type' => FieldType::DATE,
|
'type' => FieldType::DATE,
|
||||||
|
'required' => true,
|
||||||
'value' => ($v = $model->active_since ?? null) ? $v->toIso8601String() : null
|
'value' => ($v = $model->active_since ?? null) ? $v->toIso8601String() : null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|
@ -63,20 +74,30 @@ class EntryForms extends FormsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function specificGroupFields(string $objectType, ?Entry $model): array {
|
||||||
|
$object = $model->properties ?? null;
|
||||||
|
return $object ? fractal($object->groups->first()->fields, new ObjectPropertyTransformer($object))->toArray() :
|
||||||
|
fractal(ObjectType::byName($objectType)->first()->groups()->first()->fields, new FieldTransformer())->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function store(array $data): ?JsonResponse {
|
public function store(array $data): ?JsonResponse {
|
||||||
$registry = Registry::byUuid($data['registry'] ?? null)->firstOrFail();
|
$registry = Registry::byUuid($data['registry'] ?? null)->firstOrFail();
|
||||||
$category = Category::byUuid($data['category'] ?? null)->first();
|
$category = Category::byUuid($data['category'] ?? null)->first();
|
||||||
$data['asset_id'] = ($asset = Asset::byUuid($data['asset'])->first()) ? $asset->id : null;
|
$data['asset_id'] = ($asset = Asset::byUuid($data['asset'] ?? null)->first()) ? $asset->id : null;
|
||||||
$data['category_id'] = $category->id ?? 0;
|
$data['category_id'] = $category->id ?? 0;
|
||||||
$model = $registry->entries()->create($data);
|
$model = $registry->entries()->create($data);
|
||||||
|
if ($object = $model->properties ?? null) $object->setValues($data);
|
||||||
return fractal($model, new EntryTransformer())->respond();
|
return fractal($model, new EntryTransformer())->respond();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(string $id, array $data): ?JsonResponse {
|
public function update(string $id, array $data): ?JsonResponse {
|
||||||
$model = Entry::byUuid($id)->firstOrFail();
|
$model = Entry::byUuid($id)->firstOrFail();
|
||||||
$data['asset_id'] = ($asset = Asset::byUuid($data['asset'])->first()) ? $asset->id : null;
|
$data['asset_id'] = ($asset = Asset::byUuid($data['asset'] ?? null)->first()) ? $asset->id : null;
|
||||||
$model->update($data);
|
$model->update($data);
|
||||||
|
if ($object = $model->properties ?? null) $object->setValues($data);
|
||||||
return fractal($model->fresh(), new EntryTransformer())->respond();
|
return fractal($model->fresh(), new EntryTransformer())->respond();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,11 @@ trait HasObjectsTrait {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getObject($typeName): ?Model {
|
public function getObject($typeName, $group = null): ?Model {
|
||||||
return ($type = ObjectType::byName($typeName)->first()) ? $this->objects()->firstOrCreate(['type_id' => $type->id]) : null;
|
if ($type = ObjectType::byName($typeName)->first()) {
|
||||||
|
return $this->objectsByGroup($group ?? 'default')->where(['type_id' => $type->id])->first() ?? $this->createObject($typeName, null, $group ?? 'default');
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createObject($typeName, $ord = null, $group = null): ?Model {
|
public function createObject($typeName, $ord = null, $group = null): ?Model {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class EntryTransformer extends TransformerAbstract {
|
||||||
];
|
];
|
||||||
|
|
||||||
protected array $availableIncludes = [
|
protected array $availableIncludes = [
|
||||||
'registry', 'category', 'asset', 'operations'
|
'registry', 'category', 'asset', 'operations', 'properties'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function transform(Entry $model): array {
|
public function transform(Entry $model): array {
|
||||||
|
|
@ -25,6 +25,7 @@ class EntryTransformer extends TransformerAbstract {
|
||||||
'id' => $model->uuid,
|
'id' => $model->uuid,
|
||||||
'number' => $model->number,
|
'number' => $model->number,
|
||||||
'name' => $model->name,
|
'name' => $model->name,
|
||||||
|
'state' => $model->state,
|
||||||
'active_since' => $model->active_since ? $model->active_since->toIso8601String() : null,
|
'active_since' => $model->active_since ? $model->active_since->toIso8601String() : null,
|
||||||
'active_till' => $model->active_till ? $model->active_till->toIso8601String() : null,
|
'active_till' => $model->active_till ? $model->active_till->toIso8601String() : null,
|
||||||
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : null,
|
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : null,
|
||||||
|
|
@ -48,6 +49,10 @@ class EntryTransformer extends TransformerAbstract {
|
||||||
return $this->collection($model->operations, new ObjectTransformer());
|
return $this->collection($model->operations, new ObjectTransformer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function includeProperties(Entry $model): ?Item {
|
||||||
|
return $model->properties ? $this->item($model->properties, new ObjectTransformer()) : null;
|
||||||
|
}
|
||||||
|
|
||||||
public function includePermissions(Entry $model): Primitive {
|
public function includePermissions(Entry $model): Primitive {
|
||||||
return $this->primitive((new PermissionsService($model))->get());
|
return $this->primitive((new PermissionsService($model))->get());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ class CreateRegistriesTable extends Migration
|
||||||
$table->char('uuid', 36)->index()->unique();
|
$table->char('uuid', 36)->index()->unique();
|
||||||
$table->integer('page_id')->index()->nullable();
|
$table->integer('page_id')->index()->nullable();
|
||||||
$table->string('type')->index()->nullable();
|
$table->string('type')->index()->nullable();
|
||||||
$table->string('name')->index()->nullable();
|
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,9 @@ class CreateRegistryEntriesTable extends Migration
|
||||||
$table->string('name')->index()->nullable();
|
$table->string('name')->index()->nullable();
|
||||||
$table->date('active_since')->index()->nullable();
|
$table->date('active_since')->index()->nullable();
|
||||||
$table->date('active_till')->index()->nullable();
|
$table->date('active_till')->index()->nullable();
|
||||||
|
$table->date('suspended_since')->index()->nullable();
|
||||||
|
$table->date('suspended_till')->index()->nullable();
|
||||||
|
$table->date('cancelled_at')->index()->nullable();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,27 @@ class FieldsTableSeeder extends Seeder {
|
||||||
'required' => true,
|
'required' => true,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'laboratory-name' => [
|
||||||
|
'title' => 'Наименование лаборатории',
|
||||||
|
'type' => FieldType::STRING,
|
||||||
|
'required' => true
|
||||||
|
],
|
||||||
|
'certifier-name' => [
|
||||||
|
'title' => 'Наименование органа по сертификации',
|
||||||
|
'type' => FieldType::STRING,
|
||||||
|
'required' => true
|
||||||
|
],
|
||||||
|
'expert-name' => [
|
||||||
|
'title' => 'ФИО эксперта',
|
||||||
|
'type' => FieldType::STRING,
|
||||||
|
'required' => true
|
||||||
|
],
|
||||||
|
'certificate-number' => [
|
||||||
|
'title' => 'Номер сертификата',
|
||||||
|
'type' => FieldType::STRING,
|
||||||
|
'required' => true
|
||||||
|
],
|
||||||
|
|
||||||
'operation-type' => [
|
'operation-type' => [
|
||||||
'title' => 'Вид работы',
|
'title' => 'Вид работы',
|
||||||
'type' => FieldType::RELATION,
|
'type' => FieldType::RELATION,
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,28 @@ class ObjectTypeFieldsTableSeeder extends Seeder {
|
||||||
'fields' => ['feedback-email', 'feedback-name', 'feedback-type', 'feedback-message']
|
'fields' => ['feedback-email', 'feedback-name', 'feedback-type', 'feedback-message']
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'entry-properties-laboratory' => [
|
||||||
|
'common' => [
|
||||||
|
'fields' => ['laboratory-name']
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'entry-properties-certifier' => [
|
||||||
|
'common' => [
|
||||||
|
'fields' => ['certifier-name']
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'entry-properties-expert' => [
|
||||||
|
'common' => [
|
||||||
|
'fields' => ['expert-name']
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'entry-properties-certificate' => [
|
||||||
|
'common' => [
|
||||||
|
'fields' => ['certificate-number']
|
||||||
|
]
|
||||||
|
],
|
||||||
|
|
||||||
'entry-operation' => [
|
'entry-operation' => [
|
||||||
'common' => [
|
'common' => [
|
||||||
'fields' => ['operation-type', 'order-name', 'order-date', 'order-document', 'listings', 'active-since', 'active-till', 'developer']
|
'fields' => ['operation-type', 'order-name', 'order-date', 'order-document', 'listings', 'active-since', 'active-till', 'developer']
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,24 @@ class ObjectTypesTableSeeder extends Seeder {
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'registry-entry-properties' => [
|
||||||
|
'title' => 'Специфические свойства записи реестра',
|
||||||
|
'children' => [
|
||||||
|
'entry-properties-laboratory' => [
|
||||||
|
'title' => 'Испытательная лаборатория'
|
||||||
|
],
|
||||||
|
'entry-properties-certifier' => [
|
||||||
|
'title' => 'Орган по сертификации'
|
||||||
|
],
|
||||||
|
'entry-properties-expert' => [
|
||||||
|
'title' => 'Эксперт'
|
||||||
|
],
|
||||||
|
'entry-properties-certificate' => [
|
||||||
|
'title' => 'Сертификат соответствия'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
|
||||||
'entry-operation' => [
|
'entry-operation' => [
|
||||||
'title' => 'Действие с записью в реестре'
|
'title' => 'Действие с записью в реестре'
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ namespace Database\Seeders\Pages;
|
||||||
use App\Models\Pages\Page;
|
use App\Models\Pages\Page;
|
||||||
use App\Models\Pages\PageSubType;
|
use App\Models\Pages\PageSubType;
|
||||||
use App\Models\Pages\PageType;
|
use App\Models\Pages\PageType;
|
||||||
|
use App\Models\Registries\RegistryType;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
|
@ -16,11 +17,11 @@ class PagesTableSeeder extends Seeder
|
||||||
'Руководство' => [],
|
'Руководство' => [],
|
||||||
'Документы' => [
|
'Документы' => [
|
||||||
'children' => [
|
'children' => [
|
||||||
'Документы об учреждении' => [],
|
'Документы об учреждении' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE],
|
||||||
'Закупки' => [],
|
'Закупки' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE],
|
||||||
'Бухгалтерская отчетность' => [],
|
'Бухгалтерская отчетность' => [],
|
||||||
'Государственное задание' => [],
|
'Государственное задание' => [],
|
||||||
'Нормативные правовые акты' => [],
|
'Нормативные правовые акты' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE],
|
||||||
'Антимонопольное законодательство' => [],
|
'Антимонопольное законодательство' => [],
|
||||||
'Специальная оценка условий труда' => []
|
'Специальная оценка условий труда' => []
|
||||||
]
|
]
|
||||||
|
|
@ -30,13 +31,13 @@ class PagesTableSeeder extends Seeder
|
||||||
'children' => [
|
'children' => [
|
||||||
'Структура' => [],
|
'Структура' => [],
|
||||||
'Документы' => [],
|
'Документы' => [],
|
||||||
'Решения' => []
|
'Решения' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'Закупки' => [],
|
'Закупки' => [],
|
||||||
'Противодействие коррупции' => [
|
'Противодействие коррупции' => [
|
||||||
'children' => [
|
'children' => [
|
||||||
'ФЗ, указы, постановления' => [],
|
'ФЗ, указы, постановления' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE],
|
||||||
'Ведомственные нормативные правовые акты' => [],
|
'Ведомственные нормативные правовые акты' => [],
|
||||||
'Внутренние нормативные документы' => [],
|
'Внутренние нормативные документы' => [],
|
||||||
'Антикоррупционная экспертиза' => [],
|
'Антикоррупционная экспертиза' => [],
|
||||||
|
|
@ -54,7 +55,7 @@ class PagesTableSeeder extends Seeder
|
||||||
'children' => [
|
'children' => [
|
||||||
'Нормирование и стандартизация' => [
|
'Нормирование и стандартизация' => [
|
||||||
'children' => [
|
'children' => [
|
||||||
'Реестр сводов правил' => [],
|
'Реестр сводов правил' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::RULESET],
|
||||||
'Разработка сводов правил' => [],
|
'Разработка сводов правил' => [],
|
||||||
'Прикладные исследования' => [],
|
'Прикладные исследования' => [],
|
||||||
'Реестр нормативно-технической документации' => [],
|
'Реестр нормативно-технической документации' => [],
|
||||||
|
|
@ -63,7 +64,7 @@ class PagesTableSeeder extends Seeder
|
||||||
],
|
],
|
||||||
'Оценка пригодности' => [
|
'Оценка пригодности' => [
|
||||||
'children' => [
|
'children' => [
|
||||||
'Реестр технических свидетельств' => [],
|
'Реестр технических свидетельств' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE],
|
||||||
'Заявка на оформление' => [],
|
'Заявка на оформление' => [],
|
||||||
'Предварительная заявка' => [],
|
'Предварительная заявка' => [],
|
||||||
]
|
]
|
||||||
|
|
@ -74,7 +75,7 @@ class PagesTableSeeder extends Seeder
|
||||||
'Секретариат' => [],
|
'Секретариат' => [],
|
||||||
'Структура' => [],
|
'Структура' => [],
|
||||||
'Состав' => [],
|
'Состав' => [],
|
||||||
'Документы' => [],
|
'Документы' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE],
|
||||||
'АИС ТК 465 «Строительство»' => [],
|
'АИС ТК 465 «Строительство»' => [],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
@ -97,7 +98,10 @@ class PagesTableSeeder extends Seeder
|
||||||
'Основополагающие документы' => [],
|
'Основополагающие документы' => [],
|
||||||
'Решения ЦОС' => [],
|
'Решения ЦОС' => [],
|
||||||
'Руководящие документы' => [],
|
'Руководящие документы' => [],
|
||||||
'Реестры' => [],
|
'Реестр органов по сертификации' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CERTIFIERS],
|
||||||
|
'Реестр испытательных лабораторий' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::LABORATORIES],
|
||||||
|
'Реестр экспертов' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::EXPERTS],
|
||||||
|
'Реестр сертификатов соответствия' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CERTIFICATES],
|
||||||
'Бланки документов' => [],
|
'Бланки документов' => [],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
@ -151,8 +155,7 @@ class PagesTableSeeder extends Seeder
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
public function run()
|
public function run() {
|
||||||
{
|
|
||||||
$ord = 0;
|
$ord = 0;
|
||||||
collect($this->pages)->each(function ($data, $name) use (&$ord) {
|
collect($this->pages)->each(function ($data, $name) use (&$ord) {
|
||||||
$data['ord'] = $ord++;
|
$data['ord'] = $ord++;
|
||||||
|
|
@ -160,16 +163,12 @@ class PagesTableSeeder extends Seeder
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function importPage($name, $data, ?Page $parent = null)
|
public function importPage($name, $data, ?Page $parent = null) {
|
||||||
{
|
|
||||||
$slug = Str::slug(Str::transliterate($name));
|
$slug = Str::slug(Str::transliterate($name));
|
||||||
|
$data += ['type' => $data['type'] ?? PageType::CONTENT, 'name' => $name];
|
||||||
$page = Page::firstOrCreate(['parent_id' => $parent->id ?? 0, 'slug' => $slug]);
|
$page = Page::firstOrCreate(['parent_id' => $parent->id ?? 0, 'slug' => $slug]);
|
||||||
$page->update([
|
if ($v = collect($data)->except('children', 'registry_type')->all()) $page->update($v);
|
||||||
'name' => $name,
|
if ($page->type === PageType::REGISTRY) $page->registry->update(['type' => $data['registry_type'] ?? RegistryType::SIMPLE]);
|
||||||
'type' => $data['type'] ?? PageType::CONTENT,
|
|
||||||
'sub_type' => $data['sub_type'] ?? null
|
|
||||||
]);
|
|
||||||
if ($v = collect($data)->except('children')->all()) $page->update($v);
|
|
||||||
$ord = 0;
|
$ord = 0;
|
||||||
collect($data['children'] ?? [])->each(function ($data, $name) use ($page, &$ord) {
|
collect($data['children'] ?? [])->each(function ($data, $name) use ($page, &$ord) {
|
||||||
$data['ord'] = $ord++;
|
$data['ord'] = $ord++;
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<p>Поступило обращение с сайта.</p>
|
<p>Поступило обращение с сайта.</p>
|
||||||
<p class="mb-10">Email отправителя: {{$data['feedback-email']}}</p>
|
<p class="mb-10">Email отправителя: {{$data['feedback-email'] ?? '-'}}</p>
|
||||||
<p class="mb-10">Имя отправителя: {{$data['feedback-name']}}</p>
|
<p class="mb-10">Имя отправителя: {{$data['feedback-name'] ?? '-'}}</p>
|
||||||
<p class="mb-10">Тема сообщения: {{$data['feedback-type']}}</p>
|
<p class="mb-10">Тема сообщения: {{$data['feedback-type'] ?? '-'}}</p>
|
||||||
<p class="mb-10">Сообщение: {{$data['feedback-message']}}</p>
|
<p class="mb-10">Сообщение: {!! nl2br($data['feedback-message'] ?? '-') !!}</p>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
@ -23,6 +23,14 @@ Route::get('publications', 'Api\Publications\PublicationsController@index');
|
||||||
Route::get('publications/find', 'Api\Publications\PublicationsController@find');
|
Route::get('publications/find', 'Api\Publications\PublicationsController@find');
|
||||||
Route::get('publications/{id}', 'Api\Publications\PublicationsController@show');
|
Route::get('publications/{id}', 'Api\Publications\PublicationsController@show');
|
||||||
|
|
||||||
|
Route::apiResource('object-types', 'Api\Objects\ObjectTypesController');
|
||||||
|
|
||||||
|
Route::group(['prefix' => 'forms'], function() {
|
||||||
|
Route::get('/{target}/{type?}/{id?}', 'Api\Forms\FormsController@get');
|
||||||
|
Route::post('/{target}/{type?}/{id?}', 'Api\Forms\FormsController@save');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
Route::group(['prefix' => 'registries'], function() {
|
Route::group(['prefix' => 'registries'], function() {
|
||||||
Route::get('/categories', 'Api\Registries\CategoriesController@index');
|
Route::get('/categories', 'Api\Registries\CategoriesController@index');
|
||||||
Route::get('/categories/{id}', 'Api\Registries\CategoriesController@show');
|
Route::get('/categories/{id}', 'Api\Registries\CategoriesController@show');
|
||||||
|
|
@ -39,6 +47,8 @@ Route::group(['prefix' => 'registries'], function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::get('filters/{type}', 'Api\Forms\FormsController@filters');
|
||||||
|
|
||||||
Route::group(['middleware' => ['auth:api']], function() {
|
Route::group(['middleware' => ['auth:api']], function() {
|
||||||
Route::apiResource('users', 'Api\Users\UsersController');
|
Route::apiResource('users', 'Api\Users\UsersController');
|
||||||
Route::apiResource('roles', 'Api\Users\RolesController');
|
Route::apiResource('roles', 'Api\Users\RolesController');
|
||||||
|
|
@ -63,13 +73,6 @@ Route::group(['middleware' => ['auth:api']], function() {
|
||||||
|
|
||||||
Route::put('objects/move/{id}', 'Api\Objects\ObjectsController@move');
|
Route::put('objects/move/{id}', 'Api\Objects\ObjectsController@move');
|
||||||
Route::apiResource('objects', 'Api\Objects\ObjectsController');
|
Route::apiResource('objects', 'Api\Objects\ObjectsController');
|
||||||
Route::apiResource('object-types', 'Api\Objects\ObjectTypesController');
|
|
||||||
|
|
||||||
Route::group(['prefix' => 'forms'], function() {
|
|
||||||
Route::get('/{target}/{type?}/{id?}', 'Api\Forms\FormsController@get');
|
|
||||||
Route::post('/{target}/{type?}/{id?}', 'Api\Forms\FormsController@save');
|
|
||||||
});
|
|
||||||
Route::get('filters/{type}', 'Api\Forms\FormsController@filters');
|
|
||||||
|
|
||||||
Route::get('dadata/{inn}', 'Api\Companies\CompaniesController@getDataByInn');
|
Route::get('dadata/{inn}', 'Api\Companies\CompaniesController@getDataByInn');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue