php - laravel create omits/skips fields -


i'm trying seed couple of databases laravel seeder, seems skips fields..

i'm doing way:

item::create(array(     'name' => 'category 2',     'photo' => 'description of category 2',     'order' => 1     'price' => 2.30     'category_id' => 1, )); 

the fields 'category_id' , order not setup in database..

i'm calling seeder way

artisan::call('db:seed',array('--database' => 'tenant_'.$user, '--class' => 'tenantseeder')); 

any idea why happen?

if use standard

$item = new item; $item->allfields = "its_value"; $item->save(); 

it works perfectly

update here comes model:

<?php class item extends model {      //============================================================================     // parent variables     //============================================================================     protected $table = "items";      protected $softdelete = true;      protected $hidden = ['created_at','updated_at'];     protected $fillable = ['name','price','description','photo'];   //items can mass assigned     protected $guarded = array('id');      protected static $rules = [         'name'          => 'required|min:3',         'price'         => '',         'description'   => '',     ];      //============================================================================     // methods     //============================================================================     public function getid()         {   return $this->getkey();  }     public function getname()       {   return $this->name;      }     public function getphotosrc()   {   return $this->photo;     }      public function item_category(){         return $this->belongsto('items_category');     }      public function scopeactive($query)     {         return $query->where('active', '=', true);     } } 

and scheme

schema::create('items', function(blueprint $table)         {             // auto increment id (primary key)             $table->increments('id');              $table->string('name')->default('new item');             $table->float('price')->default(0);             $table->string('photo')->nullable();             $table->integer('order')->unsigned();             $table->boolean('active')->default(true);             $table->string('description')->nullable();              $table->integer('category_id')->unsigned();             $table->foreign('category_id')->references('id')->on('items_categories')->ondelete('cascade');              // created_at, updated_at datetime             $table->timestamps();             $table->softdeletes(); //it not deleted, marked deleted         }); 

any idea?

as user2094178 said, didn't have fields in $fillable


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -