@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | protected function assumeForeignKey($related): string |
| 235 | 235 | { |
| 236 | - return Str::snake((new $related())->getResponseKey()).'_id'; |
|
| 236 | + return Str::snake((new $related())->getResponseKey()) . '_id'; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | public function getOrderByDirectionParameter(): string |
| 365 | 365 | { |
| 366 | - return $this->orderByDirectionParameter ?? $this->getOrderByParameter().'desc'; |
|
| 366 | + return $this->orderByDirectionParameter ?? $this->getOrderByParameter() . 'desc'; |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | /** |
@@ -390,20 +390,20 @@ discard block |
||
| 390 | 390 | |
| 391 | 391 | // If have an id, then put it on the end |
| 392 | 392 | if ($this->getKey()) { |
| 393 | - $path .= '/'.$this->getKey(); |
|
| 393 | + $path .= '/' . $this->getKey(); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | // Stick any extra things on the end |
| 397 | - if (! is_null($extra)) { |
|
| 398 | - $path .= '/'.ltrim($extra, '/'); |
|
| 397 | + if (!is_null($extra)) { |
|
| 398 | + $path .= '/' . ltrim($extra, '/'); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - if (! empty($query)) { |
|
| 402 | - $path .= '?'.http_build_query($this->convertBoolToString($query)); |
|
| 401 | + if (!empty($query)) { |
|
| 402 | + $path .= '?' . http_build_query($this->convertBoolToString($query)); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | // If there is a parentModel & not have an id (unless for nested), then prepend parentModel |
| 406 | - if (! is_null($this->parentModel) && (! $this->getKey() || $this->isNested())) { |
|
| 406 | + if (!is_null($this->parentModel) && (!$this->getKey() || $this->isNested())) { |
|
| 407 | 407 | return $this->parentModel->getPath($path); |
| 408 | 408 | } |
| 409 | 409 | |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | { |
| 422 | 422 | $relation = $this->{$method}(); |
| 423 | 423 | |
| 424 | - if (! $relation instanceof Relation) { |
|
| 424 | + if (!$relation instanceof Relation) { |
|
| 425 | 425 | $exception_message = is_null($relation) |
| 426 | 426 | ? '%s::%s must return a relationship instance, but "null" was returned. Was the "return" keyword used?' |
| 427 | 427 | : '%s::%s must return a relationship instance.'; |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | |
| 434 | 434 | return tap( |
| 435 | 435 | $relation->getResults(), |
| 436 | - function ($results) use ($method) { |
|
| 436 | + function($results) use ($method) { |
|
| 437 | 437 | $this->setRelation($method, $results); |
| 438 | 438 | } |
| 439 | 439 | ); |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | $model = (new $related([], $this->parentModel))->setClient($this->getClient()); |
| 475 | 475 | |
| 476 | 476 | return (new Collection($given))->map( |
| 477 | - function ($attributes) use ($model, $reset) { |
|
| 477 | + function($attributes) use ($model, $reset) { |
|
| 478 | 478 | return $model->newFromBuilder($reset ? reset($attributes) : $attributes); |
| 479 | 479 | } |
| 480 | 480 | ); |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | */ |
| 580 | 580 | public function offsetExists($offset): bool |
| 581 | 581 | { |
| 582 | - return ! is_null($this->getAttribute($offset)); |
|
| 582 | + return !is_null($this->getAttribute($offset)); |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | /** |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | try { |
| 662 | - if (! $this->isDirty()) { |
|
| 662 | + if (!$this->isDirty()) { |
|
| 663 | 663 | return true; |
| 664 | 664 | } |
| 665 | 665 | |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | */ |
| 705 | 705 | public function saveOrFail(): bool |
| 706 | 706 | { |
| 707 | - if (! $this->save()) { |
|
| 707 | + if (!$this->save()) { |
|
| 708 | 708 | throw new UnableToSaveException(); |
| 709 | 709 | } |
| 710 | 710 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function __call(string $name, array $arguments) |
| 163 | 163 | { |
| 164 | - if (! isset($this->parentModel) && array_key_exists($name, $this->rootModels)) { |
|
| 164 | + if (!isset($this->parentModel) && array_key_exists($name, $this->rootModels)) { |
|
| 165 | 165 | return $this->newInstanceForModel($this->rootModels[$name]); |
| 166 | 166 | } |
| 167 | 167 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @throws NoClientException |
| 183 | 183 | * @throws TokenException |
| 184 | 184 | */ |
| 185 | - public function __get(string $name): Collection|Model|null |
|
| 185 | + public function __get(string $name): Collection | Model | null |
|
| 186 | 186 | { |
| 187 | 187 | return match (true) { |
| 188 | 188 | $name === 'agent' => $this->newInstanceForModel(Agent::class) |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | $name === 'user' => $this->newInstanceForModel(User::class) |
| 192 | 192 | ->get(extra: 'me') |
| 193 | 193 | ->first(), |
| 194 | - ! $this->parentModel && array_key_exists($name, $this->rootModels) => $this->{$name}() |
|
| 194 | + !$this->parentModel && array_key_exists($name, $this->rootModels) => $this->{$name}() |
|
| 195 | 195 | ->get(), |
| 196 | 196 | default => null, |
| 197 | 197 | }; |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | * @throws NoClientException |
| 231 | 231 | * @throws TokenException |
| 232 | 232 | */ |
| 233 | - public function get(array|string $properties = ['*'], ?string $extra = null): Collection|Model |
|
| 233 | + public function get(array | string $properties = ['*'], ?string $extra = null): Collection | Model |
|
| 234 | 234 | { |
| 235 | 235 | $properties = Arr::wrap($properties); |
| 236 | 236 | |
@@ -266,11 +266,11 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | public function getModel(): Model |
| 268 | 268 | { |
| 269 | - if (! isset($this->class)) { |
|
| 269 | + if (!isset($this->class)) { |
|
| 270 | 270 | throw new InvalidRelationshipException(); |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - if (! isset($this->model)) { |
|
| 273 | + if (!isset($this->model)) { |
|
| 274 | 274 | $this->model = (new $this->class([], $this->parentModel))->setClient($this->client); |
| 275 | 275 | } |
| 276 | 276 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * @throws NoClientException |
| 297 | 297 | * @throws TokenException |
| 298 | 298 | */ |
| 299 | - public function find(int|string $id, array|string $properties = ['*']): Model |
|
| 299 | + public function find(int | string $id, array | string $properties = ['*']): Model |
|
| 300 | 300 | { |
| 301 | 301 | return $this->whereId($id) |
| 302 | 302 | ->get($properties) |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | * |
| 319 | 319 | * @throws InvalidRelationshipException |
| 320 | 320 | */ |
| 321 | - public function limit(int|string $count): self |
|
| 321 | + public function limit(int | string $count): self |
|
| 322 | 322 | { |
| 323 | 323 | return $this->where('count', (int) $count); |
| 324 | 324 | } |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | * |
| 404 | 404 | * @throws InvalidRelationshipException |
| 405 | 405 | */ |
| 406 | - public function page(int|string $number, int|string|null $size = null): self |
|
| 406 | + public function page(int | string $number, int | string | null $size = null): self |
|
| 407 | 407 | { |
| 408 | 408 | return $this->where('page_no', (int) $number) |
| 409 | 409 | ->when($size, fn (self $b): self => $b->paginate($size)); |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | * |
| 415 | 415 | * @throws InvalidRelationshipException |
| 416 | 416 | */ |
| 417 | - public function pageinate(int|string|null $size = null): self |
|
| 417 | + public function pageinate(int | string | null $size = null): self |
|
| 418 | 418 | { |
| 419 | 419 | return $this->paginate($size); |
| 420 | 420 | } |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | * |
| 425 | 425 | * @throws InvalidRelationshipException |
| 426 | 426 | */ |
| 427 | - public function paginate(int|string|null $size = null): self |
|
| 427 | + public function paginate(int | string | null $size = null): self |
|
| 428 | 428 | { |
| 429 | 429 | return $this->where('pageinate', true) |
| 430 | 430 | ->when($size, fn (self $b): self => $b->where('page_size', (int) $size)); |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | */ |
| 468 | 468 | public function setClass(string $class): self |
| 469 | 469 | { |
| 470 | - if (! class_exists($class)) { |
|
| 470 | + if (!class_exists($class)) { |
|
| 471 | 471 | throw new ModelNotFoundException(sprintf('The model [%s] not found.', $class)); |
| 472 | 472 | } |
| 473 | 473 | |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | * |
| 492 | 492 | * @throws InvalidRelationshipException |
| 493 | 493 | */ |
| 494 | - public function take(int|string $count): self |
|
| 494 | + public function take(int | string $count): self |
|
| 495 | 495 | { |
| 496 | 496 | return $this->limit($count); |
| 497 | 497 | } |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | * |
| 524 | 524 | * @throws InvalidRelationshipException |
| 525 | 525 | */ |
| 526 | - public function whereId(int|string|null $id): self |
|
| 526 | + public function whereId(int | string | null $id): self |
|
| 527 | 527 | { |
| 528 | 528 | return $this->where($this->getModel()->getKeyName(), $id); |
| 529 | 529 | } |