-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Open
Labels
Description
Laravel Version
12.32.5
PHP Version
8.4
Database Driver & Version
Mariadb 11, redis latest
Description
There is a bug in Laravel
If new get-set Hooks are used in the model, an error pops up when executing queues or Events using redis.
I use this bug fix in my work projects. The solution to get away from Attributes is to get away from using magic methods for simple calculations.
Error message: "Failed to serialize job of type [Illuminate\Events\CallQueuedListener]: serialize(): "full_name" returned as member variable from __sleep() but does not exist"
Code in Model
<?php
namespace App\Models;
use Laravel\Passport\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
final class Client extends Authenticatable
{
use HasApiTokens;
use HasFactory;
use Notifiable;
use Prunable;
use SoftDeletes;
protected $connection = 'mariadb';
protected $fillable = [
'first_name',
'last_name',
'middle_name',
];
public string $full_name {
get => "{$this->last_name} {$this->first_name} {$this->middle_name}";
}
...
}
I'm using this fix in Laravel version 12.32.5.
Wtf @taylorotwell ???
Pls view commit Fulliton@95d7bc1
Steps To Reproduce
Fulliton