79243592

Date: 2024-12-02 09:58:42
Score: 0.5
Natty:
Report link

Laravel will use the default joins for the pivot table unless you define the model on the relation. So you need to use using() method on relation.

Your code will be like this:

class Car extends Model
{
    /**
     * m:n relation to Tyres
     */
    public function tyres(): BelongsToMany
    {
        return $this->belongsToMany(Tyres::class)->using(CarTyres::class);
    }
}

More details: https://laravel.com/docs/11.x/eloquent-relationships#defining-custom-intermediate-table-models

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
Posted by: TEFO