registries beta
parent
d7ab59d826
commit
09fd149bd9
|
|
@ -29,7 +29,6 @@ class Publication extends Model {
|
|||
'type',
|
||||
'name',
|
||||
'excerpt',
|
||||
'description',
|
||||
'is_published'
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Registries;
|
||||
|
||||
use App\Support\RelationValuesTrait;
|
||||
use App\Support\UuidScopeTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Category extends Model {
|
||||
use UuidScopeTrait, SoftDeletes, RelationValuesTrait;
|
||||
|
||||
protected $table = 'registry_categories';
|
||||
|
||||
protected $dates = [
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'registry_id',
|
||||
'parent_id',
|
||||
'name'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'id'
|
||||
];
|
||||
|
||||
|
||||
public function registry(): BelongsTo {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,23 +2,34 @@
|
|||
|
||||
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\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class RegistryEntry extends Model {
|
||||
class Entry extends Model {
|
||||
use UuidScopeTrait, SoftDeletes, HasObjectsTrait, RelationValuesTrait;
|
||||
|
||||
protected $table = 'registry_entries';
|
||||
|
||||
protected $dates = [
|
||||
'active_since',
|
||||
'active_till'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'registry_id',
|
||||
'name'
|
||||
'category_id',
|
||||
'asset_id',
|
||||
'number',
|
||||
'name',
|
||||
'active_since',
|
||||
'active_till'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
|
@ -30,6 +41,18 @@ class RegistryEntry extends Model {
|
|||
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(): HasMany {
|
||||
return $this->hasMany(Operation::class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Registries;
|
||||
|
||||
use App\Models\Asset;
|
||||
use App\Support\RelationValuesTrait;
|
||||
use App\Support\UuidScopeTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Operation extends Model {
|
||||
use UuidScopeTrait, SoftDeletes, RelationValuesTrait;
|
||||
|
||||
protected $table = 'registry_entry_operations';
|
||||
|
||||
protected $dates = [
|
||||
'order_date',
|
||||
'active_since',
|
||||
'active_till',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'entry_id',
|
||||
'order_id',
|
||||
'type',
|
||||
'developer',
|
||||
'order_name',
|
||||
'order_date',
|
||||
'active_since',
|
||||
'active_till'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'id'
|
||||
];
|
||||
|
||||
|
||||
public function entry(): BelongsTo {
|
||||
return $this->belongsTo(Entry::class);
|
||||
}
|
||||
|
||||
public function order(): BelongsTo {
|
||||
return $this->belongsTo(Asset::class);
|
||||
}
|
||||
|
||||
|
||||
public function getParsedTypeAttribute(): array {
|
||||
return ['name' => $this->type, 'title' => OperationType::TITLES[$this->type] ?? null];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Registries;
|
||||
|
||||
class OperationType {
|
||||
public const DEVELOPMENT = 'development';
|
||||
public const REWORK = 'rework';
|
||||
public const MODIFICATION = 'modification';
|
||||
|
||||
public const TITLES = [
|
||||
self::DEVELOPMENT => 'Разработка',
|
||||
self::REWORK => 'Пересмотр',
|
||||
self::MODIFICATION => 'Изменение'
|
||||
];
|
||||
}
|
||||
|
|
@ -3,15 +3,15 @@
|
|||
namespace App\Models\Registries;
|
||||
|
||||
use App\Models\Pages\Page;
|
||||
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\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Registry extends Model {
|
||||
use UuidScopeTrait, SoftDeletes, HasObjectsTrait, RelationValuesTrait;
|
||||
use UuidScopeTrait, SoftDeletes, RelationValuesTrait;
|
||||
|
||||
protected $dates = [
|
||||
];
|
||||
|
|
@ -32,6 +32,14 @@ class Registry extends Model {
|
|||
return $this->belongsTo(Page::class);
|
||||
}
|
||||
|
||||
public function categories(): HasMany {
|
||||
return $this->hasMany(Category::class);
|
||||
}
|
||||
|
||||
public function entries(): HasMany {
|
||||
return $this->hasMany(Entry::class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getParsedTypeAttribute(): array {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ class PublicationTransformer extends TransformerAbstract {
|
|||
'subtype' => $model->parsedType,
|
||||
'name' => $model->name,
|
||||
'excerpt' => $model->excerpt,
|
||||
'description' => $model->description,
|
||||
'is_published' => boolval($model->is_published),
|
||||
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : null,
|
||||
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : null
|
||||
|
|
|
|||
|
|
@ -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,55 @@
|
|||
<?php
|
||||
|
||||
namespace App\Transformers\Registries;
|
||||
|
||||
use App\Models\Registries\Entry;
|
||||
use App\Services\PermissionsService;
|
||||
use App\Transformers\Assets\AssetTransformer;
|
||||
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 OperationTransformer());
|
||||
}
|
||||
|
||||
public function includePermissions(Entry $model): Primitive {
|
||||
return $this->primitive((new PermissionsService($model))->get());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Transformers\Registries;
|
||||
|
||||
use App\Models\Registries\Entry;
|
||||
use App\Models\Registries\Operation;
|
||||
use App\Services\PermissionsService;
|
||||
use App\Transformers\Assets\AssetTransformer;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\Resource\Primitive;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class OperationTransformer extends TransformerAbstract {
|
||||
protected array $defaultIncludes = [
|
||||
|
||||
];
|
||||
|
||||
protected array $availableIncludes = [
|
||||
'entry', 'order'
|
||||
];
|
||||
|
||||
public function transform(Operation $model): array {
|
||||
return [
|
||||
'id' => $model->uuid,
|
||||
'type' => $model->parsedType,
|
||||
'name' => $model->name,
|
||||
'developer' => $model->developer,
|
||||
'order_name' => $model->order_name,
|
||||
'order_date' => $model->order_date ? $model->order_date->toIso8601String() : null,
|
||||
'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 includePermissions(Entry $model): Primitive {
|
||||
return $this->primitive((new PermissionsService($model))->get());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ class RegistryTransformer extends TransformerAbstract {
|
|||
];
|
||||
|
||||
protected array $availableIncludes = [
|
||||
'page', 'entries', 'permissions'
|
||||
'page', 'categories', 'entries', 'permissions'
|
||||
];
|
||||
|
||||
public function transform(Registry $model): array {
|
||||
|
|
@ -34,6 +34,10 @@ class RegistryTransformer extends TransformerAbstract {
|
|||
return $model->page ? $this->item($model->page, new PageTransformer()) : null;
|
||||
}
|
||||
|
||||
public function includeCategories(Registry $model): Collection {
|
||||
return $this->collection($model->categories, new CategoryTransformer());
|
||||
}
|
||||
|
||||
public function includeEntries(Registry $model): Collection {
|
||||
return $this->collection($model->objects, new ObjectTransformer());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class CreateRegistriesTable extends Migration
|
|||
Schema::create('registries', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$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('name')->index()->nullable();
|
||||
$table->timestamps();
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddDescriptionToPublicationsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('publications', function (Blueprint $table) {
|
||||
$table->addColumn('text', 'description')->after('excerpt')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('publications', function (Blueprint $table) {
|
||||
$table->dropColumn('description');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRegistryEntryOperationsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('registry_entry_operations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->char('uuid', 36)->index()->unique();
|
||||
$table->integer('entry_id')->index()->nullable();
|
||||
$table->integer('order_id')->index()->nullable();
|
||||
$table->string('type')->index()->nullable();
|
||||
$table->string('developer')->index()->nullable();
|
||||
$table->string('order_name')->index()->nullable();
|
||||
$table->date('order_date')->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_entry_operations');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue