Skip to main content

Manage Transactions with Eloquent Mutators

Premium
5:35

The Full Lesson is Only for Premium Members

Want to access all of our courses? (31 h 16 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

RA
Richard A. Hoyle ✓ Link copied!

Sorry about this but I am getting a error again. "message": "The transaction date field must be a valid date.", "errors": { "transaction_date": [ "The transaction date field must be a valid date." ] } status: 422 Unprocessable Content transaction_date 02-23-2023

	use Carbon\Carbon;
	
	class Transaction extends Model
	
	 public function setTransactionDateAttribute($value)
{
    $this->attributes['transaction_date'] = Carbon::createFromFormat('m/d/Y', $value)
        ->format('Y-m-d');
}
	
	If I comment this out it work but the date does not change
	
	The update methad will not work either get the same error message.
	
M
marko_mo ✓ Link copied!

Fix for Laravel 10

     public function setTransactionDateAttribute($value)
    {
        $this->attributes['transaction_date'] = \Carbon\Carbon::parse($value)->format('Y-m-d');
    }
V
Velkacem ✓ Link copied!

please give us the source code of this course or the github link