I am getting the following error while trying to insert into the table users_basics
Illuminate\Database\Eloquent\Model::setAttribute(), 1 passed in C:\xampp\htdocs\msadi\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Concerns\HasAttributes.php on line 592 and exactly 2 expected
Here is my controller code:
public function create()
{
$userId = '10';
$userBasics = new UserBasics;
$userBasics->user_id = $userId;
$userBasics->save();
return redirect('users');
}
Here is my model:
class UserBasics extends Model
{
protected $table = 'users_basics';
protected $primaryKey = null;
protected $fillable = ['user_id'];
const UPDATED_AT = null;
const CREATED_AT = null;
}
Here is my user_basics migration:
public function up()
{
Schema::create('users_basics', function (Blueprint $table) {
$table->integer('user_id');
$table->bigInteger('adhaar_no')->nullable();
$table->string('mobile_no')->nullable();
$table->string('college_roll_no')->nullable();
$table->date('dob')->nullable();
$table->index('user_id');
});
}
I have tried adding UPDATED_AT, CREATED_AT and PrimaryKey to the table but none worked. The user_id is being inserted into the users_basics table but the error continues to show.