sandervanhooft / laravel-invoicable

Easy invoice creation for Laravel
https://www.sandervanhooft.com/blog/laravel/stop-creating-your-laravel-invoices-manually/
MIT License
146 stars 38 forks source link

Invoicable_id should not be null #19

Closed RyonMB closed 5 years ago

RyonMB commented 5 years ago

Detailed description

I got a bug when I wanted to create a new Order: Integrity constraint violation: 1048 Column 'invoicable_id' cannot be null (SQL: insert into invoices (invoicable_id, invoicable_type, currency, status, reference, updated_at, created_at)

It happens when I am using this: $invoice = $order->invoices()->create([]);

Your environment

Using laravel 5.8 with php 7.3

sandervanhooft commented 5 years ago

Can you share the output of dd($order->all())?

janmaarten commented 5 years ago

This happens when you outright just follow the example. When you get an eloquent model, like $order = Order::findOrFail(1) or something, you'll get a proper invoice.