As far as invoice type maybe a simple added field of type would work. I don't usually like enum, but that could work too. To me a varchar type with a drop down selection is easier.
Just suggestion.
Hello everyone,
I'm really racking my brains trying to get this to work with no avail. None of the relationships described in the Laravel docs seem to work in my case and experimentation isn't going well.
I have the following models: Invoice, Order, Purchase and Storage. An Invoice may have many Orders, Purchases or Storages associated. But each Order, Purchase or Storage may belong to one Invoice only.
It seems to me that I should be using some sort of polymorphic pivot table:
Schema::create('items', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('invoice_id');
$table->string('itemable_type');
$table->unsignedBigInteger('itemable_id');
$table->timestamps();
$table->unique(['itemable_type', 'itemable_id']);
$table->foreign('invoice_id')
->references('id')
->on('invoices')
->onDelete('cascade');
});
But I have no idea how to set up the relationships. Any help would be really appreciated.
Please or to participate in this conversation.