laravel-api-generator icon indicating copy to clipboard operation
laravel-api-generator copied to clipboard

specify table key different from id

Open kirchaj opened this issue 9 years ago • 2 comments

Is there a way to generate the scaffold on a table that does not have ID as the key? It seems that it assumes that it must be there and does not recognize the real key.

kirchaj avatar Sep 04 '15 18:09 kirchaj

@kirchaj you can use Generator From Existing Tables to generate views which will create CRUD, but then you need to do changes based on your primary keys in your repository and controller.

mitulgolakiya avatar Sep 13 '15 05:09 mitulgolakiya

@kirchaj I have made a simple adjustment when you use "--fromTable" option, the generator will get the first field the table and use it like primary key, putting the (public $primaryKey = "first_field_id";) on the Eloquent Model. Also will use the primary key in the Views (before this change was hard coded with "id").

edermartins avatar Sep 20 '15 21:09 edermartins