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