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

conedevelopment / root / 13086943877

01 Feb 2025 08:35AM UTC coverage: 79.285% (+1.2%) from 78.037%
13086943877

push

github

web-flow
Merge pull request #234 from xHeaven/patch-1

Codebase health checkup

195 of 239 new or added lines in 45 files covered. (81.59%)

2 existing lines in 2 files now uncovered.

2572 of 3244 relevant lines covered (79.28%)

35.8 hits per line

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

4.76
/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())
×
NEW
37
                ->withRelatableQuery(
×
NEW
38
                    fn (Request $request, Builder $query, MorphPivot $model): Builder => $this->resolveRelatableQuery($request, $model->pivotParent)
×
NEW
39
                        ->unless($this->allowDuplicateRelations, fn (Builder $query): Builder => $query->whereNotIn(
×
40
                            $query->getModel()->getQualifiedKeyName(),
×
41
                            $this->getRelation($model->pivotParent)->select($query->getModel()->getQualifiedKeyName())
×
NEW
42
                        )))
×
NEW
43
                ->hydrate(function (Request $request, MorphPivot $model, mixed $value): void {
×
NEW
44
                    $model->setAttribute(
×
NEW
45
                        $this->getRelation($model->pivotParent)->getRelatedPivotKeyName(),
×
NEW
46
                        $value
×
NEW
47
                    );
×
NEW
48
                })->display(fn (Model $model): ?string => $this->resolveDisplay($model)),
×
UNCOV
49
        ];
×
50
    }
51
}
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