I am beginner in Laravel. I have a question and I have no idea how to do this. In create.blade.php in area, when I click a name of a campus in a dropdownbox, the next dropdown would shown the buildings of the campus selected in a dropwdown, and the third dropdown would shown the number of floors of its buildings.
My mockup for the areas create.blade.php
Here are my database:
Campus
Schema::create('campuses', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->text('address');
$table->timestamps();
});
Buildings
Schema::create('buildings', function (Blueprint $table) {
$table->increments('id');
$table->integer('campus_id')->unsigned();
$table->string('name');
$table->integer('floor');
$table->foreign('campus_id')->references('id')->on('campuses');
$table->timestamps();
});
Area
Schema::create('areas', function (Blueprint $table) {
$table->increments('id');
$table->integer('campus_id')->unsigned();
$table->integer('building_id')->unsigned();
$table->string('floor');
$table->foreign('campus_id')->references('id')->on('campuses');
$table->foreign('building_id')->references('id')->on('buildings');
$table->timestamps();
});
Screenshots of Data
Campus
Buildings
Areas
For the adding the floors, in the buildings it indicate as integers for no. of floor. I just want to have a for loop and assign an array so that it can select in area as 1st, 2nd, 3rd, and so on. Thank you it would be a big help if you can answer this but I will still to figure out how to do this.
In area table add one column name as floor_val only contain integer value like 1,2 instead of 1st , 2nd and use that in dropdown of floor option value.