When updating my cart model, I run:
$cart->transaction_id= $result->salePaymentRequestResult->token;
$cart->save();
This does update my cart. But it with different value. Why is my model not being updated correctly?
I get no errors.
The cart does not get updated in the db correctly.
No errors. Behavior as normal.
Result of running this test to see if save succeeded was true.
This Laravel thread was no help
cart model:
3
Answers
Since your question is lacking context, I’ll suggest isolating the statements and log the values. You can start by asking the following questions:
$result->salePaymentRequestResult->token
at that point of code?$cart->transaction_id
? For example:$cart->transaction_id = 'test_token';
transaction_id
attribute? Defining a MutatorIt’s possible that the issue is due to the $fillable attribute not including transaction_id. Laravel prevents mass assignment for fields that aren’t in the $fillable array, which could cause the value not to save properly.
Sometimes cached data might show old values.
Because of the limited context, I think you should log the value of
$result->salePaymentRequestResult->token
to make sure it’s the correct data.Log::info('Token:', [$result->salePaymentRequestResult->token]);
I think this should shed more light on your issue.