bosnadev / repository

Laravel Repositories is a package for Laravel 5 which is used to abstract the database layer. This makes applications much easier to maintain.
https://bosnadev.com
823 stars 233 forks source link

Usage question #53

Open sroutier opened 8 years ago

sroutier commented 8 years ago

Hey there,

Thanks for your awesome library, I have a question, hopefully not a bug, I am probably not using it right....

Using your example in the README, in the FilmsController, after you perform a search such as:

$filmsToDelete = $this->film->pushCriteria(new FilmCreatedBefore($search_date))->all();

The element $this->film->model changes from a instance of Film model to an instance of Illuminate\Database\Eloquent\Builder, this in turns makes it impossible to call the RepositoryInterface functions such as in:

        foreach( $filmsToDelete as $f) {
            $this->film->delete($f->id);
        }

This fails with Call to undefined method Illuminate\Database\Query\Builder::destroy() as the Repository.php calls $this->model->destroy($id); on line 126, but since the model is not a model anymore it fails.

Is this the expected behaviour or am I doing something wrong?

Thanks. /S