Это мой контроллер< /strong>
Код: Выделить всё
public function show($id)
{
$mahasiswa = Mahasiswa::with('mataKuliah')->find($id);
$mataKuliah = MataKuliah::all();
if (!$mahasiswa) {
return redirect()->route('daftar-krs')->with('error', 'Student not found');
}
return view('Krs.Index', compact('mahasiswa', 'mataKuliah'));
}
Код: Выделить всё
@include('Template.head')
@include('Template.navbar')
@include('Template.sidebar')
Tambah Kartu Rencana Studi (KRS)
[list]
[*][url={{ route(]Home[/url]
[*]Tambah KRS
[/list]
Input KRS
@if($mahasiswa)
@csrf
Mahasiswa
Pilih Mahasiswa
@foreach($mahasiswa as $m)
{{ $m->name }}
@endforeach
Mata Kuliah
@foreach($mataKuliah as $mk)
{{ $mk->name }}
@endforeach
Nilai
@else
@endif
Data mahasiswa tidak ditemukan.
Simpan
@include('Template.footer')
@include('Template.scripts')
Код: Выделить всё
Route::get('/krs', [KrsController::class, 'index'])->name('daftar-krs');
Route::get('/krs/edit/{id}', [KrsController::class, 'show'])->name('edit-krs');
Route::post('/krs-simpan', [KrsController::class, 'store'])->name('simpan-krs');
ErrorException: попытка прочитать свойство «id» в bool
- Запрос проверен в контроллере, чтобы убедиться в наличии данных.
- Добавлены нулевые проверки в представлении.
Подробнее здесь: https://stackoverflow.com/questions/788 ... data-in-la
Мобильная версия