New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create new article throwing up category_id doesn't have a default value #16
Comments
How does your migration file looks like? |
|
I found some articles that are maybe related to your problem. https://laravel.io/forum/08-08-2015-eloquent-create-says-column-has-no-default-value I'm currently on vacation, using a public computer with a weird keyboard. I will be back in a week. I'm sorry. I personally don't think it has something to do with this package, but I will of course take a look at it. I suggest you to keep searching for an answer. See you then. |
Every thing is working fine normally. But when I add "use HasPageVisitsCounter;" in the model it is throwing error and only showing category_id error even when the data is coming to the controller.I have used dd() to dump if the data is coming to the controller just before create($input) and it dumped all. The moment it is run with "use HasPageVisitsCounter;" it appears. I have checked your code but unable to narrow down the problem. Thank you for the links.Appreciate you taking time to reply. Will try to sort it out ASAP and update. |
What happens if you turn strict mode off in your database config file? |
I have tried it already.That way It just creates id, timestamps and a column with default value. rest are all empty. |
This threat is quite interesting: https://laravel.io/forum/08-08-2015-eloquent-create-says-column-has-no-default-value Try to change this: $article = new \App\Article();
$article->category_id = $input['category_id'];
$article->author = ........
..... etc. It think that it has something to do with Laravel Eloquent. |
Changed the code as you said and it worked like charm! |
Maybe a little bit late but a while ago @LuisNeighbur created a pull request that probably fixed this issue. I forgot to pass the fillable attributes in the constructor function. |
It is not taking lots of other fields like title,body and others. It is working fine if i comment out the below
use HasPageVisitsCounter;
error:
SQLSTATE[HY000]: General error: 1364 Field 'category_id' doesn't have a default value (SQL: insert into
articles
(updated_at
,created_at
) values (2017-08-16 12:05:23, 2017-08-16 12:05:23))controller:
Article Model:
Do not know where the issue is.
The text was updated successfully, but these errors were encountered: