php - Unable to insert into PostgreSQL using laravel eloquent ORM -


i did research lot before posting this.

i getting following error when trying insert record postgresql using laravel eloquent orm.

this error:

illuminate \ database \ queryexception  sqlstate[42703]: undefined column:  7 error: column "id" not exist line 1: ...ed_at", "created_at")  values ($1, $2, $3, $4)  returning "id" ^ (sql: insert "fb_post_like_counts" ("post_id", "count", "updated_at", "created_at") values (293843523498_10152007721598499, 0, 2014-03-12 16:56:24, 2014-03-12 16:56:24) returning "id") 

this database table create schema:

schema::create('fb_post_shares_counts', function($table) {     //     $table->string('post_id');     $table->string('count')->default(0);      //  created_at updated_at deleted_at     $table->timestamps();     $table->softdeletes();      // set composite keys        $table->primary(array('post_id', 'updated_at')); }); 

and code trying execute:

// save post shares $post_share_count   =   new fbpostsharecount; $post_share_count->post_id   =  $response['id']; $post_share_count->count    =   $fql_post['share_count'];        $post_share_count->save(); 

and created model class fbpostsharecount extends eloquent.

i know laravel not support complex keys problem did not occur when using mysql

set primary key in fbpostsharecount model

class fbpostsharecount extends eloquent {      protected $primarykey = 'post_id';      ... } 

Comments