FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix bug with SQLite morphs saves. Fixes #1004. Fixes #864. · JavaDevl/framework@ccaefab · GitHub

Commit ccaefab

Browse files
committed
Fix bug with SQLite morphs saves. Fixes laravel#1004. Fixes laravel#864.
1 parent 82dbe55 commit ccaefab

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎composer.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"ircmaxell/password-compat": "1.0.*",
1717
"filp/whoops": "1.0.1",
1818
"monolog/monolog": "1.4.*",
19+
"nesbot/carbon": "1.*",
1920
"patchwork/utf8": "1.1.*",
2021
"predis/predis": "0.8.*",
2122
"swiftmailer/swiftmailer": "4.3.*",
@@ -30,8 +31,7 @@
3031
"symfony/http-kernel": "2.3.*",
3132
"symfony/process": "2.3.*",
3233
"symfony/routing": "2.3.*",
33-
"symfony/translation": "2.3.*",
34-
"nesbot/carbon": "1.*"
34+
"symfony/translation": "2.3.*"
3535
},
3636
"replace": {
3737
"illuminate/auth": "self.version",

‎src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function getAndResetWheres()
8787
*/
8888
public function save(Model $model)
8989
{
90-
$model->setAttribute($this->morphType, $this->morphClass);
90+
$model->setAttribute($this->getPlainMorphType(), $this->morphClass);
9191

9292
return parent::save($model);
9393
}
@@ -121,7 +121,7 @@ public function create(array $attributes)
121121
*/
122122
protected function getForeignAttributesForCreate()
123123
{
124-
$foreign = array(last(explode('.', $this->foreignKey)) => $this->parent->getKey());
124+
$foreign = array($this->getPlainForeignKey() => $this->parent->getKey());
125125

126126
$foreign[last(explode('.', $this->morphType))] = $this->morphClass;
127127

@@ -138,6 +138,16 @@ public function getMorphType()
138138
return $this->morphType;
139139
}
140140

141+
/**
142+
* Get the plain morph type name without the table.
143+
*
144+
* @return string
145+
*/
146+
public function getPlainMorphType()
147+
{
148+
return last(explode('.', $this->morphType));
149+
}
150+
141151
/**
142152
* Get the class name of the parent model.
143153
*

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL