I have two models:
Place::find(1)->users[0]->pivot->type
i add this method but it doesn't work and return string:
public function getTypeAttribute($value){
return collect(json_decode($value));
}
I forgot to use using
. It should be like this:
$this->belongsToMany(Place::class, 'roles', 'place_id', 'user_id')->using(Role::class)->withPivot('type');