Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRUD relations data #1014

Closed
nadar opened this issue Oct 10, 2016 · 1 comment
Closed

CRUD relations data #1014

nadar opened this issue Oct 10, 2016 · 1 comment

Comments

@nadar
Copy link
Contributor

nadar commented Oct 10, 2016

Provide an ability to easy manage relation data by creating tabs for the relation dependency instead of clicking into other menu entries.

@nadar nadar added this to the 1.0.0-rc2 milestone Oct 10, 2016
@nadar nadar self-assigned this Oct 10, 2016
nadar added a commit that referenced this issue Oct 10, 2016
nadar added a commit that referenced this issue Oct 11, 2016
nadar added a commit that referenced this issue Oct 17, 2016
nadar added a commit that referenced this issue Oct 18, 2016
nadar added a commit that referenced this issue Oct 18, 2016
@nadar
Copy link
Contributor Author

nadar commented Oct 24, 2016

Example from the Docs:

Crud Relation Tabs

Sometimes its usefull and common to directly manage relational data inside the current ngrest crud. Therefore we have created something called ngRestRelations(). Inside this method you can define relations which are also based on the NgRest concept.

public function ngRestRelation()
{
    return [
        ['label' => 'The Label', 'apiEndpoint' => \path\to\ngRest\Model::ngRestApiEndpoint(), 'dataProvider' => $this->getSales()],
    ];
}

The above example will use the getSales() method of the current model where you are implementing this relation. The getSales() must return an {{yii\db\QueryInterface}} Object, for example you can use $this->hasMany(Model, ['key' => 'rel']) or new \yii\db\Query().

Tip: If you generate an NgRest model for a relation which is not used in any other situations you can hide those items from the menu, but not from the permission system. To hide en element add the hiddenInMenu option in the getMenu() method of the module as following: itemApi('name', 'route', 'icon', 'api', ['hiddenInMenu' => true]).

@nadar nadar closed this as completed in 9bbac7d Oct 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant