Skip to content

Commit 599719a

Browse files
committed
Branch Init for Laravel 6 (and 5.8) compatibility
1 parent dc37aa4 commit 599719a

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
],
1919
"license": "MIT",
2020
"require": {
21-
"illuminate/support": "^8.0",
22-
"illuminate/container": "^8.0",
23-
"illuminate/database": "^8.0",
24-
"illuminate/events": "^8.0",
21+
"illuminate/support": "^5.8|^6.0",
22+
"illuminate/container": "^5.8|^6.0",
23+
"illuminate/database": "^5.8|^6.0",
24+
"illuminate/events": "^5.8|^6.0",
2525
"elasticsearch/elasticsearch": "^7.16",
2626
"ongr/elasticsearch-dsl": "^7.2"
2727
},

src/Eloquent/Model.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ public function fromDateTime($value)
9292
*/
9393
protected function asDateTime($value)
9494
{
95+
$explode = explode('.', $value);
96+
if (isset($explode[1])) {
97+
return Carbon::parse($value)->setTimezone('UTC');
98+
99+
}
95100

96101
return parent::asDateTime($value);
97102
}
@@ -181,7 +186,7 @@ public function getCasts()
181186
/**
182187
* @inheritdoc
183188
*/
184-
public function originalIsEquivalent($key)
189+
public function originalIsEquivalent($key, $current)
185190
{
186191
if (!array_key_exists($key, $this->original)) {
187192
return false;
@@ -350,15 +355,23 @@ protected function isGuardableColumn($key)
350355

351356
public function saveWithoutRefresh(array $options = [])
352357
{
353-
$this->mergeAttributesFromCachedCasts();
354358

355359
$query = $this->newModelQuery();
356360
$query->setRefresh(false);
357361

362+
if ($this->fireModelEvent('saving') === false) {
363+
return false;
364+
}
365+
358366
if ($this->exists) {
359367
$saved = $this->isDirty() ? $this->performUpdate($query) : true;
360368
} else {
361369
$saved = $this->performInsert($query);
370+
371+
if (!$this->getConnectionName()
372+
&& $connection = $query->getConnection()) {
373+
$this->setConnection($connection->getName());
374+
}
362375
}
363376

364377
if ($saved) {

0 commit comments

Comments
 (0)