动态DropDownList使用Laravel 5.1错误类' City'未找到

时间:2015-08-06 12:33:43

标签: php laravel drop-down-menu laravel-5 laravel-5.1

我是laravel的新手,所以请从动态下拉列表中获取帮助......这个项目是在laravel 5.1中创建的。

index.blade.php               

    <div class="cls2">
        <ul>
            <li><label for="state"class="lbl">State</label></li>
            <li>:</li>
            <li><select  name="state" id="state" class="txtb">
                    <option>Select State</option>
                    <?php
                    foreach($State as $state) { ?>
                    <option value="<?= $state['state_id'] ?>"><?=$state['state_name'] ?></option>
                    <?php
                    } ?>
                    </select>
            </li>
        </ul>
    </div>
    <div class="cls2">
        <ul>
            <li><label for="city"class="lbl">City</label></li>
            <li>:</li>
            <li><select  name="city" id="city" class="txtb">
                    <option>Select CIty</option>
                    <?php
                    foreach($City as $city) { ?>
                    <option value="<?= $city['city_id'] ?>"><?= $city['city_name'] ?></option>
                    <?php
                    } ?>
                </select>
            </li>
            </li>
        </ul>
    </div>

</div>
<div class="sub">
    <ul>
        <li></li>
        <li><input type="submit" name="submit" value="Submit" class="btnsub"></li>
    </ul>
</div>
</form>

Route.php

Route::get('/subdropdown',function()
   $state_id = Input::get('subcat_id');  
  $city = City::where('state_id','=',$state_id)->get();
 return Response::json($city);
 });

Route::get('/','Employee@index'); //route for index.blade

Controller Employee.php

public function index()
{
    $state=State::all();
    return view('employee.index')->with('State',$state);
}

Model City.php

class City extends Model
{
  protected $table = 'city';
  protected $fillable = ['city_name','state_id'];

 public function State()
 {
   return $this->belongsTo('State');
 }
}     

Model State.php

class State extends Model
{
  protected $table = 'state';

  protected $fillable = ['state_name'];

public function City()
{
   return $this->hasMany('City');
}
}

错误就像类似城市&#39;在第36行的C:\ xampp \ htdocs \ Registration \ app \ Http \ routes.php中找不到

0 个答案:

没有答案