Hello @spawn2k,
As also mentioned in the stack overflow post you need to explicitly define your local and foreign key in both the relationships because you are not using the default id
column for referencing.
So, your relationships should be defined as:
on the PizzaPrice model
public function pizza(): BelongsTo
{
return $this->belongsTo(Pizza::class, 'pizza_id','pizza_id');
}
on the pizzas model
public function pizzaPrice(): HasOne
{
return $this->hasOne(PizzaPrice::class, 'pizza_id','pizza_id');
}
Thanks
spawn2k, salahedarhri liked this reply
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community