outl1ne / nova-notes-field

This Laravel Nova package adds a notes field to Nova's arsenal of fields.
MIT License
51 stars 36 forks source link

Create notes inside a job #58

Closed rpahmadmasri closed 1 year ago

rpahmadmasri commented 1 year ago

I am having a problem with creating notes manually. Basically, I am trying to seed data into the database and execute it as a job every x minutes or hours. The reason why I want to run it as a job is that I am synchronizing the database based on data I get from an API. The problem now is when I try to create notes in a job as follows Note::create([ 'created_at' => Carbon::parse($comment->created), 'text' => $comment->renderedBody, 'system' => 1, 'notable_type' => 'App\Models\Issue', 'notable_id' => $Issue->id, 'created_by' => $user ]);

I get SQLSTATE[HY000]: General error: 1364 Field 'notable_type' doesn't have a default value (Connection: mysql, SQL: insert into 'nova_notes' ('text', 'system', 'created_by', 'updated_at', 'created_at') values (text, 1, 2, 2023-03-16 21:01:31, 2023-03-16 21:01:31)) however, if I do the same thing as a seeder it works. The error shows that not all fields are being inserted but they are there.

Any idea what the problem could be or am I doing something wrong? I tried to use addNote but it doesn't fulfill my needs

richard-raadi commented 1 year ago

Hi.

Thank you for bringing this to our attention.

I added notable_type and notable_id to be fillable now using Eloquent, you can update your package version to 3.0.4

BR Richard