Answer the question
In order to leave comments, you need to log in
How to change data in a large number of models?
There is a code $Org= OrgModel::all();
This code receives data from the fields name
, org
, order_data
.
The field order_data
is a date and time (i.e. like this: 0000-00-00 00:00:00 )
How do I change the date format to be 25-12-2015.
Is it possible?
With the help of carbon, you can change one record ( ::find(id);
)
Or am I misunderstanding something?!
Answer the question
In order to leave comments, you need to log in
Well, if you need to change the field itself in the database, then climb into the database and set the date field type, if you need to change the output, then you need to laravel.com/docs/5.1/eloquent-mutators#accessors-a...
public function getOrderDataAttribute($value) {
return $value->toDateString();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question