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

conedevelopment / root / 13076030548

31 Jan 2025 03:44PM UTC coverage: 79.373% (+1.3%) from 78.037%
13076030548

Pull #234

github

web-flow
Merge 9d7378884 into 04cb83a80
Pull Request #234: Codebase health checkup

178 of 217 new or added lines in 45 files covered. (82.03%)

2 existing lines in 2 files now uncovered.

2559 of 3224 relevant lines covered (79.37%)

35.52 hits per line

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

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

3
namespace Cone\Root\Fields;
4

5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Database\Eloquent\Relations\MorphPivot;
8
use Illuminate\Database\Eloquent\Relations\MorphTo as MorphToRelation;
9
use Illuminate\Database\Eloquent\Relations\MorphToMany as EloquentRelation;
10
use Illuminate\Http\Request;
11

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

25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function fields(Request $request): array
29
    {
30
        return [
×
NEW
31
            MorphTo::make($this->getRelatedName(), 'related', static fn (MorphPivot $model): MorphToRelation => $model->morphTo(
×
NEW
32
                'related',
×
NEW
33
                $model->getMorphType(),
×
NEW
34
                $model->getRelatedKey(),
×
NEW
35
                $model->getForeignKey(),
×
NEW
36
            )->withDefault())->withRelatableQuery(fn (Request $request, Builder $query, MorphPivot $model): Builder => $this->resolveRelatableQuery($request, $model->pivotParent)
×
NEW
37
                ->unless($this->allowDuplicateRelations, fn (Builder $query): Builder => $query->whereNotIn(
×
NEW
38
                    $query->getModel()->getQualifiedKeyName(),
×
NEW
39
                    $this->getRelation($model->pivotParent)->select($query->getModel()->getQualifiedKeyName())
×
NEW
40
                )))->hydrate(function (Request $request, MorphPivot $model, mixed $value): void {
×
NEW
41
                    $model->setAttribute(
×
NEW
42
                        $this->getRelation($model->pivotParent)->getRelatedPivotKeyName(),
×
NEW
43
                        $value
×
NEW
44
                    );
×
NEW
45
                })->display(fn (Model $model): ?string => $this->resolveDisplay($model)),
×
UNCOV
46
        ];
×
47
    }
48
}
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

© 2026 Coveralls, Inc