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

add ability to create simple relations with addRelation() #92

Closed
romaninsh opened this issue Aug 13, 2016 · 2 comments
Closed

add ability to create simple relations with addRelation() #92

romaninsh opened this issue Aug 13, 2016 · 2 comments
Assignees
Milestone

Comments

@romaninsh
Copy link
Member

romaninsh commented Aug 13, 2016

Currently using hasOne() and hasMany() you can define related models. That's cool, but sometimes you want to add a custom relation.

Basically when calling $m->ref('AuditLog'); it would respond with a related model. Technically you could create a method $m->getAuditLog(); but we want to keep all relations separate in case we want to iterate through them (for example by visualising in UI or exploring relations).

Here is invocation:

$m->addRelation('AuditLog', function($m) {
    return (new Model_Audit($big_data_db))->addCondition('user_id', $m->id);
});

And usage after:

$log = $m->load(123)->ref('AuditLog');
$log->addAction(..);

or in UI framework:

$crud->addRef('AuditLog');
@DarkSide666
Copy link
Member

👍

@romaninsh romaninsh added this to the 1.1.0 milestone Aug 15, 2016
@romaninsh
Copy link
Member Author

Partially implemented when introduced new Relation class.

@ghost ghost assigned romaninsh Oct 3, 2016
@ghost ghost assigned DarkSide666 Oct 4, 2016
@ghost ghost removed the in progress label Oct 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants