My relationships are remembered.

Published 3 months ago by phpMick

This is very odd.

I have deleted all the rows from my agreements table (Agreement::all(); proves it.)

But, If I do this:

$selectedUserGroup->agreements;


Which uses:

 public function agreements()
    {
        return $this->hasMany(Agreement::class);
    }

I still get the old records!

I can workaround it by not using the relationship:

        $agreements =  Agreement::where('user_group_id','=',$selectedUserGroup->id)->get();

Any idea what is going on?

Mick (going mad).

Best Answer (As Selected By phpMick)
tykus

Is this in a single request/response cycle - can you get the desired result from $selectedUserGroup->fresh()->agreements;?

Or, are you caching somewhere?

tykus
tykus
3 months ago (564,760 XP)

Is this in a single request/response cycle - can you get the desired result from $selectedUserGroup->fresh()->agreements;?

Or, are you caching somewhere?

phpMick

fresh() fixed it

Why is that happening?

Yes, it is a single request it's just in my index page;

phpMick

The selectedUserGroup model was stored in the session......

Please sign in or create an account to participate in this conversation.