Courses

Flutter v2 Mobile App with Laravel API

Manage Transactions with Eloquent Mutators

Previous: Get Transactions: Resource with Money/Date Transformation
avatar

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.
	
avatar

Fix for Laravel 10

     public function setTransactionDateAttribute($value)
    {
        $this->attributes['transaction_date'] = \Carbon\Carbon::parse($value)->format('Y-m-d');
    }
avatar
You can use Markdown
avatar

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

avatar
You can use Markdown
avatar
You can use Markdown