Check favoriteable isset before put on favorites stack.
Motivation and context
When a favorite user is a specific model and that model is deleted it is returned in the favorite() method this causes an exception when trying to access id. Exception below:
`ErrorException: Trying to get property 'id' of non-object
Favorite two articles with user and delete one of them. Checks if the return number in favorite () is equal to one.
Types of changes
What types of changes does your code introduce?
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
Go over all the following points, and put an x in all the boxes that apply.
Please, please, please, don't send your pull request until all of the boxes are ticked. Once your pull request is created, it will trigger a build on our continuous integration server to make sure your tests and code style pass.
Description
Check favoriteable isset before put on favorites stack.
Motivation and context
When a favorite user is a specific model and that model is deleted it is returned in the
favorite()
method this causes an exception when trying to access id. Exception below:`ErrorException: Trying to get property 'id' of non-object
/home/jedson/develop/contribuitions/laravel-favorite/src/Traits/Favoriteability.php:38 /home/jedson/develop/contribuitions/laravel-favorite/vendor/laravel/framework/src/Illuminate/Support/Collection.php:816 /home/jedson/develop/contribuitions/laravel-favorite/src/Traits/Favoriteability.php:40 /home/jedson/develop/contribuitions/laravel-favorite/tests/FavoriteModelTest.php:238`
How has this been tested?
Favorite two articles with user and delete one of them. Checks if the return number in
favorite ()
is equal to one.Types of changes
What types of changes does your code introduce?
Checklist:
Go over all the following points, and put an
x
in all the boxes that apply.Please, please, please, don't send your pull request until all of the boxes are ticked. Once your pull request is created, it will trigger a build on our continuous integration server to make sure your tests and code style pass.