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