0
votes

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:

image

table/migration:

image

Database in Xampp:

image

1
Can you add the database migration for the students table? - Rwd
sorry i didn't understand, but both migration table and migrated database to xampp pics are added in my question - waqarfazal92

1 Answers

0
votes

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"));
});