Coder Social home page Coder Social logo

Comments (9)

cyrildewit avatar cyrildewit commented on May 13, 2024 1

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.

cyrildewit avatar cyrildewit commented on May 13, 2024

How does your migration file looks like?

from eloquent-viewable.

venkatavinash avatar venkatavinash commented on May 13, 2024
    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.

cyrildewit avatar cyrildewit commented on May 13, 2024

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.

venkatavinash avatar venkatavinash commented on May 13, 2024

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.

cyrildewit avatar cyrildewit commented on May 13, 2024

What happens if you turn strict mode off in your database config file?

https://laracasts.com/discuss/channels/laravel/laravel-530-throwing-error-field-test-1-doesnt-have-a-default-value

from eloquent-viewable.

venkatavinash avatar venkatavinash commented on May 13, 2024

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.

venkatavinash avatar venkatavinash commented on May 13, 2024

Changed the code as you said and it worked like charm!
Thank you for your time and effort.

from eloquent-viewable.

cyrildewit avatar cyrildewit commented on May 13, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.