@@ 143-150 (lines=8) @@ | ||
140 | * |
|
141 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
|
142 | */ |
|
143 | public function hasOne($related, $foreignKey = null, $localKey = null) |
|
144 | { |
|
145 | $foreignKey = $foreignKey ?: $this->getForeignKey(); |
|
146 | $instance = new $related(); |
|
147 | $localKey = $localKey ?: $this->getKeyName(); |
|
148 | ||
149 | return new HasOne($instance->newQuery(), $this, $foreignKey, $localKey); |
|
150 | } |
|
151 | ||
152 | /** |
|
153 | * Define a one-to-many relationship. |
|
@@ 161-168 (lines=8) @@ | ||
158 | * |
|
159 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
160 | */ |
|
161 | public function hasMany($related, $foreignKey = null, $localKey = null) |
|
162 | { |
|
163 | $foreignKey = $foreignKey ?: $this->getForeignKey(); |
|
164 | $instance = new $related(); |
|
165 | $localKey = $localKey ?: $this->getKeyName(); |
|
166 | ||
167 | return new HasMany($instance->newQuery(), $this, $foreignKey, $localKey); |
|
168 | } |
|
169 | } |
|
170 |