Framework: SerializesModels - Doesn't serialize "dirty" attributes as dirty

Created on 1 Mar 2017  路  1Comment  路  Source: laravel/framework

  • Laravel Version: 5.4.13
  • PHP Version: 7.1.1
  • Database Driver & Version: MariaDB 10.1.20

Description:

When using the SeralizesModels trait, the dirty attributes on the model are not maintained. This means that if you use $model->getDirty() in the handling of the job it returns an empty array.

Steps To Reproduce:

  1. Instantiate a job with an Eloquent model that has dirty attributes.
  2. Check the output of $model-getDirty() in the handle() method

>All comments

Yes because when you serialize, the model is retrieved from the DB when the job is dispatched and no dirty state will be set then, you need to pass the value getDirty() to the job while dispatching if you need to use it.

Was this page helpful?
0 / 5 - 0 ratings