JeffreyWay / Laravel-4-Generators

Rapidly speed up your Laravel workflow with generators
https://packagist.org/packages/way/generators
MIT License
27 stars 9 forks source link

How to create post_id instead of id ? #430

Closed darkcyber closed 9 years ago

darkcyber commented 9 years ago

Hello,

By default this generator will create "id" as primary key in the migration file , then i want to ask how to change "id" with something like "post_id" as primary key , so in the migration file only post_id fields and the other not "id","post_id", and the other ? So is there any way to change default id fields ? or we must change it manually in the migration file ?

Thanks.

andrewhood125 commented 9 years ago

I don't have a solid answer for you if it's possible but I will say that it goes against convention. Typically this would be a foreign key referencing post . id. You're probably going to need to change the $primaryKey variable in your Post.php model as well.

Don't know your level with php or laravel but I would strongly suggest sticking with the standards so in the future people can help you and mitigate any possible problems before they occur. Good luck.

idhamperdameian commented 9 years ago

"id" is default Laravel primary key convention, if you want change to other, you may define a primaryKey property to override the convention.

darkcyber commented 9 years ago

@idhamperdameian Thanks, i just need to create fields for primary key then define in model files for $primaryKey.