You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Job class that implements "ShouldQueue" and uses the trait "serializes model".
class Test implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function __construct(Group $group)
{
$this->group = $group;
}
public function handle() {/** do stuff **/ return;}
}
The group class has relation with user:
class Group extends Model {
public function users() {
return $this->belongsToMany(User::class)
->using(GroupUserPivot::class)
->withPivot('id')
->as('group_user_pivot');
}
}
The user also have a relation with groups
class User extends Model {
public function groups() {
return $this->belongsToMany(Group::class)
->using(GroupUserPivot::class)
->withPivot('id')
->as('group_user_pivot');
}
}
And the GroupUserPivot has a relation with roles (the roles the user have in that group);
class GroupUserPivot extends Pivot {
public function roles() {
return $this->belongsToMany(Role::class);
}
}
When de-serialized, it will try to load the relations and it will throw an error:
Illuminate\Database\Eloquent\RelationNotFoundException:
Call to undefined relationship [group_user_pivot.roles] on model
[App\Group in [path]/vendor/laravel/framework/src/Illuminate/Database/Eloquent
/RelationNotFoundException.php:34
The text was updated successfully, but these errors were encountered:
Description:
I have a Job class that implements "ShouldQueue" and uses the trait "serializes model".
The group class has relation with user:
The user also have a relation with groups
And the GroupUserPivot has a relation with roles (the roles the user have in that group);
Steps To Reproduce:
On tinker:
This will be the result of the serialization:
When de-serialized, it will try to load the relations and it will throw an error:
The text was updated successfully, but these errors were encountered: