laravel5.4 中的未定义变量
undefined variable in laravel5.4
我正在尝试从数据库中获取值并将其显示在下拉列表中..当我尝试这个时我得到了这个错误未定义的变量用户类型..我不明白错误在哪里..我是新手laravel 框架..
这是我的控制器:
public function get() {
$usertype = DB::table('user_type')->get();
return View::make('/home')->with(compact('user_type'));
return $usertype;
}
这是我的视图下拉列表:
<div class="form-group">
<label for="cat">User Type</label>
<select class="form-control" name="user_type_id">
@foreach($usertype as $user)
<option id="user_type_Id" value="{{$user->id}}" selected="selected">{{ $user->type }}</option>
@endforeach
</select>
</div>
谁能帮帮我..
尝试更改紧凑函数中的变量名
public function get() {
$usertype = DB::table('user_type')->get();
return View::make('/home')->with(compact('usertype'));
return $usertype;
}
并删除第二个 return 语句,因为它永远不会执行。
我正在尝试从数据库中获取值并将其显示在下拉列表中..当我尝试这个时我得到了这个错误未定义的变量用户类型..我不明白错误在哪里..我是新手laravel 框架..
这是我的控制器:
public function get() {
$usertype = DB::table('user_type')->get();
return View::make('/home')->with(compact('user_type'));
return $usertype;
}
这是我的视图下拉列表:
<div class="form-group">
<label for="cat">User Type</label>
<select class="form-control" name="user_type_id">
@foreach($usertype as $user)
<option id="user_type_Id" value="{{$user->id}}" selected="selected">{{ $user->type }}</option>
@endforeach
</select>
</div>
谁能帮帮我..
尝试更改紧凑函数中的变量名
public function get() {
$usertype = DB::table('user_type')->get();
return View::make('/home')->with(compact('usertype'));
return $usertype;
}
并删除第二个 return 语句,因为它永远不会执行。