troelskn / laravel-fillable-relations

Provides HasFillableRelations trait to Eloquent models
63 stars 23 forks source link

Allow to fill model in addiction to array. #2

Closed montyclt closed 7 years ago

montyclt commented 7 years ago

When I tried to fill a model, I get a PHP error saying fillBelongsToRelation expects as second parameter an array, object passed.

Seeing the code, I found the method sign force the second parameter be an array, but in method body checks if is a Model.

I propose to change method signature without type-hinting as array the second parameter, and specify in PHPDoc that the second parameter can be array or Model.

troelskn commented 7 years ago

Thanks for the PR. I agree, it should be possible to pass an object instance. I've added a few tests to cover the change you've made, and I'm merging both to master.

montyclt commented 7 years ago

Thanks you!