php - Laravel 5.5 下拉框
问题描述
我是 Laravel 的初学者。我有一个问题,我不知道该怎么做。在 area 的 create.blade.php 中,当我在下拉框中单击某个校区的名称时,下一个下拉菜单会显示下拉菜单中选择的校区的建筑物,第三个下拉菜单会显示其建筑物的楼层数。
我的区域模型 create.blade.php
这是我的数据库:
校园
Schema::create('campuses', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->text('address');
$table->timestamps();
});
建筑物
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();
});
区域
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();
});
数据截图
校园
建筑物
领域
对于添加楼层,在建筑物中它表示为整数。的地板。我只想有一个 for 循环并分配一个数组,以便它可以在区域中选择第一个、第二个、第三个等。谢谢你,如果你能回答这个问题,那将是一个很大的帮助,但我仍然会弄清楚如何做到这一点。
解决方案
在区域表中添加一列名称作为 floor_val 仅包含整数值,例如 1,2 而不是 1st , 2nd 并在 floor 选项值的下拉列表中使用它。
推荐阅读
- python - 使用 re.split() 拆分多个值的字符串
- javascript - 如何在 webpack 中处理编译后的 Vue 组件?
- java - 导入 org.springframework.mail 无法解析
- pip - 在 macOS 10.15 上安装“fastai”时出现问题
- android - 有许多选项的复选框
- python - 如何通过命令行限制 Python 脚本的内存使用量?
- c# - 如何使用视图插入、更新和删除数据
- kubernetes - Datadog 代理错误:无法从提供程序 docker 收集配置:dockerutil 中的临时故障
- listview - 将边距底部添加到 NativeScript 中的最后一个 ListView 项
- python - 如何使用 Web URL 调用/运行 Python 脚本?