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

api-platform / core / 14380251321

10 Apr 2025 12:19PM UTC coverage: 8.487% (+0.3%) from 8.187%
14380251321

Pull #7075

github

web-flow
Merge 802b308ba into dfca9bf60
Pull Request #7075: fix(laravel): eloquent BelongsTo linking

0 of 70 new or added lines in 7 files covered. (0.0%)

1 existing line in 1 file now uncovered.

13399 of 157884 relevant lines covered (8.49%)

22.86 hits per line

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

0.0
/src/Laravel/workbench/app/Models/GrandFather.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace Workbench\App\Models;
15

16
use ApiPlatform\Metadata\ApiProperty;
17
use ApiPlatform\Metadata\ApiResource;
18
use ApiPlatform\Metadata\Get;
19
use ApiPlatform\Metadata\Link;
20
use Illuminate\Database\Eloquent\Collection;
21
use Illuminate\Database\Eloquent\Model;
22
use Illuminate\Database\Eloquent\Relations\HasMany;
23

24
#[ApiResource]
25
#[ApiResource(
NEW
26
    uriTemplate: '/grand_sons/{id_grand_son}/grand_father',
×
NEW
27
    uriVariables: [
×
NEW
28
        'id_grand_son' => new Link(
×
NEW
29
            fromClass: GrandSon::class,
×
NEW
30
            fromProperty: 'grandfather',
×
NEW
31
            identifiers: ['id_grand_son']
×
NEW
32
        ),
×
NEW
33
    ],
×
NEW
34
    operations: [new Get()]
×
NEW
35
)]
×
36
#[ApiProperty(identifier: true, property: 'id_grand_father')]
37
class GrandFather extends Model
38
{
39
    protected $table = 'grand_fathers';
40
    protected $primaryKey = 'id_grand_father';
41
    protected $fillable = ['name', 'sons'];
42

43
    #[ApiProperty(genId: false, identifier: true)]
44
    private ?int $id_grand_father;
45

46
    private ?string $name = null;
47

48
    private ?Collection $sons = null;
49

50
    public function sons(): HasMany
51
    {
NEW
52
        return $this->hasMany(GrandSon::class, 'grand_father_id', 'id_grand_father');
×
53
    }
54
}
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