A
A
Anonymous Anonymous2019-07-05 16:44:10
Laravel
Anonymous Anonymous, 2019-07-05 16:44:10

How to set custom date to NULL in laravel?

In migration:
$table->timestamp('date_of'); // дата выдачи
I tried to set ->nullable() and ->default(NULL)
All the same, it adds the current date with time to the database.
Even changed to string. Maybe in the controller you need to set the date to null when adding an entry to the database?
When adding an order, the date must be empty, because the order has not been issued yet. And when editing, the date of issue is put.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Zhuk, 2019-07-05
@freelance_money

The correct option for migrating timestamp for a field that can be NULL:
If this approach still sets the date, you need to look at what values ​​are passed from the controller, it is also possible that the mutator for this field is triggered.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question