• 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/GrandSon.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\GetCollection;
19
use ApiPlatform\Metadata\Link;
20
use Illuminate\Database\Eloquent\Model;
21
use Illuminate\Database\Eloquent\Relations\BelongsTo;
22

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

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

45
    private ?string $name = null;
46

47
    private ?GrandFather $grandfather = null;
48

49
    public function grandfather(): BelongsTo
50
    {
NEW
51
        return $this->belongsTo(GrandFather::class, 'grand_father_id', 'id_grand_father');
×
52
    }
53
}
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