mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 18:13:11 +00:00
feat(pivot): add support for multiple pivot types when using the same accessor
This commit is contained in:
@@ -5,6 +5,7 @@ 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
|
||||
@@ -15,4 +16,26 @@ class ModelWithPivot extends Model
|
||||
->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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user