Category : pivot

I have a following configuration: ClassGroupDate model class ClassGroupDate extends Model { use HasFactory; protected $table = ‘class_group_dates’; protected $primaryKey = ‘id’; public function employees(){ return $this->belongsToMany(Employee::class, ’employee_class_group_date’,’class_group_date_id’, ’employee_id’) ->withPivot([‘replaced_by_employee_id’]) ->using(EmployeeClassGroupDates::class); } Employee model class Employee extends Model { use HasFactory; protected $table = ’employees’; protected $primaryKey = ‘id’; public function class_group_dates(){ return $this->belongsToMany(ClassGroupDate::class, ’employee_class_group_date’, ..

Read more

I have done much research about this but I can’t fetch the pivot table as I want. I want to just fetch the measurement value from the pivot table-like structure you can see. Please check my all details first then you know what I want to show. Model MeasurementPart.php public function customers(){ return $this->belongsToMany(Customer::class, ‘customer_measurements’, ..

Read more

Is it possible to eager load a relationship for a an already eager loaded pivot model? I tried to put this in my ContactEvent pivot model: protected $with = [‘tags:id,title’];, but it’s not loading it when I run this in my Event model: public function contacts(): BelongsToMany { return $this->belongsToMany(Contact::class)->withPivot(‘response’)->using(ContactEvent::class); } Any way I can ..

Read more

I’m fairly now to using Pivot tables, and Many to Many relations overall, so hopefully I can learn what the issue. I have a many to many relation between beers and beer lists, and I have a custom pivot table: Schema::create(‘beer_list_pivot’, function (Blueprint $table) { $table->id(); $table->foreignId(‘beer_id’)->constrained(); $table->foreignId(‘list_id’)->constrained(); }); And the relations are looking like ..

Read more