Skip to content

remove unneeded check to make compatible with mongodb #80

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

Merged
merged 1 commit into from
Feb 19, 2018

Conversation

vesper8
Copy link
Contributor

@vesper8 vesper8 commented Feb 18, 2018

In order for my mongodb models to be able to extend this trait, I had to make a CachedModel of my own as seen below

use GeneaLabs\LaravelModelCaching\CachedBuilder as Builder;
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

abstract class _CachedMongoModel extends Eloquent
{
    use Cachable;

    ... rest is the same as your CachedModel
}

But then the above check was a blocker. Upon inspection it seems like there's no reason to make this check since we can assume anyone using your trait is using it with your CachedModel (or an adapted clone as in my case)

In order for my mongodb models to be able to extend this trait, I had to make a CachedModel of my own as seen below

```
use GeneaLabs\LaravelModelCaching\CachedBuilder as Builder;
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

abstract class _CachedMongoModel extends Eloquent
{
    use Cachable;

    ... rest is the same as your CachedModel
}
```

But then the above check was a blocker. Upon inspection it seems like there's no reason to make this check since we can assume anyone using your trait is using it with your CachedModel (or an adapted clone as in my case)
@vesper8
Copy link
Contributor Author

vesper8 commented Feb 18, 2018

hrm ok.. perhaps that check is not as unneeded as I thought. Even though commenting it out in my fork does not seem to be causing any issues.

Perhaps the solution then is to add a configuration option where one can whitelist which classes are recognized, with the default being the included CachedModel class

I guess for now I will just re-fork with your latest changes and hardcode it like this

            if (is_a($this, CachedModel::class) || is_a($this, CachedMongoModel::class)) {
                array_push($tags, str_slug(get_called_class()));
            }

@mikebronner
Copy link
Owner

@vesper8 I was looking at your change and realized you were right, but I need to analyze the ramifications first (that's why I deleted my comment). I will take a look at that now.

@mikebronner
Copy link
Owner

If you wish to join, I'm live-streaming this: https://www.larastream.com/r/40555b5 :)

@mikebronner mikebronner changed the base branch from master to hotfix/fix-redundant-class-check February 19, 2018 00:07
@mikebronner mikebronner merged commit a755769 into mikebronner:hotfix/fix-redundant-class-check Feb 19, 2018
@vesper8
Copy link
Contributor Author

vesper8 commented Feb 19, 2018

I joined, but not sure if you can see my comments

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

Successfully merging this pull request may close these issues.

2 participants