| @@ 217-237 (lines=21) @@ | ||
| 214 | * @param array $options |
|
| 215 | * @return $this |
|
| 216 | */ |
|
| 217 | public function load($relation, array $options = []) |
|
| 218 | { |
|
| 219 | if (is_array($relation)) { |
|
| 220 | foreach ($relation as $name => $subOption) { |
|
| 221 | if (is_string($subOption)) { |
|
| 222 | //Array of relation names |
|
| 223 | $this->load($subOption, $options); |
|
| 224 | } else { |
|
| 225 | //Multiple relations or relation with addition load options |
|
| 226 | $this->load($name, $subOption + $options); |
|
| 227 | } |
|
| 228 | } |
|
| 229 | ||
| 230 | return $this; |
|
| 231 | } |
|
| 232 | ||
| 233 | //We are requesting primary loaded to pre-load nested relation |
|
| 234 | $this->loader->loader($relation, $options); |
|
| 235 | ||
| 236 | return $this; |
|
| 237 | } |
|
| 238 | ||
| 239 | /** |
|
| 240 | * With method is very similar to load() one, except it will always include related data to |
|
| @@ 312-332 (lines=21) @@ | ||
| 309 | * @param array $options |
|
| 310 | * @return $this |
|
| 311 | */ |
|
| 312 | public function with($relation, array $options = []) |
|
| 313 | { |
|
| 314 | if (is_array($relation)) { |
|
| 315 | foreach ($relation as $name => $options) { |
|
| 316 | if (is_string($options)) { |
|
| 317 | //Array of relation names |
|
| 318 | $this->with($options, []); |
|
| 319 | } else { |
|
| 320 | //Multiple relations or relation with addition load options |
|
| 321 | $this->with($name, $options); |
|
| 322 | } |
|
| 323 | } |
|
| 324 | ||
| 325 | return $this; |
|
| 326 | } |
|
| 327 | ||
| 328 | //Requesting primary loader to join nested relation, will only work for ORM loaders |
|
| 329 | $this->loader->joiner($relation, $options); |
|
| 330 | ||
| 331 | return $this; |
|
| 332 | } |
|
| 333 | ||
| 334 | /** |
|
| 335 | * Fetch one record from database using it's primary key. You can use INLOAD and JOIN_ONLY |
|