Laravel 5.2与PostgreSQL自动增量无法正常工作,必须填写id

时间:2016-07-18 02:55:59

标签: php postgresql laravel laravel-5.2

我正在使用PostgreSQL处理Laravel 5.2,插入时出错:

QueryException in Connection.php line 713:
  SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "id" violates not-null constraint
  DETAIL: Failing row contains (null, null, t, 11, null, null, null, null, null, null, null, null, 5, null, null, 1, null, 1, null, null, null, 1, null, 1, null, null, null, bla bla bakar bakar, null, null, 00000000469, 33, bla bladfs, TEST KEDUAAAA, null, null, null, null, null, null, null, null, 45, 1, null, null, null). (SQL: insert into "produk_m" ("statusenabled", "kdproduk", "namaproduk", "kodeexternal", "kdproduk_intern", "objectdetailjenisprodukfk", "objectkategoryprodukfk", "objectgolonganprodukfk", "objectstatusprodukfk", "objectsatuankecilfk", "qtysatukemasan", "qtyterkecil", "kekuatan", "deskripsiproduk") values (1, 00000000469, TEST KEDUAAAA, 11, 33, 5, 1, 1, 1, 1, 45, 1, bla bladfs, bla bla bakar bakar) returning "id")

我必须填写id值;自动增量不起作用,

我的模型是这样的:

<?php
    namespace App\Master;

    use Illuminate\Database\Eloquent\Model;

    class Produk extends Model
    {
        protected $table ="produk_m";
        protected $fillable = ['statusenabled','kdproduk','namaproduk','kodeexternal', 'kdproduk_intern','objectdetailjenisprodukfk','objectkategoryprodukfk','objectgolonganprodukfk','objectstatusprodukfk','objectstatusprodukfk','objectsatuankecilfk','qtysatukemasan','qtyterkecil','kekuatan','deskripsiproduk'];
        public $timestamps = false;
        protected $primaryKey = 'id';
        // protected $guarded = array('id');
        public $incrementing = true;
    }

如何解决此问题?

0 个答案:

没有答案