私はモーダルのpicklistフォームを作成したいと思います。ここに私のコントローラは、次のとおりです。未定義の変数:picklistを作成しようとするとき
public function picklist(Request $request)
{
$q = $request->q;
$lists = Customer::where('name', 'like', "%$q%")
->orderBy('name')->paginate('5');
return view('customer._customer_list')
->with('lists', $lists);
}
、これは私はそれが働いたlocalhostの/顧客/リスト を開いたときに、これは私のルート
Route::get('/customer/list/', '[email protected]');
ある
<tbody>
@foreach ($lists as $key => $list)
<tr>
<td>
{{ $list->name }}
</td>
<td>
<button data-dismiss="modal" class="btn btn-warning btn-xs btn-choose"
type="button" data-id="{{ $list->id }}" data-name="{{ $list->name }}">Pilih</button>
</td>
</tr>
@endforeach
</tbody>
</table>
{!! $lists->appends(Request::except('page'))->render() !!}
_customer_list.blade.php図であり、
しかし、このような別のビューに渡そうとすると、
このようなルートの場合 Route :: get( '/ customer/add'、 'CustomerController @ create');
私はエラーを得た:
Undefined variable: lists (View: /srv/web/resources/views/customer/_customer_list.blade.php) (View: /srv/web/resources/views/customer/_customer_list.blade.php)
アイブ試みてきたが、それはまだエラーにundifined変数を与えます。 –
もちろん、** customer._customer_list ** bladeにパラメータを渡さない別のブレードに@include( 'customer._customer_list')を含めると、エラーが発生します。 ** @ include( 'customer._customer_list'、[ 'lists' => 'your list']); ** –
これを試してみると、@section( ' ( 'customer'_customer_list'、['lists' => 'lists "]) @endsection しかし、私は、foreachのために供給されるエラー無効な引数()(閲覧:/srv/web/resources/views/customer/_customer_list.blade.php)を得るので、私は、私は_customer_listに@foreachを削除すると思います –