mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 10:07:12 +00:00
* fix(pivot): only use unique classes in the pivot union (Fixes #1606) * composer fix-style --------- Co-authored-by: laravel-ide-helper <[email protected]>
48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Pivot\Models;
|
|
|
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Pivot\Models\Pivots\CustomPivot;
|
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Pivot\Models\Pivots\DifferentCustomPivot;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ModelWithPivot extends Model
|
|
{
|
|
public function relationWithCustomPivot()
|
|
{
|
|
return $this->belongsToMany(ModelwithPivot::class)
|
|
->using(CustomPivot::class)
|
|
->as('customAccessor');
|
|
}
|
|
|
|
|
|
public function relationWithDifferentCustomPivot()
|
|
{
|
|
return $this->belongsToMany(ModelwithPivot::class)
|
|
->using(DifferentCustomPivot::class)
|
|
->as('differentCustomAccessor');
|
|
}
|
|
|
|
// without an accessor
|
|
|
|
public function relationCustomPivotUsingSameAccessor()
|
|
{
|
|
return $this->belongsToMany(ModelwithPivot::class)
|
|
->using(CustomPivot::class);
|
|
}
|
|
|
|
public function relationCustomPivotUsingSameAccessorAndClass()
|
|
{
|
|
return $this->belongsToMany(ModelwithPivot::class)
|
|
->using(CustomPivot::class);
|
|
}
|
|
|
|
public function relationWithDifferentCustomPivotUsingSameAccessor()
|
|
{
|
|
return $this->belongsToMany(ModelwithPivot::class)
|
|
->using(DifferentCustomPivot::class);
|
|
}
|
|
}
|