小编Kev*_*vin的帖子

Laravel动态下拉国家和州

我正在尝试制作两个下拉菜单.这些是我的数据库中的国家/地区和州选择.我的问题是不知道如何制定国家必须依赖国家的条件.当我选择[countryname]时,它会在我的下拉列表中给出不同的州名称选择.到目前为止我到目前为止所做的工作.

AdminController.php

public function user_register()
    {
        $countryname = DB::table('countries')
            ->get();
        $statename = DB::table('states')
            ->get();

        $title = ucwords(Lang::get('constants.user') . ' ' . Lang::get('constants.register')); 
        return View::make('register.user_register')
            ->with('title', $title)
            ->with('page', 'user_register')
            ->with('countryname', $countryname)
            ->with('statename', $statename)
    }
Run Code Online (Sandbox Code Playgroud)

user_register.blade.php

<select class="form-control" id="countries" name="countries">
    <option value="">Please select</option>
        <?php foreach ($countryname as $key=>$countryname): ?>
        <option value="<?php echo $countryname->sortname; ?>"<?php
         if (isset($countries) && Input::old('countries') == $countryname->sortname) 
         {
             echo 'selected="selected"';
         }
         ?>>
         <?php  echo $countryname->sortname ." - ". $countryname->name  ; ?>
    </option>
    <?php endforeach; ?>
</select>


<select class="form-control" id="states" …
Run Code Online (Sandbox Code Playgroud)

php mysql database laravel dropdown

9
推荐指数
2
解决办法
2万
查看次数

Docker:错误无法启动服务 nginx:OCI 运行时创建失败

我正在为 nginx 服务使用 docker-compose,这里是docker-compose.yml文件:

version: '3'

networks:
  laravel:


services:
  nginx:
    image: nginx:stable-alpine
    container_name: nginx
    networks:
      - laravel
    ports:
      - "8088:80"
    volumes:
      - ./src:/var/www/html
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - php
      - mysql


  mysql:
    image: mysql:5.7.22
    container_name: mysql
    restart: unless-stopped
    tty: true
    ports:
      - "4306:3306"
    volumes:
      - ./mysql:/var/lib/mysql
    environment:
      MYSQL_DATABASE: homestead
      MYSQL_USER: root
      MYSQL_PASSWORD: secret
      MYSQL_ROOT_PASSWORD: secret
      SERVICE_TAGS: dev
      SERVICE_NAME: mysql
    networks:
      - laravel

  php:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: php
    volumes:
      - ./src:/var/www/html
    ports:
        - "9000:9000"
    networks:
      - laravel …
Run Code Online (Sandbox Code Playgroud)

nginx laravel docker

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

laravel ×2

database ×1

docker ×1

dropdown ×1

mysql ×1

nginx ×1

php ×1