Reputation: 11
i'm creating a database for school management in laravel.. i'm stuck in students table where i want to set primary key as "reg_no" column without auto-incrementing and still want the "id" column as auto-incrementing, i tried "protected $primaryKey" and "public $incrementing" but these properties does not solve the problem..
after did this, my db still point "id" column as primary key..
Here are some screen shots:
model:
table/migration:
Database in Xampp:
Upvotes: 0
Views: 497
Reputation: 892
Add this in 'up' method of students migration file
Schema::table('students', function(Blueprint $table) {
// Remove the primary key
$table->dropPrimary("id");
// Set the actual primary key
$table->primary(array("reg_no"));
});
Upvotes: 0