Skip to content

Commit

Permalink
fix phpstan analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
bastien-phi committed Nov 24, 2023
1 parent fbd7c08 commit 36ff96c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Cannot call method getKeyName\\(\\) on Illuminate\\\\Database\\\\Eloquent\\\\Model\\|null\\.$#"
count: 2
path: src/Mixins/CollectionMixin.php

-
message: "#^Cannot call method newModelQuery\\(\\) on Illuminate\\\\Database\\\\Eloquent\\\\Model\\|null\\.$#"
count: 1
path: src/Mixins/CollectionMixin.php

-
message: "#^PHPDoc tag @mixin contains generic class Illuminate\\\\Database\\\\Eloquent\\\\Collection but does not specify its types\\: TKey, TModel$#"
count: 1
Expand Down
9 changes: 5 additions & 4 deletions src/Mixins/CollectionMixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ class CollectionMixin
public function loadAttributes(): Closure
{
return function (Closure $closure): self {
if ($this->isEmpty()) {
$model = $this->first();
if ($model === null) {
return $this;
}

$query = $this->first()->newModelQuery()
$query = $model->newModelQuery()
->whereKey($this->modelKeys())
->select($this->first()->getKeyName());
->select($model->getKeyName());
$query = $closure($query) ?? $query;
$models = $query->get()->keyBy($this->first()->getKeyName());
$models = $query->get()->keyBy($model->getKeyName());

$attributes = Arr::except(
array_keys($models->first()->getAttributes()),
Expand Down

0 comments on commit 36ff96c

Please sign in to comment.