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

conedevelopment / root / 15084089635

17 May 2025 10:00AM UTC coverage: 77.93% (+0.04%) from 77.891%
15084089635

push

github

web-flow
Modernize back-end.yml (#240)

3291 of 4223 relevant lines covered (77.93%)

36.04 hits per line

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

8.7
/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
9✔
21
    {
22
        return parent::getRelation($model);
9✔
23
    }
24

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