Hey all,
I am trying to add some note taking functionality to my web app. I'd like it so that when I click the show button next to a client line, it shows more info about them and their notes underneath. I believe I have the indexing and most of the routes sorted, but when I try to store a note, it gives me a $client variable not found error.
How do I pass through the show buttons linked client ID to the note store method so that it saves the note with the correct linked client ID.
Controllers:
Note -
public function store(Request $request)
{
Note::create([
'title' => $request->title,
'description' => $request->description,
'category' => $request->category,
'employee_id' => $request->employee_id,
'client_id' => $request->client_id,
]);
Routes
Route::resource('notes', NoteController::class);
Route::get('/{client}/add-note', [App\Http\Controllers\NoteController::class, 'create'])->name('database.{client}.notes.create');
Route::delete('{client}/notes/{note}',[App\Http\Controllers\NoteController::class, 'destroy'])->name('notes.destroy');
Route::get('{client}/notes/{note}/edit', [App\Http\Controllers\NoteController::class, 'edit'])->name('database.notes.edit');
Route::get('{client}/notes/{note}/show', [App\Http\Controllers\NoteController::class, 'show'])->name('database.notes.show');
Store method route in view
<form action="{{ route('notes.store', ['client_id'=>$client->id]) }}" method="POST">
Thanks in advance.