Skip to content
This repository was archived by the owner on Jul 2, 2022. It is now read-only.

cant use for cycle dependency #11

Open
brillliant opened this issue Nov 5, 2020 · 0 comments
Open

cant use for cycle dependency #11

brillliant opened this issue Nov 5, 2020 · 0 comments

Comments

@brillliant
Copy link

CREATE TABLE category (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
title VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci',
parent_category_id INT(10) UNSIGNED NULL DEFAULT NULL,
enabled TINYINT(1) NOT NULL DEFAULT '1',
title_en VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci',
PRIMARY KEY (id) USING BTREE,
INDEX category_parent_category_id_foreign (parent_category_id) USING BTREE,
CONSTRAINT category_parent_category_id_foreign FOREIGN KEY (parent_category_id) REFERENCES inar_local_refactored.category (id) ON UPDATE RESTRICT ON DELETE RESTRICT
)

        Select::make('Category')
            ->options(\App\Category::all()->mapWithKeys(function ($category) {
                return [$category->id => $category->title];
            }))
            ->rules('required'),

        ChildSelect::make('Category')
            ->parent('id')
            ->options(function ($value) {
                \App\Category::whereParentCategoryId($value)->get()->mapWithKeys(function ($category) {
                    return [$category->id => $category->title];
                });
            })
            ->rules('required'),

what I'm doing wrong? you example in lib doesn not show initial DB structure.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant