thekordy / ticketit

A simple helpdesk tickets system for Laravel 5.1+ which integrates smoothly with Laravel default users and auth system, demo is available at: http://ticketit.kordy.info/tickets
MIT License
875 stars 387 forks source link

Getting an error when trying to create a new input field on create ticket #548

Open Coffeline opened 4 years ago

Coffeline commented 4 years ago

I have a very complicated problem here. I followed the tutorial on the issue #454.

  1. Publish views so you can edit the html layout of the form: php artisan vendor:publish

Publishing the view and adding the new input field was easy, here is what i added: {!! CollectiveForm::text('address', null, ['class' => 'form-control', 'required' => 'required']) !!} Capturar2

  1. Create a migration that extends the table ticketit with fields you want.

And on phpmyadmin, i made this: Capturar And it has its own index too, just like the "subject" one.

  1. Override TicketsController so that in the store method you can add the functionality to store extra fields. This is how to override a vendor class (read the comments too): https://stackoverflow.com/a/34600074

I created the overrides folder and added the "autoload" thing into composer.json

Now for the problem im having:

When i try to submit the new ticket, i get this error: SQLSTATE[HY000]: General error: 1364 Field 'address' doesn't have a default value (SQL: insert into ticketit (subject, content, html, priority_id, category_id, status_id, user_id, agent_id, updated_at, created_at) values (TEST SUBJECT, TEST DESC,

TEST DESC

, 1, 1, 1, 1, 1, 2020-01-29 19:01:41, 2020-01-29 19:01:41))

And if i add a default value to "address" on phpmyadmin, or if i make it nullable, it will be an empty field or the default value i set.

Basically, the "address" data is not being sent to the database, and i have no idea why.

Coffeline commented 4 years ago

By the way, this is what is in my TicketsController's store method: Capturar

AhmedAlEssam commented 4 years ago

try to add 'address' to fillable in the ticket model \kordy\ticketit\src\Models\Ticket.php like this protected $fillable = ['address'];