Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel tables removid id column

Tags:

php

laravel

Is that possible to remove id column from laravel tables?

Example

In my settings table I really don't need id column there will be basic columns and data 1 row only, maximum user will edit them so nothing to add(store).

Explanation

My question is about model binding

  1. for eg. when we remove timestamps we'll add public $timestamps = false; should we do the same for id?
  2. Since it's increment will cause error then or not? https://laracasts.com/discuss/channels/laravel/laravel-migration-removing-incrementsid-makes-table-un-updatable
like image 474
mafortis Avatar asked Sep 14 '25 00:09

mafortis


1 Answers

You can try that in your migration.

Schema::table('table', function (Blueprint $table) {

    $table->dropPrimary('id');
    $table->integer('id')->unsigned()->change();
});
like image 99
Kaleem Avatar answered Sep 16 '25 14:09

Kaleem