So I have custom primary keys and I am not sure If I need to define the incrementation in both eloquent and migrations?
class Question extends Model
{
protected $primaryKey = 'que_id';
protected $keyType = 'tinyInteger';
public $autoincrement = true;
}
public function up()
{
Schema::create('questions', function (Blueprint $table) {
$table->tinyInteger('que_id')->autoIncrement();
$table->timestamps();
});
}
Or it is just enough to define it like this?
public function up()
{
Schema::create('questions', function (Blueprint $table) {
$table->tinyInteger('que_id')->primary();
$table->timestamps();
});
}
Model:
$keyType
supports int[eger]
and string
$autoincrement
property, it's called $incrementing
.Migration:
tinyInteger()
etc. is $autoIncrement = false
.$autoIncrement
, you don't need and can't use ->primary()
(at least on MySQL).