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

Role $model save() returns false after attaching/detaching roles in Laravel 5.3 #27

Closed
larsbo opened this issue Sep 8, 2016 · 2 comments

Comments

@larsbo
Copy link

larsbo commented Sep 8, 2016

When I change the permissions of a role with $role->attachPermission() or $role->detachPermission()and save the role, the role is updated in db but the save() method returns false(a.k.a. no actually model db change happened).

I think the reason for this is that in Laravel 5.3 the behaviour value of the save() method changed:

The Eloquent save method now returns false if the model has not been changed since the last time it was retrieved or saved.
https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0

@santigarcor
Copy link
Owner

@larsbo You're totally right. Now the save method from the Eloquent always returns null if no change was made to the model.

Check this post for a possible solution to check if a model was saved

@larsbo
Copy link
Author

larsbo commented Sep 8, 2016

Thank you for the link - I already used that fix :-)

Nevertheless I think the expected result of updating a manipulated role should be true. Maybe It's possible to manually make the instance "dirty" when attaching/detaching permissions?

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