Closed coamw2 closed 1 year ago
My mistake. Incase anyone in future gets this issue:
$history->oldValue()
will return the foreign key value if valid e.g unknown
or 1234
or Jeff
$history->old_value
will return the exact value in database e.g 1234
We need a way to get the id value for foreign keys where they have been soft deleted.
e.g
job
table with foreign keyapplicant_id
If I change the applicant_id then on the job history I get
old_value = 1
andnew_value = 2
If I soft delete the applicant with
id = 1
then I getold_value = unknown
andnew_value = 2
I can see in the revisions table that
old_value = 1
however, so I'm guessing some check is happening because it's a foreign key where it retrieves the applicant model andisTrashed
is not used and therefore it fails to find and returns unknown, whereas I just need the history to give me the database value of 1 in this instance.