conflict
commit
74513b0176
|
|
@ -7,6 +7,7 @@ use App\Models\Pages\Page;
|
||||||
use App\Models\Publications\Publication;
|
use App\Models\Publications\Publication;
|
||||||
use App\Models\Publications\PublicationType;
|
use App\Models\Publications\PublicationType;
|
||||||
use App\Transformers\Publications\PublicationTransformer;
|
use App\Transformers\Publications\PublicationTransformer;
|
||||||
|
use App\Transformers\Registries\RegistryTransformer;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
@ -35,8 +36,8 @@ class PublicationsController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show(Request $request, $id): JsonResponse {
|
public function show(Request $request, $id): JsonResponse {
|
||||||
$model = $this->model->bySlug($id)->firstOrFail();
|
$model = $this->model->ByUuid($id)->firstOrFail();
|
||||||
return fractal($model, new PublicationTransformer())->respond();
|
return fractal($model, new RegistryTransformer())->respond();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\Registries;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Registries\Category;
|
||||||
|
use App\Models\Registries\Registry;
|
||||||
|
use App\Transformers\Registries\CategoryTransformer;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class CategoriesController extends Controller {
|
||||||
|
protected Category $model;
|
||||||
|
|
||||||
|
public function __construct(Category $model) {
|
||||||
|
$this->model = $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request): JsonResponse {
|
||||||
|
$registry = Registry::byUuid($request->get('registry'))->first();
|
||||||
|
$parent = Category::byUuid($request->get('parent'))->first();
|
||||||
|
$query = $this->model->query()->where(['registry_id' => $registry->id ?? 0, 'parent_id' => $parent->id ?? 0]);
|
||||||
|
$paginator = $query->paginate(config('app.pagination_limit'));
|
||||||
|
return fractal($paginator, new CategoryTransformer())->respond();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Request $request, $id): JsonResponse {
|
||||||
|
$model = $this->model->byUuid($id)->firstOrFail();
|
||||||
|
return fractal($model, new CategoryTransformer())->respond();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function store(Request $request): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function update(Request $request, $uuid): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Request $request, $uuid): JsonResponse {
|
||||||
|
$model = $this->model->byUuid($uuid)->firstOrFail();
|
||||||
|
$model->delete();
|
||||||
|
return response()->json(null, 204);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\Registries;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Registries\Category;
|
||||||
|
use App\Models\Registries\Entry;
|
||||||
|
use App\Models\Registries\Registry;
|
||||||
|
use App\Transformers\Registries\EntryTransformer;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class EntriesController extends Controller {
|
||||||
|
protected Entry $model;
|
||||||
|
|
||||||
|
public function __construct(Entry $model) {
|
||||||
|
$this->model = $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request): JsonResponse {
|
||||||
|
$registry = Registry::byUuid($request->get('registry'))->first();
|
||||||
|
$category = Category::byUuid($request->get('category'))->first();
|
||||||
|
$query = $this->model->query()->where(['registry_id' => $registry->id ?? 0, 'category_id' => $category->id ?? 0]);
|
||||||
|
$paginator = $query->paginate(config('app.pagination_limit'));
|
||||||
|
return fractal($paginator, new EntryTransformer())->respond();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Request $request, $id): JsonResponse {
|
||||||
|
$model = $this->model->byUuid($id)->firstOrFail();
|
||||||
|
return fractal($model, new EntryTransformer())->respond();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function store(Request $request): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function update(Request $request, $uuid): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Request $request, $uuid): JsonResponse {
|
||||||
|
$model = $this->model->byUuid($uuid)->firstOrFail();
|
||||||
|
$model->delete();
|
||||||
|
return response()->json(null, 204);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\Registries;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Objects\NirObject;
|
||||||
|
use App\Models\Registries\Entry;
|
||||||
|
use App\Transformers\Objects\ObjectTransformer;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class OperationsController extends Controller {
|
||||||
|
protected NirObject $model;
|
||||||
|
|
||||||
|
public function __construct(NirObject $model) {
|
||||||
|
$this->model = $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request): JsonResponse {
|
||||||
|
$query = ($entry = Entry::byUuid($request->get('entry'))->first()) ? $entry->operations() : $this->model->query();
|
||||||
|
$paginator = $query->paginate(config('app.pagination_limit'));
|
||||||
|
return fractal($paginator, new ObjectTransformer())->respond();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Request $request, $id): JsonResponse {
|
||||||
|
$model = $this->model->byUuid($id)->firstOrFail();
|
||||||
|
return fractal($model, new ObjectTransformer())->respond();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function store(Request $request): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function update(Request $request, $uuid): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Request $request, $uuid): JsonResponse {
|
||||||
|
$model = $this->model->byUuid($uuid)->firstOrFail();
|
||||||
|
$model->delete();
|
||||||
|
return response()->json(null, 204);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\Registries;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Pages\Page;
|
||||||
|
use App\Models\Registries\Registry;
|
||||||
|
use App\Transformers\Publications\PublicationTransformer;
|
||||||
|
use App\Transformers\Registries\RegistryTransformer;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class RegistriesController extends Controller {
|
||||||
|
protected Registry $model;
|
||||||
|
|
||||||
|
public function __construct(Registry $model) {
|
||||||
|
$this->model = $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request): JsonResponse {
|
||||||
|
$query = $this->model->query();
|
||||||
|
if ($page = Page::byUuid($request->get('page'))->first()) $query->where(['page_id' => $page->id]);
|
||||||
|
$paginator = $query->paginate(config('app.pagination_limit'));
|
||||||
|
return fractal($paginator, new RegistryTransformer())->respond();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Request $request, $id): JsonResponse {
|
||||||
|
$model = $this->model->byUuid($id)->firstOrFail();
|
||||||
|
return fractal($model, new PublicationTransformer())->respond();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function store(Request $request): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function update(Request $request, $uuid): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Request $request, $uuid): JsonResponse {
|
||||||
|
$model = $this->model->byUuid($uuid)->firstOrFail();
|
||||||
|
$model->delete();
|
||||||
|
return response()->json(null, 204);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Database\Query\JoinClause;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
|
@ -175,6 +176,16 @@ class Field extends Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function applyOrder(Builder $query, $dir) {
|
||||||
|
if ($table = FieldType::TABLES[$this->type] ?? null) {
|
||||||
|
$query->leftJoin("{$table} as {$this->name}", function(JoinClause $join) use($table) {
|
||||||
|
$join->on('objects.id', '=', "{$this->name}.object_id");
|
||||||
|
})->where(["{$this->name}.field_id" => $this->id])->orderBy("{$this->name}.value", $dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function fakeValue($objectId) {
|
public function fakeValue($objectId) {
|
||||||
$faker = new Generator();
|
$faker = new Generator();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Models\Objects;
|
namespace App\Models\Objects;
|
||||||
|
|
||||||
use App\Models\Catalog\Specification;
|
|
||||||
use App\Models\Objects\Values\BooleanValue;
|
use App\Models\Objects\Values\BooleanValue;
|
||||||
use App\Models\Objects\Values\DateValue;
|
use App\Models\Objects\Values\DateValue;
|
||||||
use App\Models\Objects\Values\DocumentValue;
|
use App\Models\Objects\Values\DocumentValue;
|
||||||
|
|
@ -12,7 +11,6 @@ use App\Models\Objects\Values\IntegerValue;
|
||||||
use App\Models\Objects\Values\RelationValue;
|
use App\Models\Objects\Values\RelationValue;
|
||||||
use App\Models\Objects\Values\StringValue;
|
use App\Models\Objects\Values\StringValue;
|
||||||
use App\Models\Objects\Values\TextValue;
|
use App\Models\Objects\Values\TextValue;
|
||||||
use App\Models\Polls\PollInvitation;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Support\UuidScopeTrait;
|
use App\Support\UuidScopeTrait;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
@ -103,6 +101,13 @@ class NirObject extends Model {
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeApplyOrders(Builder $query, $orders): Builder {
|
||||||
|
collect($orders)->each(function($dir, $prop) use($query) {
|
||||||
|
if ($field = Field::byUuidOrName($prop)->first()) $field->applyOrder($query, $dir);
|
||||||
|
});
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getValuesAttribute(): array {
|
public function getValuesAttribute(): array {
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Models\Objects\Values;
|
namespace App\Models\Objects\Values;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
class DateValue extends Value {
|
class DateValue extends Value {
|
||||||
protected $table = 'field_date_values';
|
protected $table = 'field_date_values';
|
||||||
|
|
@ -16,6 +16,7 @@ class DateValue extends Value {
|
||||||
return $this->value ? $this->value->toIso8601String() : null;
|
return $this->value ? $this->value->toIso8601String() : null;
|
||||||
}
|
}
|
||||||
public function set($value): bool {
|
public function set($value): bool {
|
||||||
|
$value = ($value instanceof Carbon) ? $value : ($value ? Carbon::create($value) : null);
|
||||||
return parent::set($value);
|
return parent::set($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Models\Pages;
|
namespace App\Models\Pages;
|
||||||
|
|
||||||
use App\Models\Publications\Publication;
|
use App\Models\Publications\Publication;
|
||||||
|
use App\Models\Registries\Registry;
|
||||||
use App\Support\HasObjectsTrait;
|
use App\Support\HasObjectsTrait;
|
||||||
use App\Support\RelationValuesTrait;
|
use App\Support\RelationValuesTrait;
|
||||||
use App\Support\UuidScopeTrait;
|
use App\Support\UuidScopeTrait;
|
||||||
|
|
@ -56,6 +57,10 @@ class Page extends Model {
|
||||||
return $this->hasMany(Publication::class);
|
return $this->hasMany(Publication::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function registries(): HasMany {
|
||||||
|
return $this->hasMany(Registry::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function scopeBySlug($query, $slug) {
|
public function scopeBySlug($query, $slug) {
|
||||||
$query->where(['slug' => $slug]);
|
$query->where(['slug' => $slug]);
|
||||||
|
|
@ -83,6 +88,10 @@ class Page extends Model {
|
||||||
return ['name' => $this->type, 'title' => PageType::TITLES[$this->type] ?? null];
|
return ['name' => $this->type, 'title' => PageType::TITLES[$this->type] ?? null];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRegistryAttribute(): Model {
|
||||||
|
return $this->registries()->firstOrCreate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function addSection($typeName, $ord = null): ?Model {
|
public function addSection($typeName, $ord = null): ?Model {
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,17 @@
|
||||||
|
|
||||||
namespace App\Models\Registries;
|
namespace App\Models\Registries;
|
||||||
|
|
||||||
use App\Support\HasObjectsTrait;
|
|
||||||
use App\Support\RelationValuesTrait;
|
use App\Support\RelationValuesTrait;
|
||||||
use App\Support\UuidScopeTrait;
|
use App\Support\UuidScopeTrait;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
class RegistryEntry extends Model {
|
class Category extends Model {
|
||||||
use UuidScopeTrait, SoftDeletes, HasObjectsTrait, RelationValuesTrait;
|
use UuidScopeTrait, SoftDeletes, RelationValuesTrait;
|
||||||
|
|
||||||
|
protected $table = 'registry_categories';
|
||||||
|
|
||||||
protected $dates = [
|
protected $dates = [
|
||||||
];
|
];
|
||||||
|
|
@ -18,6 +20,7 @@ class RegistryEntry extends Model {
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'uuid',
|
'uuid',
|
||||||
'registry_id',
|
'registry_id',
|
||||||
|
'parent_id',
|
||||||
'name'
|
'name'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -30,6 +33,18 @@ class RegistryEntry extends Model {
|
||||||
return $this->belongsTo(Registry::class);
|
return $this->belongsTo(Registry::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function parent(): BelongsTo {
|
||||||
|
return $this->belongsTo(Category::class, 'parent_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function children(): HasMany {
|
||||||
|
return $this->hasMany(Category::class, 'parent_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function entries(): HasMany {
|
||||||
|
return $this->hasMany(Entry::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Registries;
|
||||||
|
|
||||||
|
use App\Models\Asset;
|
||||||
|
use App\Support\HasObjectsTrait;
|
||||||
|
use App\Support\RelationValuesTrait;
|
||||||
|
use App\Support\UuidScopeTrait;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class Entry extends Model {
|
||||||
|
use UuidScopeTrait, SoftDeletes, HasObjectsTrait, RelationValuesTrait;
|
||||||
|
|
||||||
|
protected $table = 'registry_entries';
|
||||||
|
|
||||||
|
protected $dates = [
|
||||||
|
'active_since',
|
||||||
|
'active_till'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'uuid',
|
||||||
|
'registry_id',
|
||||||
|
'category_id',
|
||||||
|
'asset_id',
|
||||||
|
'number',
|
||||||
|
'name',
|
||||||
|
'active_since',
|
||||||
|
'active_till'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'id'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
public function registry(): BelongsTo {
|
||||||
|
return $this->belongsTo(Registry::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function category(): BelongsTo {
|
||||||
|
return $this->belongsTo(Category::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asset(): BelongsTo {
|
||||||
|
return $this->belongsTo(Asset::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function operations(): MorphToMany {
|
||||||
|
return $this->objects()->reorder()->applyOrders(['order-date' => 'desc']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -3,15 +3,15 @@
|
||||||
namespace App\Models\Registries;
|
namespace App\Models\Registries;
|
||||||
|
|
||||||
use App\Models\Pages\Page;
|
use App\Models\Pages\Page;
|
||||||
use App\Support\HasObjectsTrait;
|
|
||||||
use App\Support\RelationValuesTrait;
|
use App\Support\RelationValuesTrait;
|
||||||
use App\Support\UuidScopeTrait;
|
use App\Support\UuidScopeTrait;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
class Registry extends Model {
|
class Registry extends Model {
|
||||||
use UuidScopeTrait, SoftDeletes, HasObjectsTrait, RelationValuesTrait;
|
use UuidScopeTrait, SoftDeletes, RelationValuesTrait;
|
||||||
|
|
||||||
protected $dates = [
|
protected $dates = [
|
||||||
];
|
];
|
||||||
|
|
@ -32,6 +32,18 @@ class Registry extends Model {
|
||||||
return $this->belongsTo(Page::class);
|
return $this->belongsTo(Page::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function categories(): HasMany {
|
||||||
|
return $this->hasMany(Category::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rootCategories(): HasMany {
|
||||||
|
return $this->categories()->where(['parent_id' => 0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function entries(): HasMany {
|
||||||
|
return $this->hasMany(Entry::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getParsedTypeAttribute(): array {
|
public function getParsedTypeAttribute(): array {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ use App\Models\Objects\ObjectType;
|
||||||
use App\Models\Pages\Page;
|
use App\Models\Pages\Page;
|
||||||
use App\Models\Permission;
|
use App\Models\Permission;
|
||||||
use App\Models\Publications\Publication;
|
use App\Models\Publications\Publication;
|
||||||
|
use App\Models\Registries\Category;
|
||||||
|
use App\Models\Registries\Entry;
|
||||||
|
use App\Models\Registries\Registry;
|
||||||
use App\Models\Role;
|
use App\Models\Role;
|
||||||
use App\Models\SocialProvider;
|
use App\Models\SocialProvider;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
@ -58,6 +61,10 @@ class AppServiceProvider extends ServiceProvider
|
||||||
|
|
||||||
'page' => Page::class,
|
'page' => Page::class,
|
||||||
'publication' => Publication::class,
|
'publication' => Publication::class,
|
||||||
|
|
||||||
|
'registry' => Registry::class,
|
||||||
|
'registry-category' => Category::class,
|
||||||
|
'registry-entry' => Entry::class
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ namespace App\Services\Forms;
|
||||||
|
|
||||||
use App\Services\Forms\Pages\PageFormsServices;
|
use App\Services\Forms\Pages\PageFormsServices;
|
||||||
use App\Services\Forms\Publications\PublicationFormsServices;
|
use App\Services\Forms\Publications\PublicationFormsServices;
|
||||||
|
use App\Services\Forms\Registries\RegistryFormsServices;
|
||||||
use App\Services\Forms\Users\UserFormsServices;
|
use App\Services\Forms\Users\UserFormsServices;
|
||||||
|
|
||||||
class FormsService {
|
class FormsService {
|
||||||
|
|
@ -12,6 +13,7 @@ class FormsService {
|
||||||
public static array $services = [
|
public static array $services = [
|
||||||
PageFormsServices::class,
|
PageFormsServices::class,
|
||||||
PublicationFormsServices::class,
|
PublicationFormsServices::class,
|
||||||
|
RegistryFormsServices::class,
|
||||||
UserFormsServices::class
|
UserFormsServices::class
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Forms\Registries;
|
||||||
|
|
||||||
|
use App\Models\Objects\FieldType;
|
||||||
|
use App\Models\Registries\Category;
|
||||||
|
use App\Models\Registries\Registry;
|
||||||
|
use App\Services\Forms\FormsService;
|
||||||
|
use App\Transformers\Registries\CategoryTransformer;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
class CategoryForms extends FormsService {
|
||||||
|
public array $formTitles = ['create' => 'Создание категории', 'update' => 'Редактирование категории'];
|
||||||
|
|
||||||
|
public function form(?string $id = null, array $data = []): array {
|
||||||
|
$model = Category::byUuid($id)->first();
|
||||||
|
$groups = [
|
||||||
|
['name' => 'common', 'fields' => $this->commonGroupFields($model)]
|
||||||
|
];
|
||||||
|
return ['title' => $this->formTitle($model), 'data' => $groups];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function commonGroupFields(?Category $model): array {
|
||||||
|
$fields = [
|
||||||
|
[
|
||||||
|
'name' => 'name',
|
||||||
|
'title' => 'Название категории',
|
||||||
|
'type' => FieldType::STRING,
|
||||||
|
'required' => true,
|
||||||
|
'value' => $model->name ?? null
|
||||||
|
]
|
||||||
|
];
|
||||||
|
return ['data' => $fields];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function store(array $data): ?JsonResponse {
|
||||||
|
$registry = Registry::byUuid($data['registry'] ?? null)->firstOrFail();
|
||||||
|
$parent = Category::byUuid($data['parent'] ?? null)->first();
|
||||||
|
$data['parent_id'] = $parent->id ?? 0;
|
||||||
|
$model = $registry->categories()->create($data);
|
||||||
|
return fractal($model, new CategoryTransformer())->respond();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(string $id, array $data): ?JsonResponse {
|
||||||
|
$model = Category::byUuid($id)->firstOrFail();
|
||||||
|
$model->update($data);
|
||||||
|
return fractal($model->fresh(), new CategoryTransformer())->respond();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Forms\Registries;
|
||||||
|
|
||||||
|
use App\Models\Asset;
|
||||||
|
use App\Models\Objects\FieldType;
|
||||||
|
use App\Models\Registries\Category;
|
||||||
|
use App\Models\Registries\Entry;
|
||||||
|
use App\Models\Registries\Registry;
|
||||||
|
use App\Services\Forms\FormsService;
|
||||||
|
use App\Transformers\Assets\AssetTransformer;
|
||||||
|
use App\Transformers\Registries\EntryTransformer;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
class EntryForms extends FormsService {
|
||||||
|
public array $formTitles = ['create' => 'Создание записи', 'update' => 'Редактирование записи'];
|
||||||
|
|
||||||
|
public function form(?string $id = null, array $data = []): array {
|
||||||
|
$model = Entry::byUuid($id)->first();
|
||||||
|
$groups = [
|
||||||
|
['name' => 'common', 'fields' => $this->commonGroupFields($model)]
|
||||||
|
];
|
||||||
|
return ['title' => $this->formTitle($model), 'data' => $groups];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function commonGroupFields(?Entry $model): array {
|
||||||
|
$fields = [
|
||||||
|
[
|
||||||
|
'name' => 'number',
|
||||||
|
'title' => 'Номер записи',
|
||||||
|
'type' => FieldType::STRING,
|
||||||
|
'required' => true,
|
||||||
|
'value' => $model->number ?? null
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'name',
|
||||||
|
'title' => 'Название',
|
||||||
|
'type' => FieldType::STRING,
|
||||||
|
'required' => true,
|
||||||
|
'value' => $model->name ?? null
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'asset',
|
||||||
|
'title' => 'Документ',
|
||||||
|
'type' => FieldType::DOCUMENT,
|
||||||
|
'required' => true,
|
||||||
|
'value' => ($asset = $model->asset ?? null) ? fractal($asset, new AssetTransformer()) : null
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'active_since',
|
||||||
|
'title' => 'Дата начала действия',
|
||||||
|
'type' => FieldType::DATE,
|
||||||
|
'value' => ($v = $model->active_since ?? null) ? $v->toIso8601String() : null
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'active_till',
|
||||||
|
'title' => 'Дата окончания действия',
|
||||||
|
'type' => FieldType::DATE,
|
||||||
|
'value' => ($v = $model->active_till ?? null) ? $v->toIso8601String() : null
|
||||||
|
]
|
||||||
|
];
|
||||||
|
return ['data' => $fields];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function store(array $data): ?JsonResponse {
|
||||||
|
$registry = Registry::byUuid($data['registry'] ?? null)->firstOrFail();
|
||||||
|
$category = Category::byUuid($data['category'] ?? null)->first();
|
||||||
|
$data['asset_id'] = ($asset = Asset::byUuid($data['asset'])->first()) ? $asset->id : null;
|
||||||
|
$data['category_id'] = $category->id ?? 0;
|
||||||
|
$model = $registry->entries()->create($data);
|
||||||
|
return fractal($model, new EntryTransformer())->respond();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(string $id, array $data): ?JsonResponse {
|
||||||
|
$model = Entry::byUuid($id)->firstOrFail();
|
||||||
|
$data['asset_id'] = ($asset = Asset::byUuid($data['asset'])->first()) ? $asset->id : null;
|
||||||
|
$model->update($data);
|
||||||
|
return fractal($model->fresh(), new EntryTransformer())->respond();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Forms\Registries;
|
||||||
|
|
||||||
|
use App\Models\Asset;
|
||||||
|
use App\Models\Dictionaries\Dictionary;
|
||||||
|
use App\Models\Objects\FieldType;
|
||||||
|
use App\Models\Objects\NirObject;
|
||||||
|
use App\Models\Objects\ObjectType;
|
||||||
|
use App\Models\Registries\Entry;
|
||||||
|
use App\Models\Registries\Operation;
|
||||||
|
use App\Models\Registries\OperationType;
|
||||||
|
use App\Services\Forms\FormsService;
|
||||||
|
use App\Transformers\Assets\AssetTransformer;
|
||||||
|
use App\Transformers\Dictionaries\DictionaryItemTransformer;
|
||||||
|
use App\Transformers\Objects\FieldTransformer;
|
||||||
|
use App\Transformers\Objects\ObjectPropertyTransformer;
|
||||||
|
use App\Transformers\Objects\ObjectTransformer;
|
||||||
|
use App\Transformers\Registries\OperationTransformer;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
class OperationForms extends FormsService {
|
||||||
|
public array $formTitles = ['create' => 'Создание операции', 'update' => 'Редактирование операции'];
|
||||||
|
|
||||||
|
public function form(?string $id = null, array $data = []): array {
|
||||||
|
$model = NirObject::byUuid($id)->first();
|
||||||
|
$groups = [
|
||||||
|
['name' => 'common', 'fields' => $this->commonGroupFields($model)]
|
||||||
|
];
|
||||||
|
return ['title' => $this->formTitle($model), 'data' => $groups];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function commonGroupFields(?NirObject $model): array {
|
||||||
|
return $model ? fractal($model->groups->first()->fields, new ObjectPropertyTransformer($model))->toArray() :
|
||||||
|
fractal(ObjectType::byName('entry-operation')->first()->groups()->first()->fields, new FieldTransformer())->toArray();
|
||||||
|
|
||||||
|
/*
|
||||||
|
$fields = [
|
||||||
|
[
|
||||||
|
'name' => 'type',
|
||||||
|
'title' => 'Вид работы',
|
||||||
|
'type' => FieldType::RELATION,
|
||||||
|
'required' => true,
|
||||||
|
'appearance' => 'radio',
|
||||||
|
'options' => $this->getRelationItems(OperationType::TITLES),
|
||||||
|
'value' => $this->getRelationValue(OperationType::TITLES, $model->type ?? null)
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'order_name',
|
||||||
|
'title' => 'Наименование приказа',
|
||||||
|
'type' => FieldType::STRING,
|
||||||
|
'required' => true,
|
||||||
|
'value' => $model->order_name ?? null
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'order_date',
|
||||||
|
'title' => 'Дата приказа',
|
||||||
|
'required' => true,
|
||||||
|
'type' => FieldType::DATE,
|
||||||
|
'value' => ($v = $model->order_date ?? null) ? $v->toIso8601String() : null
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'order',
|
||||||
|
'title' => 'Документ приказа',
|
||||||
|
'type' => FieldType::DOCUMENT,
|
||||||
|
'required' => true,
|
||||||
|
'value' => ($order = $model->order ?? null) ? fractal($order, new AssetTransformer()) : null
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'listing',
|
||||||
|
'title' => 'Вхождение в перечень ПП',
|
||||||
|
'type' => FieldType::RELATION,
|
||||||
|
'multiple' => true,
|
||||||
|
'appearance' => 'checkbox',
|
||||||
|
'options' => fractal(Dictionary::byName('listings')->first()->items, new DictionaryItemTransformer()),
|
||||||
|
'value' => null
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'active_since',
|
||||||
|
'title' => 'Дата начала действия',
|
||||||
|
'type' => FieldType::DATE,
|
||||||
|
'required' => true,
|
||||||
|
'value' => ($v = $model->active_since ?? null) ? $v->toIso8601String() : null
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'active_till',
|
||||||
|
'title' => 'Дата окончания действия',
|
||||||
|
'type' => FieldType::DATE,
|
||||||
|
'value' => ($v = $model->active_till ?? null) ? $v->toIso8601String() : null
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'developer',
|
||||||
|
'title' => 'Разработчик',
|
||||||
|
'type' => FieldType::STRING,
|
||||||
|
'required' => true,
|
||||||
|
'value' => $model->developer ?? null
|
||||||
|
]
|
||||||
|
];
|
||||||
|
return ['data' => $fields];
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function store(array $data): ?JsonResponse {
|
||||||
|
$entry = Entry::byUuid($data['entry'] ?? null)->firstOrFail();
|
||||||
|
$model = $entry->createObject('entry-operation', null, 'operations');
|
||||||
|
$model->setValues($data);
|
||||||
|
return fractal($model, new ObjectTransformer())->respond();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(string $id, array $data): ?JsonResponse {
|
||||||
|
$model = NirObject::byUuid($id)->firstOrFail();
|
||||||
|
$model->setValues($data);
|
||||||
|
return fractal($model->fresh(), new ObjectTransformer())->respond();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Forms\Registries;
|
||||||
|
|
||||||
|
class RegistryFormsServices {
|
||||||
|
public static array $services = [
|
||||||
|
'registryCategory' => CategoryForms::class,
|
||||||
|
'registryEntry' => EntryForms::class,
|
||||||
|
'entryOperation' => OperationForms::class
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -23,7 +23,7 @@ class ObjectTransformer extends TransformerAbstract {
|
||||||
return [
|
return [
|
||||||
'id' => $model->uuid,
|
'id' => $model->uuid,
|
||||||
'name' => $model->name,
|
'name' => $model->name,
|
||||||
'type_title' => $model->type->title,
|
'type_title' => $model->type->title ?? null,
|
||||||
'pivot' => ['group' => $model->pivot->group ?? null, 'ord' => $model->pivot->ord ?? null],
|
'pivot' => ['group' => $model->pivot->group ?? null, 'ord' => $model->pivot->ord ?? null],
|
||||||
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : null,
|
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : null,
|
||||||
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : null
|
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : null
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ use App\Models\Pages\Page;
|
||||||
use App\Services\PermissionsService;
|
use App\Services\PermissionsService;
|
||||||
use App\Transformers\Objects\ObjectTransformer;
|
use App\Transformers\Objects\ObjectTransformer;
|
||||||
use App\Transformers\Publications\PublicationTransformer;
|
use App\Transformers\Publications\PublicationTransformer;
|
||||||
|
use App\Transformers\Registries\RegistryTransformer;
|
||||||
use League\Fractal\Resource\Collection;
|
use League\Fractal\Resource\Collection;
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
use League\Fractal\Resource\Primitive;
|
use League\Fractal\Resource\Primitive;
|
||||||
|
|
@ -17,7 +18,8 @@ class PageTransformer extends TransformerAbstract {
|
||||||
];
|
];
|
||||||
|
|
||||||
protected array $availableIncludes = [
|
protected array $availableIncludes = [
|
||||||
'children', 'parent', 'parents', 'sections', 'sidebars', 'publications', 'permissions'
|
'children', 'parent', 'parents', 'sections', 'sidebars', 'publications',
|
||||||
|
'registries', 'registry', 'permissions'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function transform(Page $model): array {
|
public function transform(Page $model): array {
|
||||||
|
|
@ -59,6 +61,14 @@ class PageTransformer extends TransformerAbstract {
|
||||||
return $this->collection($model->publications, new PublicationTransformer());
|
return $this->collection($model->publications, new PublicationTransformer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function includeRegistries(Page $model): Collection {
|
||||||
|
return $this->collection($model->registries, new RegistryTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function includeRegistry(Page $model): ?Item {
|
||||||
|
return $model->registry ? $this->item($model->registry, new RegistryTransformer()) : null;
|
||||||
|
}
|
||||||
|
|
||||||
public function includePermissions(Page $model): Primitive {
|
public function includePermissions(Page $model): Primitive {
|
||||||
return $this->primitive((new PermissionsService($model))->get());
|
return $this->primitive((new PermissionsService($model))->get());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformers\Registries;
|
||||||
|
|
||||||
|
use App\Models\Registries\Category;
|
||||||
|
use App\Services\PermissionsService;
|
||||||
|
use League\Fractal\Resource\Collection;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
use League\Fractal\Resource\Primitive;
|
||||||
|
use League\Fractal\TransformerAbstract;
|
||||||
|
|
||||||
|
class CategoryTransformer extends TransformerAbstract {
|
||||||
|
protected array $defaultIncludes = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
protected array $availableIncludes = [
|
||||||
|
'registry', 'parent', 'children', 'entries', 'permissions'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function transform(Category $model): array {
|
||||||
|
return [
|
||||||
|
'id' => $model->uuid,
|
||||||
|
'name' => $model->name,
|
||||||
|
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : null,
|
||||||
|
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : null
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function includeRegistry(Category $model): ?Item {
|
||||||
|
return $model->registry ? $this->item($model->registry, new RegistryTransformer()) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function includeParent(Category $model): ?Item {
|
||||||
|
return $model->parent ? $this->item($model->parent, new CategoryTransformer()) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function includeChildren(Category $model): Collection {
|
||||||
|
return $this->collection($model->children, new CategoryTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function includeEntries(Category $model): Collection {
|
||||||
|
return $this->collection($model->entries, new EntryTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function includePermissions(Category $model): Primitive {
|
||||||
|
return $this->primitive((new PermissionsService($model))->get());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformers\Registries;
|
||||||
|
|
||||||
|
use App\Models\Registries\Entry;
|
||||||
|
use App\Services\PermissionsService;
|
||||||
|
use App\Transformers\Assets\AssetTransformer;
|
||||||
|
use App\Transformers\Objects\ObjectTransformer;
|
||||||
|
use League\Fractal\Resource\Collection;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
use League\Fractal\Resource\Primitive;
|
||||||
|
use League\Fractal\TransformerAbstract;
|
||||||
|
|
||||||
|
class EntryTransformer extends TransformerAbstract {
|
||||||
|
protected array $defaultIncludes = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
protected array $availableIncludes = [
|
||||||
|
'registry', 'category', 'asset', 'operations'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function transform(Entry $model): array {
|
||||||
|
return [
|
||||||
|
'id' => $model->uuid,
|
||||||
|
'number' => $model->number,
|
||||||
|
'name' => $model->name,
|
||||||
|
'active_since' => $model->active_since ? $model->active_since->toIso8601String() : null,
|
||||||
|
'active_till' => $model->active_till ? $model->active_till->toIso8601String() : null,
|
||||||
|
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : null,
|
||||||
|
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : null
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function includeRegistry(Entry $model): ?Item {
|
||||||
|
return $model->registry ? $this->item($model->registry, new RegistryTransformer()) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function includeCategory(Entry $model): ?Item {
|
||||||
|
return $model->category ? $this->item($model->category, new CategoryTransformer()) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function includeAsset(Entry $model): ?Item {
|
||||||
|
return $model->asset ? $this->item($model->asset, new AssetTransformer()) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function includeOperations(Entry $model): Collection {
|
||||||
|
return $this->collection($model->operations, new ObjectTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function includePermissions(Entry $model): Primitive {
|
||||||
|
return $this->primitive((new PermissionsService($model))->get());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -17,7 +17,7 @@ class RegistryTransformer extends TransformerAbstract {
|
||||||
];
|
];
|
||||||
|
|
||||||
protected array $availableIncludes = [
|
protected array $availableIncludes = [
|
||||||
'page', 'entries', 'permissions'
|
'page', 'categories', 'entries', 'permissions'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function transform(Registry $model): array {
|
public function transform(Registry $model): array {
|
||||||
|
|
@ -34,6 +34,10 @@ class RegistryTransformer extends TransformerAbstract {
|
||||||
return $model->page ? $this->item($model->page, new PageTransformer()) : null;
|
return $model->page ? $this->item($model->page, new PageTransformer()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function includeCategories(Registry $model): Collection {
|
||||||
|
return $this->collection($model->rootCategories, new CategoryTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
public function includeEntries(Registry $model): Collection {
|
public function includeEntries(Registry $model): Collection {
|
||||||
return $this->collection($model->objects, new ObjectTransformer());
|
return $this->collection($model->objects, new ObjectTransformer());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class CreateRegistriesTable extends Migration
|
||||||
Schema::create('registries', function (Blueprint $table) {
|
Schema::create('registries', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->char('uuid', 36)->index()->unique();
|
$table->char('uuid', 36)->index()->unique();
|
||||||
$table->integer('page_id')->index()->default(0);
|
$table->integer('page_id')->index()->nullable();
|
||||||
$table->string('type')->index()->nullable();
|
$table->string('type')->index()->nullable();
|
||||||
$table->string('name')->index()->nullable();
|
$table->string('name')->index()->nullable();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateRegistryCategoriesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('registry_categories', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->char('uuid', 36)->index()->unique();
|
||||||
|
$table->integer('registry_id')->index()->nullable();
|
||||||
|
$table->integer('parent_id')->index()->default(0);
|
||||||
|
$table->string('name')->index()->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('registry_categories');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateRegistryEntriesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('registry_entries', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->char('uuid', 36)->index()->unique();
|
||||||
|
$table->integer('registry_id')->index()->nullable();
|
||||||
|
$table->integer('category_id')->index()->nullable();
|
||||||
|
$table->integer('asset_id')->index()->nullable();
|
||||||
|
$table->string('number')->index()->nullable();
|
||||||
|
$table->string('name')->index()->nullable();
|
||||||
|
$table->date('active_since')->index()->nullable();
|
||||||
|
$table->date('active_till')->index()->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('registry_entries');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -18,8 +18,20 @@ class DictionariesTableSeeder extends Seeder {
|
||||||
'feedback-types' => [
|
'feedback-types' => [
|
||||||
'title' => 'Тема обращения',
|
'title' => 'Тема обращения',
|
||||||
'items' => [
|
'items' => [
|
||||||
'regulation' => 'Техническое нормирование', 'assessment' => 'Оценка пригодности', 'certification' => 'Добровольная сертификация', 'questions' => 'Вопросы нормирования и стандартизации', 'other' => 'Другие'
|
'regulation' => 'Техническое нормирование',
|
||||||
]
|
'assessment' => 'Оценка пригодности',
|
||||||
|
'certification' => 'Добровольная сертификация',
|
||||||
|
'questions' => 'Вопросы нормирования и стандартизации',
|
||||||
|
'other' => 'Другие'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'operation-types' => [
|
||||||
|
'title' => 'Виды операций',
|
||||||
|
'items' => ['development' => 'Разработка', 'rework' => 'Пересмотр', 'modification' => 'Изменение']
|
||||||
|
],
|
||||||
|
'listings' => [
|
||||||
|
'title' => 'Перечни ПП',
|
||||||
|
'items' => ['pp1521' => 'ПП №1521 от 26.12.2014 г.', 'pp985' => 'ПП № 985 от 04.07.2020 г.', 'pp815' => 'ПП № 815 от 28.05.2021 г.']
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,54 @@ class FieldsTableSeeder extends Seeder {
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'showForm' => 'second',
|
'showForm' => 'second',
|
||||||
],
|
],
|
||||||
|
'operation-type' => [
|
||||||
|
'title' => 'Вид работы',
|
||||||
|
'type' => FieldType::RELATION,
|
||||||
|
'required' => true,
|
||||||
|
'params' => [
|
||||||
|
'appearance' => 'radio',
|
||||||
|
'related' => DictionaryItem::class, 'transformer' => DictionaryItemTransformer::class,
|
||||||
|
'options' => ['show' => true, 'whereHas' => ['dictionary' => ['name' => 'operation-types']]]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'order-name' => [
|
||||||
|
'title' => 'Наименование приказа',
|
||||||
|
'type' => FieldType::STRING,
|
||||||
|
'required' => true
|
||||||
|
],
|
||||||
|
'order-date' => [
|
||||||
|
'title' => 'Дата приказа',
|
||||||
|
'type' => FieldType::DATE,
|
||||||
|
'required' => true
|
||||||
|
],
|
||||||
|
'order-document' => [
|
||||||
|
'title' => 'Документ приказа',
|
||||||
|
'type' => FieldType::DOCUMENT,
|
||||||
|
'required' => true
|
||||||
|
],
|
||||||
|
'listings' => [
|
||||||
|
'title' => 'Вхождение в перечень ПП',
|
||||||
|
'type' => FieldType::RELATION,
|
||||||
|
'multiple' => true,
|
||||||
|
'params' => [
|
||||||
|
'appearance' => 'checkbox',
|
||||||
|
'related' => DictionaryItem::class, 'transformer' => DictionaryItemTransformer::class,
|
||||||
|
'options' => ['show' => true, 'whereHas' => ['dictionary' => ['name' => 'listings']]]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'active-since' => [
|
||||||
|
'title' => 'Дата начала действия',
|
||||||
|
'type' => FieldType::DATE,
|
||||||
|
'required' => true
|
||||||
|
],
|
||||||
|
'active-till' => [
|
||||||
|
'title' => 'Дата окончания действия',
|
||||||
|
'type' => FieldType::DATE
|
||||||
|
],
|
||||||
|
'developer' => [
|
||||||
|
'title' => 'Разработчик',
|
||||||
|
'type' => FieldType::STRING
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
public function run() {
|
public function run() {
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,11 @@ class ObjectTypeFieldsTableSeeder extends Seeder {
|
||||||
'common' => [
|
'common' => [
|
||||||
'fields' => ['feddback-email-admin', 'feedback-email-user', 'feedback-name', 'feedback-type', 'feedback-message']
|
'fields' => ['feddback-email-admin', 'feedback-email-user', 'feedback-name', 'feedback-type', 'feedback-message']
|
||||||
]
|
]
|
||||||
|
],
|
||||||
|
'entry-operation' => [
|
||||||
|
'common' => [
|
||||||
|
'fields' => ['operation-type', 'order-name', 'order-date', 'order-document', 'listings', 'active-since', 'active-till', 'developer']
|
||||||
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,13 +47,8 @@ class ObjectTypesTableSeeder extends Seeder {
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
'registry-entry' => [
|
'entry-operation' => [
|
||||||
'title' => 'Запись в реестре',
|
'title' => 'Действие с записью в реестре'
|
||||||
'children' => [
|
|
||||||
'registry-entry-document' => [
|
|
||||||
'title' => 'Документ'
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,22 @@ 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::group(['prefix' => 'registries'], function() {
|
||||||
|
Route::get('/categories', 'Api\Registries\CategoriesController@index');
|
||||||
|
Route::get('/categories/{id}', 'Api\Registries\CategoriesController@show');
|
||||||
|
Route::get('/entries', 'Api\Registries\EntriesController@index');
|
||||||
|
Route::get('/entries/{id}', 'Api\Registries\EntriesController@show');
|
||||||
|
Route::get('/operations', 'Api\Registries\OperationsController@index');
|
||||||
|
Route::get('/operations/{id}', 'Api\Registries\OperationsController@show');
|
||||||
|
Route::get('/', 'Api\Registries\RegistriesController@index');
|
||||||
|
Route::get('/{id}', 'Api\Registries\RegistriesController@show');
|
||||||
|
Route::group(['middleware' => ['auth:api']], function() {
|
||||||
|
Route::delete('/categories/{id}', 'Api\Registries\CategoriesController@destroy');
|
||||||
|
Route::delete('/entries/{id}', 'Api\Registries\EntriesController@destroy');
|
||||||
|
Route::delete('/operations/{id}', 'Api\Registries\OperationsController@destroy');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
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');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue