I have a job that is called by another job or a controller. Let’s call it CalledJob.
The calling job should be able to pass just the ID of the model and the CalledJob constructor/handle should receive the instantiated model instance.
CallinJob
{
function handle(){
$user = User::where('name','John')->first();
CalledJob:dispath($user->id);
}
}
CalledJob
{
Private User $user;
function __construct(User $user)
{
$this->user = $user;
function handle(){
print $this->user->name;
}
}
I have tried to use SerializeModel but not sure. Laravel should be able to do this because it does something similar (if not same) while routing where passing ID in request, instantiates a model instance.