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.56k stars 538 forks source link

One To Many Relation #172

Open mustafa-qamaruddin opened 7 years ago

mustafa-qamaruddin commented 7 years ago

Hello,

I noticed when I add field as Drop Down / Multi-select, then choose values from Table Source. The one to many relationship is implemented by adding a column to the table with type varchar. Then, lara admin generator only fills the cell with array of ids of related fields from foreign table.

I wonder how to normalize this kind of auto generated relation to a new separate table without affecting Lara Admin auto generated validations / views, etc.????

razzul commented 7 years ago

Hi, can you please guide me how to do one to many relation here.

I have courses module and books module, and now I am trying to build relation so I have added in the couse migration file like this.

 ["books", "Books", "Multiselect", false, [0], 0, 0, false, "@books"],
class CreateCoursesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Module::generate("Courses", 'courses', 'name', 'fa-cube', [
            ["name", "Name", "Name", true, "", 5, 250, true],
            ["teacher", "Teacher", "String", false, "", 0, 256, true],
            ["fees", "Fees", "Currency", false, "0", 0, 2, true],
            ["description", "Description", "Textarea", false, "", 0, 1000, false],
            ["books", "Books", "Multiselect", false, [0], 0, 0, false, "@books"],
        ]);

While doing php artisan migrate:refresh

Getting error Class CreateBooksTable not found