dwijitsolutions / laraadmin

LaraAdmin is a Open source Laravel Admin Panel / CMS which can be used as Admin Backend, Data Management Tool or CRM boilerplate for Laravel with features like Advanced CRUD Generation, Module Manager, Backups and many more.
http://laraadmin.com
MIT License
1.57k stars 537 forks source link

How to link tables #145

Open vanessa-joyce opened 7 years ago

vanessa-joyce commented 7 years ago

First congratulations to your awesome work!

I started a few days ago implementing a new webplatform based on Laravel and discovered your backend solution yesterday. So I tried to migrate my solution to use LaraAdmin, but a few questions are still open:

When I wrote my migrations directly in Laravel, i could set a foreign key like this: $table->integer('user_id')->unsigned(); $table->foreign('user_id')->references('id')->on('users');

The migrations generated by LaraAdmin (I make a new model without existing table) do not allow to set a foreign key but instead I found the following advice in your issues:

You can use @locations as poup_values. This will create foreign key linking automatically. https://github.com/dwijitsolutions/laraadmin/issues/135

When I try to add this to a migration generated by LaraAdmin:

[ "colname" => "user_id", "label" => "User ID", "field_type" => "Integer", "unique" => false, "defaultvalue" => [""], "minlength" => 0, "maxlength" => 256, "required" => false, "listing_col" => false, "popup_vals" => "@users", ]

it does not work. Could you please give me some advice on how to implement this? My application consists of many tables with relation to other tables and therefore this is very important for me.

Thank you very much

cerelli commented 7 years ago

I have same question