This is belongs to
public function packaging()
{
return $this->belongsTo(Packaging::class)
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey I am kind of stuck: I have this migration
Schema::create('product_packagings', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('packaging_id');
$table->foreign('packaging_id')->references('id')->on('packagings');
});
In my ProductPackaging model I have:
public function packaging()
{
return $this->hasOne(Packaging::class)
}
And in my ProductPackaging resource I have
public function fields(NovaRequest $request)
{
return [
ID::make()->sortable(),
HasOne::make('Packaging'),
];
}
Now when I try to create a ProductPackaging I get this error:
Column not found: 1054 Unknown column 'packagings.product_packaging_id' in 'where clause' (SQL: select * from `packagings` where `packagings`.`product_packaging_id` in (0))
And I don't understand why I should have a product_packaging_id in my packagings table. I must be doing something wrong. But don't understand what.
This is belongs to
public function packaging()
{
return $this->belongsTo(Packaging::class)
}
Please or to participate in this conversation.