![]() As the fromDateTime() method expects the $current parameter as a DateTime value but instead a attribute name is passed. When I debug the process I see that the "filled" attributes are used as an input parameter in in line 1094 in the Class /vendor/illuminate/database/Eloquent/Concerns/HasAttributes.php. If I run the unit test I always receive the the InvalidArgumentException : A four digit year could not be found Data missing Expcetion. $ this-> assertEquals( $beforeFilePath, $order-> xml_file_path) $ this-> assertTrue( true, $order-> save()) $beforeFilePath = $order-> xml_file_path ** \App\Models\Order $order */ $order = $orders-> last() $orders = \ App\ Models\ Order:: hydrate(( array) $result) If I remove the dates attribute from my Eloquent Model, everything. $result = DB:: table( 'orders')-> latest()-> first() This returns the following error: A four digit year could not be found Data missing. $ this-> assertInstanceOf( App\ Models\ Order::class, $order) $order = factory(\ App\ Models\ Order::class)-> create() I think Laravel somehow thinks the primary key column is a date, because it throws this exception: A four digit year could not be found Data missing. Return number_format( $ this-> price_total, 2, ',', '') ** * Returns price with comma instead of do notation * * string */ public function getPriceTotalAttributeFormatted() Return $formatedOrderDate-> format( 'm.d.Y H:i:s') $formatedOrderDate = Carbon:: createFromFormat( 'Y-m-d H:i:s', $orderDate) ** * Mutator for order date * Returns date formatted * * $deliveryDate * string */ public function getOrderDateAttribute( $orderDate) Return $formatedDeliveryDate-> format( 'm.d.Y') ![]() $formatedDeliveryDate = Carbon:: createFromFormat( 'Y-m-d H:i:s', $deliveryDate) ** * Mutator for delivery date * Returns date formatted * * $deliveryDate * string */ public function getDeliveryDateAttribute( $deliveryDate) ** * Return all fillable attributes of the object * * array */ public function getAttributes() Return $ this-> hasMany( 'App\Models\OrderLines', 'order_id') Relationships public function orderlines()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |