1
- <?php namespace Jenssegers \Mongodb \Eloquent ;
1
+ <?php
2
+
3
+ namespace Jenssegers \Mongodb \Eloquent ;
2
4
3
5
use Illuminate \Database \Eloquent \Relations \MorphMany ;
4
6
use Illuminate \Database \Eloquent \Relations \MorphOne ;
@@ -23,7 +25,7 @@ trait HybridRelations
23
25
public function hasOne ($ related , $ foreignKey = null , $ localKey = null )
24
26
{
25
27
// Check if it is a relation with an original model.
26
- if (! is_subclass_of ($ related , \Jenssegers \Mongodb \Eloquent \Model::class)) {
28
+ if (!is_subclass_of ($ related , \Jenssegers \Mongodb \Eloquent \Model::class)) {
27
29
return parent ::hasOne ($ related , $ foreignKey , $ localKey );
28
30
}
29
31
@@ -49,7 +51,7 @@ public function hasOne($related, $foreignKey = null, $localKey = null)
49
51
public function morphOne ($ related , $ name , $ type = null , $ id = null , $ localKey = null )
50
52
{
51
53
// Check if it is a relation with an original model.
52
- if (! is_subclass_of ($ related , \Jenssegers \Mongodb \Eloquent \Model::class)) {
54
+ if (!is_subclass_of ($ related , \Jenssegers \Mongodb \Eloquent \Model::class)) {
53
55
return parent ::morphOne ($ related , $ name , $ type , $ id , $ localKey );
54
56
}
55
57
@@ -73,7 +75,7 @@ public function morphOne($related, $name, $type = null, $id = null, $localKey =
73
75
public function hasMany ($ related , $ foreignKey = null , $ localKey = null )
74
76
{
75
77
// Check if it is a relation with an original model.
76
- if (! is_subclass_of ($ related , \Jenssegers \Mongodb \Eloquent \Model::class)) {
78
+ if (!is_subclass_of ($ related , \Jenssegers \Mongodb \Eloquent \Model::class)) {
77
79
return parent ::hasMany ($ related , $ foreignKey , $ localKey );
78
80
}
79
81
@@ -99,7 +101,7 @@ public function hasMany($related, $foreignKey = null, $localKey = null)
99
101
public function morphMany ($ related , $ name , $ type = null , $ id = null , $ localKey = null )
100
102
{
101
103
// Check if it is a relation with an original model.
102
- if (! is_subclass_of ($ related , \Jenssegers \Mongodb \Eloquent \Model::class)) {
104
+ if (!is_subclass_of ($ related , \Jenssegers \Mongodb \Eloquent \Model::class)) {
103
105
return parent ::morphMany ($ related , $ name , $ type , $ id , $ localKey );
104
106
}
105
107
@@ -138,15 +140,15 @@ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relat
138
140
}
139
141
140
142
// Check if it is a relation with an original model.
141
- if (! is_subclass_of ($ related , \Jenssegers \Mongodb \Eloquent \Model::class)) {
143
+ if (!is_subclass_of ($ related , \Jenssegers \Mongodb \Eloquent \Model::class)) {
142
144
return parent ::belongsTo ($ related , $ foreignKey , $ otherKey , $ relation );
143
145
}
144
146
145
147
// If no foreign key was supplied, we can use a backtrace to guess the proper
146
148
// foreign key name by using the name of the relationship function, which
147
149
// when combined with an "_id" should conventionally match the columns.
148
150
if (is_null ($ foreignKey )) {
149
- $ foreignKey = Str::snake ($ relation ). '_id ' ;
151
+ $ foreignKey = Str::snake ($ relation ) . '_id ' ;
150
152
}
151
153
152
154
$ instance = new $ related ;
@@ -225,18 +227,18 @@ public function belongsToMany($related, $collection = null, $foreignKey = null,
225
227
}
226
228
227
229
// Check if it is a relation with an original model.
228
- if (! is_subclass_of ($ related , \Jenssegers \Mongodb \Eloquent \Model::class)) {
230
+ if (!is_subclass_of ($ related , \Jenssegers \Mongodb \Eloquent \Model::class)) {
229
231
return parent ::belongsToMany ($ related , $ collection , $ foreignKey , $ otherKey , $ relation );
230
232
}
231
233
232
234
// First, we'll need to determine the foreign key and "other key" for the
233
235
// relationship. Once we have determined the keys we'll make the query
234
236
// instances as well as the relationship instances we need for this.
235
- $ foreignKey = $ foreignKey ?: $ this ->getForeignKey (). 's ' ;
237
+ $ foreignKey = $ foreignKey ?: $ this ->getForeignKey () . 's ' ;
236
238
237
239
$ instance = new $ related ;
238
240
239
- $ otherKey = $ otherKey ?: $ instance ->getForeignKey (). 's ' ;
241
+ $ otherKey = $ otherKey ?: $ instance ->getForeignKey () . 's ' ;
240
242
241
243
// If no table name was provided, we can guess it by concatenating the two
242
244
// models using underscores in alphabetical order. The two model names
0 commit comments