many fixes and updates
parent
cf18dea146
commit
3f96780514
|
|
@ -9,6 +9,7 @@ use App\Services\Filters\FiltersService;
|
|||
use App\Services\Forms\FormsService;
|
||||
use App\Transformers\Objects\ObjectTransformer;
|
||||
use App\Transformers\Objects\ObjectTypeTransformer;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FormsController extends Controller {
|
||||
|
|
@ -31,10 +32,17 @@ class FormsController extends Controller {
|
|||
} elseif ($objectType = ObjectType::byUuidOrName($type)->first()) {
|
||||
$object = $objectType->objects()->create();
|
||||
$object->setValues($request->all());
|
||||
$this->attachObject($object, $request->get('attach'));
|
||||
return fractal($object->fresh(), new ObjectTransformer());
|
||||
}
|
||||
}
|
||||
|
||||
public function attachObject(NirObject $object, $attach) {
|
||||
if (($type = $attach['model_type'] ?? null) && ($className = Relation::$morphMap[$type] ?? null) && ($id = $attach['model_id'] ?? null)) {
|
||||
if ($model = $className::byUuid($id)->first()) $model->attachObject($object, $attach['ord'] ?? null, $attach['group'] ?? null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function filters(Request $request, $type) {
|
||||
$filters = collect(json_decode($request->get('filters', []), true));
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use App\Models\Objects\Field;
|
|||
use App\Models\Objects\NirObject;
|
||||
use App\Models\Objects\ObjectType;
|
||||
use App\Transformers\Objects\ObjectTransformer;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
|
@ -56,6 +57,14 @@ class ObjectsController extends Controller {
|
|||
return fractal($model, new ObjectTransformer())->respond(201);
|
||||
}
|
||||
|
||||
public function move(Request $request, $id): JsonResponse {
|
||||
$model = $this->model->byUuid($id)->firstOrFail();
|
||||
if (($type = $request->get('model_type')) && ($className = Relation::$morphMap[$type] ?? null) && ($id = $request->get('model_id'))) {
|
||||
if ($related = $className::byUuid($id)->first()) $related->moveObject($model, $request->get('ord'), $request->get('group'));
|
||||
}
|
||||
return fractal($model, new ObjectTransformer())->respond();
|
||||
}
|
||||
|
||||
public function update(Request $request, $uuid): JsonResponse {
|
||||
$model = $this->model->byUuid($uuid)->firstOrFail();
|
||||
$this->validate($request, [
|
||||
|
|
|
|||
|
|
@ -19,13 +19,17 @@ class PagesController extends Controller {
|
|||
return fractal(Page::root(), new PageTransformer())->respond();
|
||||
}
|
||||
|
||||
public function find(Request $request): ?JsonResponse {
|
||||
return ($page = Page::byUrl($request->get('url'))) ? fractal($page, new PageTransformer())->respond() : null;
|
||||
}
|
||||
|
||||
public function index(Request $request): JsonResponse {
|
||||
$query = $this->model->query();
|
||||
$paginator = $query->paginate(config('app.pagination_limit'));
|
||||
return fractal($paginator, new PageTransformer())->respond();
|
||||
}
|
||||
|
||||
public function show($id): JsonResponse {
|
||||
public function show(Request $request, $id): JsonResponse {
|
||||
$model = $this->model->byUuid($id)->firstOrFail();
|
||||
return fractal($model, new PageTransformer())->respond();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class Field extends Model {
|
|||
}
|
||||
|
||||
public function objectValues($objectId): HasMany {
|
||||
return $this->values()->where(['object_id' => $objectId]);
|
||||
return $this->values()->where(['object_id' => $objectId])->orderBy('ord');
|
||||
}
|
||||
|
||||
public function objectsValues(array $ids): HasMany {
|
||||
|
|
@ -121,8 +121,8 @@ class Field extends Model {
|
|||
public function setValue($objectId, $value) {
|
||||
if ($this->multiple) $this->objectValues($objectId)->delete();
|
||||
if (!($value instanceof Collection)) $value = collect((is_array($value) && !Arr::isAssoc($value)) ? $value : [$value]);
|
||||
$value->each(function($value) use($objectId) {
|
||||
if ($this->multiple) $this->values()->create(['object_id' => $objectId])->set($value);
|
||||
$value->each(function($value, $ord) use($objectId) {
|
||||
if ($this->multiple) $this->values()->create(['object_id' => $objectId, 'ord' => $ord])->set($value);
|
||||
else $this->values()->firstOrCreate(['object_id' => $objectId])->set($value);
|
||||
});
|
||||
return $this->getValue($objectId);
|
||||
|
|
@ -130,9 +130,11 @@ class Field extends Model {
|
|||
|
||||
public function addValue($objectId, $value) {
|
||||
if ($this->multiple) {
|
||||
$max = $this->objectValues($objectId)->max('ord');
|
||||
if (is_null($max)) $max = -1;
|
||||
if (!($value instanceof Collection)) $value = collect((is_array($value) && !Arr::isAssoc($value)) ? $value : [$value]);
|
||||
$value->each(function($value) use($objectId) {
|
||||
$this->values()->create(['object_id' => $objectId])->set($value);
|
||||
$value->each(function($value, $ord) use($objectId, $max) {
|
||||
$this->values()->create(['object_id' => $objectId, 'ord' => $max + $ord + 1])->set($value);
|
||||
});
|
||||
}
|
||||
return $this->getValue($objectId);
|
||||
|
|
|
|||
|
|
@ -47,11 +47,10 @@ class NirObject extends Model {
|
|||
return $this->morphToMany(NirObject::class, 'objectable');
|
||||
}
|
||||
|
||||
public function pollInvitations(): MorphToMany {
|
||||
return $this->morphedByMany(PollInvitation::class, 'objectable');
|
||||
public function objectables($related): MorphToMany {
|
||||
return $this->morphedByMany($related, 'objectable')->withPivot(['ord', 'group']);
|
||||
}
|
||||
|
||||
|
||||
public function type(): BelongsTo {
|
||||
return $this->belongsTo(ObjectType::class);
|
||||
}
|
||||
|
|
@ -154,6 +153,12 @@ class NirObject extends Model {
|
|||
return $clone;
|
||||
}
|
||||
|
||||
public function currentGroup($related) {
|
||||
return ($res = $this->objectables($related)->first()) ? $res->pivot->group : 'default';
|
||||
}
|
||||
public function currentOrd($related) {
|
||||
return ($res = $this->objectables($related)->first()) ? $res->pivot->ord : null;
|
||||
}
|
||||
|
||||
public function applySearchFilter(Builder $query, $search) {
|
||||
$query->whereHas('stringValues', function($query) use($search) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ class DateValue extends Value {
|
|||
protected $table = 'field_date_values';
|
||||
|
||||
protected $dates = [
|
||||
'value'
|
||||
'value',
|
||||
'ord'
|
||||
];
|
||||
|
||||
public function get() {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ class DatetimeValue extends Value {
|
|||
protected $table = 'field_datetime_values';
|
||||
|
||||
protected $dates = [
|
||||
'value'
|
||||
'value',
|
||||
'ord'
|
||||
];
|
||||
|
||||
public function get() {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ class DocumentValue extends Value {
|
|||
protected $fillable = [
|
||||
'object_id',
|
||||
'field_id',
|
||||
'asset_id'
|
||||
'asset_id',
|
||||
'ord'
|
||||
];
|
||||
|
||||
public function asset(): BelongsTo {
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@ use App\Models\Asset;
|
|||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ImageValue extends Value {
|
||||
protected $table = 'field_document_values';
|
||||
protected $table = 'field_image_values';
|
||||
|
||||
protected $fillable = [
|
||||
'object_id',
|
||||
'field_id',
|
||||
'asset_id'
|
||||
'asset_id',
|
||||
'ord'
|
||||
];
|
||||
|
||||
public function asset(): BelongsTo {
|
||||
|
|
@ -23,7 +24,7 @@ class ImageValue extends Value {
|
|||
}
|
||||
|
||||
public function set($value): bool {
|
||||
if (!is_object($value)) $value = Asset::query()->where(['uuid' => $value])->first();
|
||||
if (!is_object($value)) $value = Asset::byUuid($value)->first();
|
||||
return is_object($value) ? $this->update(['asset_id' => $value->id]) : !$this->delete();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ class RelationValue extends Value {
|
|||
'object_id',
|
||||
'field_id',
|
||||
'relatable_type',
|
||||
'relatable_id'
|
||||
'relatable_id',
|
||||
'ord'
|
||||
];
|
||||
|
||||
public function relatable(): MorphTo {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ class TimeValue extends Value {
|
|||
protected $table = 'field_time_values';
|
||||
|
||||
protected $dates = [
|
||||
'value'
|
||||
'value',
|
||||
'ord'
|
||||
];
|
||||
|
||||
public function get() {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ abstract class Value extends Model {
|
|||
protected $fillable = [
|
||||
'object_id',
|
||||
'field_id',
|
||||
'value'
|
||||
'value',
|
||||
'ord'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
|
|
|||
|
|
@ -39,33 +39,37 @@ class Page extends Model {
|
|||
}
|
||||
|
||||
public function children(): HasMany {
|
||||
return $this->hasMany(Page::class, 'parent_id');
|
||||
return $this->hasMany(Page::class, 'parent_id')->orderBy('ord');
|
||||
}
|
||||
|
||||
public function sections(): MorphToMany {
|
||||
return $this->objects()->whereHas('type.parent', function($query) {
|
||||
$query->where(['name' => 'page-section']);
|
||||
});
|
||||
return $this->objects()->wherePivot('group', '=', 'sections');
|
||||
}
|
||||
|
||||
public function sidebar(): Model {
|
||||
return $this->getObject('page-sidebar');
|
||||
}
|
||||
public function sidebars(): MorphToMany {
|
||||
return $this->objects()->whereHas('type', function($query) {
|
||||
$query->where(['name' => 'page-sidebar']);
|
||||
return $this->objects()->wherePivot('group', '=', 'sidebars');
|
||||
}
|
||||
|
||||
|
||||
public function scopeBySlug($query, $slug) {
|
||||
$query->where(['slug' => $slug]);
|
||||
}
|
||||
|
||||
public function scopeNthParentSlug($query, $nth, $slug) {
|
||||
$query->whereHas(implode('.', array_fill(0, $nth, 'parent')), function($query) use($slug) {
|
||||
$query->bySlug($slug);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function getLinkAttribute(): string {
|
||||
return $this->parents->reverse()->push($this)->pluck('slug')->implode('/');
|
||||
return '/' . $this->parents->reverse()->push($this)->pluck('slug')->implode('/');
|
||||
}
|
||||
|
||||
public function getParentsAttribute(): Collection {
|
||||
$page = $this;
|
||||
$result = collect([]);
|
||||
while($page = $page->parent) $result->push($page);
|
||||
while ($page = $page->parent) $result->push($page);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
@ -75,14 +79,30 @@ class Page extends Model {
|
|||
|
||||
|
||||
|
||||
public function addSection($typeName, $ord) {
|
||||
$this->createObject($typeName, $ord);
|
||||
public function addSection($typeName, $ord = null): ?Model {
|
||||
return $this->createObject($typeName, $ord, 'sections');
|
||||
}
|
||||
|
||||
public function addSidebar($typeName = 'page-sidebar', $ord = null): ?Model {
|
||||
return $this->createObject($typeName, $ord, 'sidebars');
|
||||
}
|
||||
|
||||
|
||||
public static function byUrl($url) {
|
||||
if ($url = trim($url, '/ ')) {
|
||||
$query = self::query();
|
||||
collect(explode('/', $url))->reverse()->values()->each(function ($slug, $index) use ($query) {
|
||||
if ($slug !== '') {
|
||||
$index ? $query->nthParentSlug($index, $slug) : $query->bySlug($slug);
|
||||
}
|
||||
});
|
||||
return $query->first();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function root() {
|
||||
return self::query()->where(['parent_id' => 0])->get();
|
||||
return self::query()->where(['parent_id' => 0])->orderBy('ord')->get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,14 @@
|
|||
|
||||
namespace App\Services\Forms;
|
||||
|
||||
use App\Services\Forms\Pages\PageFormsServices;
|
||||
use App\Services\Forms\Users\UserFormsServices;
|
||||
|
||||
class FormsService {
|
||||
public array $formTitles = ['create' => '', 'update' => ''];
|
||||
|
||||
public static array $services = [
|
||||
PageFormsServices::class,
|
||||
UserFormsServices::class
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\Forms\Pages;
|
||||
|
||||
class PageFormsServices {
|
||||
public static array $services = [
|
||||
|
||||
];
|
||||
}
|
||||
|
|
@ -9,39 +9,80 @@ use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
|||
|
||||
trait HasObjectsTrait {
|
||||
public function objects(): MorphToMany {
|
||||
return $this->morphToMany(NirObject::class, 'objectable')->orderByPivot('ord')->withTimestamps();
|
||||
return $this->morphToMany(NirObject::class, 'objectable')->withPivot(['ord', 'group'])->orderByPivot('ord')->withTimestamps();
|
||||
}
|
||||
|
||||
public function objectsByGroup($group = null): MorphToMany {
|
||||
return $this->objects()->wherePivot('group', '=', $group ?? 'default');
|
||||
}
|
||||
|
||||
|
||||
public function getObjectAttribute() {
|
||||
return $this->objects()->first();
|
||||
}
|
||||
|
||||
|
||||
public function getObject($typeName): ?Model {
|
||||
return ($type = ObjectType::query()->where(['name' => $typeName])->first()) ? $this->objects()->firstOrCreate(['type_id' => $type->id]) : null;
|
||||
return ($type = ObjectType::byName($typeName)->first()) ? $this->objects()->firstOrCreate(['type_id' => $type->id]) : null;
|
||||
}
|
||||
|
||||
public function createObject($typeName, $ord = null): ?Model {
|
||||
if (($type = ObjectType::query()->where(['name' => $typeName])->first()) && ($object = NirObject::create(['type_id' => $type->id]))) {
|
||||
if ($ord !== null) $ord = ($res = $this->objects()->where(['type_id' => $type->id])->withPivot('ord')->reorder()->orderByPivot('ord', 'desc')->first()) ? ($res->pivot->ord + 1) : 0;
|
||||
$this->objects()->attach($object->id, ['ord' => $ord]);
|
||||
public function createObject($typeName, $ord = null, $group = null): ?Model {
|
||||
if (($type = ObjectType::byName($typeName)->first()) && ($object = NirObject::create(['type_id' => $type->id]))) {
|
||||
$this->attachObject($object, $ord, $group);
|
||||
return $object;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function attachObject(NirObject $object, $ord = null, $group = null) {
|
||||
$ord = ($ord === null) ? $this->getMaxOrd($group) : $ord;
|
||||
$this->moveFollowingObjects($ord, $group);
|
||||
$this->objects()->attach($object->id, ['ord' => $ord ?? 0, 'group' => $group ?? 'default']);
|
||||
}
|
||||
|
||||
public function moveFollowingObjects($ord, $group = null) {
|
||||
$this->objectsByGroup($group)->wherePivot('ord', '>=', $ord)->get()->each(function($object) {
|
||||
$this->objects()->updateExistingPivot($object, ['ord' => $object->pivot->ord + 1]);
|
||||
});
|
||||
}
|
||||
|
||||
public function getMaxOrd($group = null): int {
|
||||
$res = $this->objectsByGroup($group)->max('ord');
|
||||
return ($res !== null) ? ($res + 1) : 0;
|
||||
}
|
||||
|
||||
|
||||
public function moveObject(NirObject $object, $ord, $group = null) {
|
||||
$currentGroup = $object->currentGroup($this);
|
||||
$group = $group ?? $currentGroup;
|
||||
$currentOrd = $object->currentOrd($this);
|
||||
if (($group === $currentGroup) && ($ord > $currentOrd)) {
|
||||
$this->objectsByGroup($group)->wherePivot('ord', '>', $currentOrd)->wherePivot('ord', '<=', $ord)->each(function($object) {
|
||||
$this->objects()->updateExistingPivot($object, ['ord' => $object->pivot->ord - 1]);
|
||||
});
|
||||
} else $this->moveFollowingObjects($ord, $group);
|
||||
$this->objects()->updateExistingPivot($object, ['ord' => $ord, 'group' => $group ?? 'default']);
|
||||
$this->trimIndexes([$group, $currentGroup]);
|
||||
}
|
||||
|
||||
public function trimIndexes($groups) {
|
||||
collect(is_array($groups) ? $groups : [$groups])->unique()->each(function($group) {
|
||||
$this->objectsByGroup($group)->each(function($object, $index) {
|
||||
if ($object->pivot->ord !== $index) $this->objects()->updateExistingPivot($object, ['ord' => $index]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function getValue($fieldName) {
|
||||
return $this->object ? $this->object->getValue($fieldName) : null;
|
||||
}
|
||||
|
||||
public function setValue($fieldName, $value) {
|
||||
return $this->object ? $this->object->setValue($fieldName, $value) : null;
|
||||
}
|
||||
|
||||
public function setValues(array $values) {
|
||||
return $this->object ? $this->object->setValues($values) : null;
|
||||
}
|
||||
|
||||
public function addValue($fieldName, $value) {
|
||||
return $this->object ? $this->object->addValue($fieldName, $value) : null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class FieldsGroupTransformer extends TransformerAbstract {
|
|||
}
|
||||
|
||||
public function includeFields(FieldsGroup $model): Collection {
|
||||
return $this->collection($model->fields, new FieldTransformer($model->objectType));
|
||||
return $this->collection($model->fields, new FieldTransformer());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class ObjectPropertyTransformer extends TransformerAbstract {
|
|||
public function includeValue(Field $model) {
|
||||
if ($value = $model->getValue($this->object->id)) {
|
||||
if ($model->type === FieldType::RELATION) return $this->collection($value->filter(function($val) {return !is_null($val);}), $model->transformer);
|
||||
elseif ($model->type === FieldType::DOCUMENT) return $this->collection($value, new AssetTransformer());
|
||||
elseif (in_array($model->type, [FieldType::DOCUMENT, FieldType::IMAGE])) return $this->collection($value, new AssetTransformer());
|
||||
else return $this->primitive(['data' => $model->getValue($this->object->id)]);
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ class ObjectTransformer extends TransformerAbstract {
|
|||
'id' => $model->uuid,
|
||||
'name' => $model->name,
|
||||
'type_title' => $model->type->title,
|
||||
'pivot' => ['group' => $model->pivot->group ?? null, 'ord' => $model->pivot->ord ?? null],
|
||||
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : null,
|
||||
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : null
|
||||
];
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class PageTransformer extends TransformerAbstract {
|
|||
];
|
||||
|
||||
protected array $availableIncludes = [
|
||||
'children', 'parent', 'sections', 'sidebars', 'permissions'
|
||||
'children', 'parent', 'parents', 'sections', 'sidebars', 'permissions'
|
||||
];
|
||||
|
||||
public function transform(Page $model): array {
|
||||
|
|
@ -41,6 +41,10 @@ class PageTransformer extends TransformerAbstract {
|
|||
return $model->parent ? $this->item($model->parent, new PageTransformer()) : null;
|
||||
}
|
||||
|
||||
public function includeParents(Page $model): Collection {
|
||||
return $this->collection($model->parents->reverse(), new PageTransformer());
|
||||
}
|
||||
|
||||
public function includeSections(Page $model): Collection {
|
||||
return $this->collection($model->sections, new ObjectTransformer());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class CreateFieldStringValuesTable extends Migration
|
|||
$table->integer('object_id')->index()->nullable();
|
||||
$table->integer('field_id')->index()->nullable();
|
||||
$table->string('value', 500)->index()->nullable();
|
||||
$table->integer('ord')->index()->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class CreateFieldIntegerValuesTable extends Migration
|
|||
$table->integer('object_id')->index()->nullable();
|
||||
$table->integer('field_id')->index()->nullable();
|
||||
$table->integer('value')->index()->nullable();
|
||||
$table->integer('ord')->index()->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class CreateFieldFloatValuesTable extends Migration
|
|||
$table->integer('object_id')->index()->nullable();
|
||||
$table->integer('field_id')->index()->nullable();
|
||||
$table->float('value')->index()->nullable();
|
||||
$table->integer('ord')->index()->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class CreateFieldTextValuesTable extends Migration
|
|||
$table->integer('object_id')->index()->nullable();
|
||||
$table->integer('field_id')->index()->nullable();
|
||||
$table->text('value')->nullable();
|
||||
$table->integer('ord')->index()->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class CreateFieldBooleanValuesTable extends Migration
|
|||
$table->integer('object_id')->index()->nullable();
|
||||
$table->integer('field_id')->index()->nullable();
|
||||
$table->boolean('value')->index()->nullable();
|
||||
$table->integer('ord')->index()->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class CreateFieldRelationValuesTable extends Migration
|
|||
$table->integer('object_id')->index()->nullable();
|
||||
$table->integer('field_id')->index()->nullable();
|
||||
$table->nullableMorphs('relatable');
|
||||
$table->integer('ord')->index()->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class CreateFieldDateValuesTable extends Migration
|
|||
$table->integer('object_id')->index()->nullable();
|
||||
$table->integer('field_id')->index()->nullable();
|
||||
$table->date('value')->index()->nullable();
|
||||
$table->integer('ord')->index()->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class CreateFieldDatetimeValues extends Migration
|
|||
$table->integer('object_id')->index()->nullable();
|
||||
$table->integer('field_id')->index()->nullable();
|
||||
$table->dateTime('value')->index()->nullable();
|
||||
$table->integer('ord')->index()->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class CreateObjectablesTable extends Migration
|
|||
$table->id();
|
||||
$table->integer('nir_object_id')->index()->nullable();
|
||||
$table->nullableMorphs('objectable');
|
||||
$table->string('group')->index()->default('default');
|
||||
$table->integer('ord')->index()->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class CreateFieldDocumentValuesTable extends Migration
|
|||
$table->integer('object_id')->index()->nullable();
|
||||
$table->integer('field_id')->index()->nullable();
|
||||
$table->integer('asset_id')->index()->nullable();
|
||||
$table->integer('ord')->index()->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class CreateFieldTimeValuesTable extends Migration
|
|||
$table->integer('object_id')->index()->nullable();
|
||||
$table->integer('field_id')->index()->nullable();
|
||||
$table->date('value')->index()->nullable();
|
||||
$table->integer('ord')->index()->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class CreateFieldImageValues extends Migration
|
|||
$table->integer('object_id')->index()->nullable();
|
||||
$table->integer('field_id')->index()->nullable();
|
||||
$table->integer('asset_id')->index()->nullable();
|
||||
$table->integer('ord')->index()->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,16 +20,6 @@ class FieldsTableSeeder extends Seeder {
|
|||
'required' => true
|
||||
],
|
||||
|
||||
'subheader' => [
|
||||
'title' => 'Текст подзаголовка',
|
||||
'type' => FieldType::TEXT
|
||||
],
|
||||
'subheader-required' => [
|
||||
'title' => 'Текст подзаголовка',
|
||||
'type' => FieldType::TEXT,
|
||||
'required' => true
|
||||
],
|
||||
|
||||
'documents' => [
|
||||
'title' => 'Документы',
|
||||
'type' => FieldType::DOCUMENT,
|
||||
|
|
@ -69,6 +59,11 @@ class FieldsTableSeeder extends Seeder {
|
|||
],
|
||||
|
||||
'images' => [
|
||||
'title' => 'Изображения',
|
||||
'type' => FieldType::IMAGE,
|
||||
'multiple' => true
|
||||
],
|
||||
'images-required' => [
|
||||
'title' => 'Изображения',
|
||||
'type' => FieldType::IMAGE,
|
||||
'multiple' => true,
|
||||
|
|
|
|||
|
|
@ -11,19 +11,15 @@ class ObjectTypeFieldsTableSeeder extends Seeder {
|
|||
public array $objectTypeFields = [
|
||||
'page-sidebar' => [
|
||||
'common' => [
|
||||
'fields' => ['header', 'subheader', 'documents']
|
||||
'fields' => ['header', 'text', 'documents']
|
||||
]
|
||||
],
|
||||
|
||||
'page-section-header' => [
|
||||
'common' => [
|
||||
'fields' => ['header-required']
|
||||
]
|
||||
],
|
||||
'page-section-subheader' => [
|
||||
'common' => [
|
||||
'fields' => ['subheader-required']
|
||||
]
|
||||
],
|
||||
'page-section-text' => [
|
||||
'common' => [
|
||||
'fields' => ['text-required']
|
||||
|
|
@ -36,7 +32,12 @@ class ObjectTypeFieldsTableSeeder extends Seeder {
|
|||
],
|
||||
'page-section-images' => [
|
||||
'common' => [
|
||||
'fields' => ['images']
|
||||
'fields' => ['images-required']
|
||||
]
|
||||
],
|
||||
'page-section-documents' => [
|
||||
'common' => [
|
||||
'fields' => ['documents-required']
|
||||
]
|
||||
],
|
||||
'page-section-videos' => [
|
||||
|
|
|
|||
|
|
@ -16,11 +16,8 @@ class ObjectTypesTableSeeder extends Seeder {
|
|||
'page-section-header' => [
|
||||
'title' => 'Заголовок'
|
||||
],
|
||||
'page-section-subheader' => [
|
||||
'title' => 'Подзаголовок'
|
||||
],
|
||||
'page-section-text' => [
|
||||
'title' => 'Текст'
|
||||
'title' => 'Текстовый блок'
|
||||
],
|
||||
'page-section-list' => [
|
||||
'title' => 'Список'
|
||||
|
|
@ -28,6 +25,9 @@ class ObjectTypesTableSeeder extends Seeder {
|
|||
'page-section-images' => [
|
||||
'title' => 'Изображения'
|
||||
],
|
||||
'page-section-documents' => [
|
||||
'title' => 'Документы'
|
||||
],
|
||||
'page-section-videos' => [
|
||||
'title' => 'Видео'
|
||||
]
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ Route::get('/check-email', 'Api\Auth\RegisterController@checkEmail');
|
|||
|
||||
Route::get('pages', 'Api\Pages\PagesController@index');
|
||||
Route::get('pages/root', 'Api\Pages\PagesController@root');
|
||||
Route::get('pages/find', 'Api\Pages\PagesController@find');
|
||||
Route::get('pages/{id}', 'Api\Pages\PagesController@show');
|
||||
|
||||
Route::group(['middleware' => ['auth:api']], function() {
|
||||
|
|
@ -40,6 +41,7 @@ Route::group(['middleware' => ['auth:api']], function() {
|
|||
Route::post('/', 'Api\Assets\UploadFileController@store');
|
||||
});
|
||||
|
||||
Route::put('objects/move/{id}', 'Api\Objects\ObjectsController@move');
|
||||
Route::apiResource('objects', 'Api\Objects\ObjectsController');
|
||||
Route::apiResource('object-types', 'Api\Objects\ObjectTypesController');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue