mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
* feat(pivot): add support for multiple pivot types when using the same accessor
* composer fix-style
* changelog
* resolve namespaces
* Revert "resolve namespaces"
This reverts commit 37559ab089.
* resolve namespaces
---------
Co-authored-by: laravel-ide-helper <[email protected]>
42 lines
1.2 KiB
PHP
42 lines
1.2 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 relationWithDifferentCustomPivotUsingSameAccessor()
|
|
{
|
|
return $this->belongsToMany(ModelwithPivot::class)
|
|
->using(DifferentCustomPivot::class);
|
|
}
|
|
}
|