Ich versuche, Carbon datetime in Sub-Json-Dokument zu speichern, aber im ISO-Format speichern seine Speicherung auf andere Weise unten dargestellt.So speichern Sie Carbon DateTime ISO-Objekt in Sub-Json-Dokument in Laravel 5.2 MongoDB
"_id" : ObjectId("5791bc3d6e79d211aa5be019"),
"breakUps" : [
{
"amount" : 2000,
"expiry" : {
"date" : "2016-09-05 06:25:01.000000",
"timezone_type" : 3,
"timezone" : "UTC"
}
}
],
"updated_at" : ISODate("2016-07-22T06:25:01.576Z"),
"created_at" : ISODate("2016-07-22T06:25:01.576Z")
Stattdessen sollte es wie isodate gespeichert ("2016-07-22T06: 25: 01.576Z") Format.
Meine Eloquent Modellklasse ist:
class Configurations extends Eloquent
{
public $incrementing = false;
public $timestamps = true;
protected $collection = 'configurations';
protected $dates = array('created_at','updated_at','breakUps.expiry');
}
PHP-Code, die ich für Speicher sind mit dem Objekt
$config1 = new Configurations();
$config1->breakUps = [['amount' => 1000, 'expiry' => Carbon::now()->addDays(30)]];
$config1->save();
Kann ich sehen, wie Sie die Breakups sparen –
Thema diskutiert hier https://github.com/jenssegers/laravel-mongodb/issues/897 – Sharath