• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

conedevelopment / root / 18216690222

03 Oct 2025 08:07AM UTC coverage: 76.331% (-0.7%) from 77.022%
18216690222

push

github

iamgergo
fixes

14 of 61 new or added lines in 2 files covered. (22.95%)

1 existing line in 1 file now uncovered.

3354 of 4394 relevant lines covered (76.33%)

34.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

6.67
/src/Fields/MorphToMany.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Cone\Root\Fields;
6

7
use Illuminate\Database\Eloquent\Builder;
8
use Illuminate\Database\Eloquent\Model;
9
use Illuminate\Database\Eloquent\Relations\BelongsTo as BelongsToRelation;
10
use Illuminate\Database\Eloquent\Relations\MorphPivot;
11
use Illuminate\Database\Eloquent\Relations\MorphToMany as EloquentRelation;
12
use Illuminate\Http\Request;
13

14
/**
15
 * @extends \Cone\Root\Fields\BelongsToMany<\Illuminate\Database\Eloquent\Relations\MorphToMany>
16
 */
17
class MorphToMany extends BelongsToMany
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function getRelation(Model $model): EloquentRelation
9✔
23
    {
24
        return parent::getRelation($model);
9✔
25
    }
26

27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function fields(Request $request): array
×
31
    {
32
        return [
×
33
            BelongsTo::make($this->getRelatedName(), 'related', static function (Model $model): BelongsToRelation {
×
34
                return $model->belongsTo(
×
35
                    $model::class,
×
36
                    $model->getRelatedKey(),
×
37
                    $model->getForeignKey()
×
38
                )->withDefault();
×
39
            })->withRelatableQuery(function (Request $request, Builder $query, Model $model): Builder {
×
40
                return $this->resolveRelatableQuery($request, $model->pivotParent)
×
41
                    ->unless($this->allowDuplicateRelations, function (Builder $query) use ($model): Builder {
×
42
                        return $query->whereNotIn(
×
43
                            $query->getModel()->getQualifiedKeyName(),
×
NEW
44
                            $this->getRelation($model->pivotParent)
×
NEW
45
                                ->select($query->getModel()->getQualifiedKeyName())
×
NEW
46
                                ->whereNot(
×
NEW
47
                                    $query->getModel()->getQualifiedKeyName(),
×
NEW
48
                                    $model->getAttribute($model->getRelatedKey())
×
NEW
49
                                )
×
50
                        );
×
51
                    });
×
52
            })->hydrate(function (Request $request, MorphPivot $model, mixed $value): void {
×
53
                $model->setAttribute(
×
54
                    $this->getRelation($model->pivotParent)->getRelatedPivotKeyName(),
×
55
                    $value
×
56
                );
×
57
            })->display(fn (Model $model): ?string => $this->resolveDisplay($model)),
×
58
        ];
×
59
    }
60
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc