Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Question: Can I use this on a Pivot Model? #485

ferdiebergado started this conversation in General
Discussion options

This is actually just a question.

I have created a Base Pivot Model which use laravel-model-caching like this:

<?php
namespace App;
use Illuminate\Database\Eloquent\Relations\Pivot;
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
abstract class BasePivot extends Pivot
{
 use Cachable;
}

Then, from it I extend my Pivot Models.

<?php
namespace App;
use App\BasePivot;
class UserPermission extends BasePivot
{
 //
}

It seems that every time the Pivot Model is called in a relationship, data is not cached as seen from debugbar.

 public function permissions()
 {
 return $this->belongsToMany('App\Permission')->using('App\UserPermission');
 }

What am I missing? Thanks.

You must be logged in to vote

Replies: 5 comments

Comment options

Hi @ferdiebergado, I'll have to look into this.

You must be logged in to vote
0 replies
Comment options

Thanks mike. I'll be standing by for updates.

You must be logged in to vote
0 replies
Comment options

This is related to #127 .... so I won't have an answer for you anytime soon. But I'll keep this open. If anyone has the time to create a PR for this, that would be awesome!

You must be logged in to vote
0 replies
Comment options

Alright mike. I'll just use eager-loading for relationships for now. Thanks.

You must be logged in to vote
0 replies
Comment options

@ferdiebergado Hi there, I know it's been a while, but I might have good news. :) Would you mind testing the latest release and see if this works for you now?

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Converted from issue

This discussion was converted from issue #151 on March 05, 2025 13:44.

AltStyle によって変換されたページ (->オリジナル) /