samedi 6 avril 2019

How to make simple dynamic drop list in laravel?

I'm new at Laravel and not good with syntax. I have seen many tutorials and have read many answers but still my mind didn't get the point of how can I have dropdown field for foreign key.

I'm having one table "Section" and other "Class". I want to show name of classes in section page.

Section (Migration):

    Schema::create('sections', function (Blueprint $table) {
        $table->increments('id');
        $table->string('title');
        $table->integer('class_id')->unsigned();
        $table->foreign('class_id')->references('id')->on('classses');

    });

Honestly, I don't know if I should have change my controller or not.

In blade Page:

<div class="form-group">
                <label for="Name">Name</label>
                <input type="text" class="form-control" name="name" id="title">
            </div>

            <div class="form-group">
                <label for="cid">Class</label>
                ???????????????
            </div>

Thankyou in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire