Data not saved in database in real after model created

98 Views Asked by At

I am using CREATE method for mass assignment in laravel eloquent, the result also printed and showing, but when i check table in database, no data inserted.

I am using laravel 5.6, It showing successful, but in real no data saved in table.

here is my code

class User extends Authenticatable
{
   use HasApiTokens, Notifiable;

   protected $table = 'users';
   public $primaryKey = 'user_id';
   public $timestamps = false;

   protected $fillable = [
    'first_name','middle_name', 'last_name', 'role_id', 'email', 'mobile', 'telephone'
   ];

.... and other code

Here is my insert function

$users = User::create([
            'first_name'     => $row[1],
            'middle_name'    => $row[2],
            'last_name' => $row[3],
            'email' => $row[4],
            'role_id' => 6,//$row[5],
            'telephone' => $row[6],
            'mobile' => $row[7],

        ]);

        var_dump($users);// this shows result.

$users prints data. There is no error showing. BUT when i check database, table is empty. I expect the same data in users table.

0

There are 0 best solutions below