php - 将数据从控制器传递到模态
问题描述
我正在尝试从数据库表中获取数据并将其传递给模式,但它表示我传入的数组未定义。这是我的控制器:
public function displayLocNotesForModal() {
$notesLoc = Note::all();
return view('/components/callCenter/modalLocNotes', ['notesLoc' => $notesLoc]);
}
这是我的路线:
Route::get('/components/callCenter/modalLocNotes', 'App\Http\Controllers\CallCenter\NoteController@displayLocNotesForModal');
这是我的模态:
<div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">
<h3 class="text-lg leading-6 font-medium text-gray-900" id="modal-headline">
Location #{{ $title }} Notes
</h3>
<div class="mt-2">
<p class="text-sm leading-5 text-gray-500">
{{-- {{ $slot }} --}}
@foreach($notesLoc as $notes)
@if($notes == $title)
works
@endif
@endforeach
</p>
</div>
</div>
解决方案
我认为应该如下所示,假设 components 文件夹在您的resources/views
文件夹中
return view('components.callCenter.modalLocNotes', ['notesLoc' => $notesLoc]);
还提供了文档Laravel 嵌套视图目录的链接
推荐阅读
- cypress - 即使页面存在,赛普拉斯超时
- javascript - 类型 {properties .....} 不可分配给类型 ActionReducer
NGRX 角 12 - python - pyomo中变量之间除法的线性化
- python - 创建/循环通过不同的文件夹和保存文件
- flutter - 在颤振中使用 textFormField
- php - 在 MySQL 中查询单个列中的多个值
- flutter - 如何根据天气条件显示图标。我做了大部分代码,在结束部分需要帮助
- c# - 在 C# 中的选定文本位置之前和之后插入 HTML TAG
- dependency-injection - NestJS 在守卫中注入服务
- arrays - 如何摆脱这个简单的 SwiftUI 错误?