-
Notifications
You must be signed in to change notification settings - Fork 442
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
Auto setter for relations #125
Comments
something similar: http://www.phpactiverecord.org/boards/1/topics/573-set-relationship |
There is it in a proper branch: https://github.com/greut/php-activerecord/compare/gh125-setter-for-relations |
Similar issue: #34 |
This still is not in official repo? Is PHP ActiveRecord still maintained? |
+1! |
+1 |
@greut did you ever make a formal pull request based on this issue. I see that you've put it into a separate branch on your own repo and linked it here, but making a formal PR makes the issue much easier to fix/merge. |
Yeah, @greut, if you could attach your branch to this issue to make it a pull request, that would really help. |
If @gruet doesn't this week, I'll fetch, rebase, and open a PR for his work. This seems like a no-brainer to add, assuming there are tests, of course. ;) |
Just a quick note, instead of simply checking if the // OLD way of doing it
if (is_object($value) &&
$relationship = $table->get_relationship($name)
)
...
// The new hotness
if (($value instanceof \ActiveRecord\Model) &&
$relationship = $table->get_relationship($name)
) Of course you don't have to fully qualify the Model namespace if its in the Model class already. Hell, you could just use |
@al-the-x be my guest, I won't have time to do that anytime soon. Thanks! |
Like your suggestion, @Rican7. Let's see which of us can get to it first...! 🐎 |
I've got tired of writing custom setters and came up with this, like __get it uses the relationship to auto assign a value.
What do you think?
The text was updated successfully, but these errors were encountered: