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