cards section and few minor updates
parent
20beb09593
commit
2bf370c473
|
|
@ -15,6 +15,7 @@ use App\Models\Objects\Values\TextValue;
|
|||
use App\Models\Pages\Page;
|
||||
use App\Models\Registries\Entry;
|
||||
use App\Models\User;
|
||||
use App\Support\HasObjectsTrait;
|
||||
use App\Support\UuidScopeTrait;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
|
@ -25,7 +26,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
use Illuminate\Support\Collection;
|
||||
|
||||
class NirObject extends Model {
|
||||
use UuidScopeTrait, SoftDeletes;
|
||||
use UuidScopeTrait, SoftDeletes, HasObjectsTrait;
|
||||
|
||||
protected $table = 'objects';
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class Page extends Model {
|
|||
|
||||
|
||||
public function getLinkAttribute(): string {
|
||||
return '/' . $this->parents->reverse()->push($this)->pluck('slug')->implode('/');
|
||||
return '/' . $this->parents->reverse()->push($this)->pluck('slug')->filter(function($v) {return $v;})->implode('/');
|
||||
}
|
||||
|
||||
public function getParentsAttribute(): Collection {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class ObjectTransformer extends TransformerAbstract {
|
|||
];
|
||||
|
||||
protected array $availableIncludes = [
|
||||
'groups', 'type', 'owner', 'pages', 'permissions'
|
||||
'groups', 'type', 'owner', 'pages', 'objects', 'permissions'
|
||||
];
|
||||
|
||||
public function transform(NirObject $model): array {
|
||||
|
|
@ -47,6 +47,10 @@ class ObjectTransformer extends TransformerAbstract {
|
|||
return $this->collection($model->pages, new PageTransformer());
|
||||
}
|
||||
|
||||
public function includeObjects(NirObject $model): Collection {
|
||||
return $this->collection($model->objects, new ObjectTransformer());
|
||||
}
|
||||
|
||||
public function includePermissions(NirObject $model): Primitive {
|
||||
return $this->primitive((new PermissionsService($model))->get());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class PageTransformer extends TransformerAbstract {
|
|||
];
|
||||
|
||||
protected array $availableIncludes = [
|
||||
'hasChildren', 'children', 'parent', 'parents', 'picture', 'sections', 'sidebars', 'publications',
|
||||
'children', 'parent', 'parents', 'picture', 'sections', 'sidebars', 'publications',
|
||||
'registries', 'registry', 'permissions'
|
||||
];
|
||||
|
||||
|
|
@ -35,15 +35,12 @@ class PageTransformer extends TransformerAbstract {
|
|||
'description' => $model->description,
|
||||
'keywords' => $model->keywords,
|
||||
'h1' => $model->h1,
|
||||
'has_children' => $model->children()->exists(),
|
||||
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : null,
|
||||
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : null
|
||||
];
|
||||
}
|
||||
|
||||
public function includeHasChildren(Page $model): Primitive {
|
||||
return $this->primitive($model->children()->exists());
|
||||
}
|
||||
|
||||
public function includeChildren(Page $model): Collection {
|
||||
return $this->collection($model->children, new PageTransformer());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,15 @@ class FieldsTableSeeder extends Seeder {
|
|||
'required' => true
|
||||
],
|
||||
|
||||
'image' => [
|
||||
'title' => 'Изображение',
|
||||
'type' => FieldType::IMAGE
|
||||
],
|
||||
'image-required' => [
|
||||
'title' => 'Изображение',
|
||||
'type' => FieldType::IMAGE,
|
||||
'required' => true
|
||||
],
|
||||
'images' => [
|
||||
'title' => 'Изображения',
|
||||
'type' => FieldType::IMAGE,
|
||||
|
|
@ -76,6 +85,34 @@ class FieldsTableSeeder extends Seeder {
|
|||
]
|
||||
],
|
||||
|
||||
'link' => [
|
||||
'title' => 'Ссылка',
|
||||
'type' => FieldType::STRING
|
||||
],
|
||||
'link-required' => [
|
||||
'title' => 'Ссылка',
|
||||
'type' => FieldType::STRING,
|
||||
'required' => true
|
||||
],
|
||||
|
||||
'cards-section-type' => [
|
||||
'title' => 'Тип карточек',
|
||||
'type' => FieldType::RELATION,
|
||||
'required' => true,
|
||||
'params' => [
|
||||
'related' => ObjectType::class, 'transformer' => ObjectTypeTransformer::class,
|
||||
'options' => ['show' => true, 'whereHas' => ['parent' => ['name' => 'cards-section-type']]]
|
||||
]
|
||||
],
|
||||
'person-name' => [
|
||||
'title' => 'ФИО сотрудника',
|
||||
'type' => FieldType::STRING
|
||||
],
|
||||
'person-position' => [
|
||||
'title' => 'Должность',
|
||||
'type' => FieldType::STRING
|
||||
],
|
||||
|
||||
'video-url' => [
|
||||
'title' => 'Ссылка на видео',
|
||||
'type' => FieldType::STRING,
|
||||
|
|
|
|||
|
|
@ -31,6 +31,23 @@ class ObjectTypeFieldsTableSeeder extends Seeder {
|
|||
'fields' => ['images-required', 'image-type']
|
||||
]
|
||||
],
|
||||
|
||||
'page-section-cards' => [
|
||||
'common' => [
|
||||
'fields' => ['cards-section-type']
|
||||
]
|
||||
],
|
||||
'cards-section-persons' => [
|
||||
'common' => [
|
||||
'fields' => ['image', 'person-name', 'person-position', 'contact-phone', 'contact-email', 'html']
|
||||
]
|
||||
],
|
||||
'cards-section-partners' => [
|
||||
'common' => [
|
||||
'fields' => ['image-required', 'link-required']
|
||||
]
|
||||
],
|
||||
|
||||
'page-section-documents' => [
|
||||
'common' => [
|
||||
'fields' => ['documents-required']
|
||||
|
|
|
|||
|
|
@ -26,10 +26,12 @@ class ObjectTypesTableSeeder extends Seeder {
|
|||
'page-section-media' => [
|
||||
'title' => 'Визуальные элементы',
|
||||
'children' => [
|
||||
|
||||
'page-section-images' => [
|
||||
'title' => 'Изображения'
|
||||
],
|
||||
'page-section-cards' => [
|
||||
'title' => 'Карточки'
|
||||
],
|
||||
'page-section-video' => [
|
||||
'title' => 'Видео'
|
||||
],
|
||||
|
|
@ -55,6 +57,14 @@ class ObjectTypesTableSeeder extends Seeder {
|
|||
]
|
||||
],
|
||||
|
||||
'cards-section-type' => [
|
||||
'title' => 'Тип карточек',
|
||||
'children' => [
|
||||
'cards-section-persons' => ['title' => 'Сотрудники'],
|
||||
'cards-section-partners' => ['title' => 'Партнеры']
|
||||
]
|
||||
],
|
||||
|
||||
'feedback-form' => [
|
||||
'title' => '',
|
||||
'children' => [
|
||||
|
|
|
|||
Loading…
Reference in New Issue