Comments (9)
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 = \App\Article::create($input);
To:
$article = new \App\Article();
$article->category_id = $input['category_id'];
$article->author = ........
..... etc.
It think that it has something to do with Laravel Eloquent.
from eloquent-viewable.
How does your migration file looks like?
from eloquent-viewable.
public function up()
{
Schema::create('articles', function (Blueprint $table) {
$table->increments('id');
$table->integer('category_id')->index();
$table->string('author')->default('admin');
$table->string('title');
$table->text('excerpt');
$table->text('body');
$table->string('slug');
$table->string('feature_image')->default('test.jpg');
$table->timestamps();
});
}
from eloquent-viewable.
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
https://stackoverflow.com/questions/43186521/laravel-5-4-field-doesnt-have-a-default-value
https://stackoverflow.com/questions/39301589/laravel-5-3-creating-models-returns-field-doesnt-have-a-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.
from eloquent-viewable.
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.
from eloquent-viewable.
What happens if you turn strict mode off in your database config file?
from eloquent-viewable.
I have tried it already.That way It just creates id, timestamps and a column with default value. rest are all empty.
from eloquent-viewable.
Changed the code as you said and it worked like charm!
Thank you for your time and effort.
from eloquent-viewable.
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.
from eloquent-viewable.
Related Issues (20)
- give point to post author on unique post view HOT 1
- how can I get user post view count HOT 1
- how to get total number of views of all posts HOT 1
- Getting Column not found when using ->orderByViews() HOT 10
- Laravel 9 support HOT 6
- `touch` the parent timestamp if the view has been recorded HOT 3
- Error : Cannot record a view for a viewable type HOT 1
- How to add some fields to table views HOT 1
- cannot record new views instance HOT 2
- Is there a way to record a view on cyrildewit / eloquent-viewable with the user_id not just the viewable_id HOT 1
- local.ERROR: Undefined index: lifetime_in_minutes
- Class "Period" not found HOT 2
- How can I check if an auth user or a visitor has already viewed a post? HOT 4
- Laravel 10 Support HOT 2
- PHP 8.2 support HOT 2
- CyrildeWit\EloquentViewable\Views::forViewable(): Argument #1 ($viewable) must be of type HOT 1
- How to extend the package to also count other things HOT 2
- User show the post twice HOT 1
- [Question] Seperate records by type
- Sort OutType Error:
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eloquent-viewable.