Siema, mam pewien problem z routami nie wiem czy ja je jakoś źle rozumiem czy o co chodzi. Dostaję błąd
Missing required parameter for [Route: drinks.update] [URI: drinks/{drink}] [Missing parameter: drink]. (View: C:\Users\User\Desktop\drinks-app\resources\views\profile\drinks\edit.blade.php)
Czemu gdy jestem na url http://127.0.0.1:8000/drinks/5/edit
Krzyczy mi o błąd z drinks.update ?
Wiem , że routy działają z góry na dół i szukają pierwszego dopasowania, ale tutaj chyba nie jest problem z dopasowaniem bo zamieniałem kolejnością i też nie działało.
Wchodzę na linka
<a href="{{ route('drinks.edit', ['drink' => $drink]) }}" class="btn-primary btn">Edit</a>
Route::get('drinks/{drink}/edit',[DrinkController::class,'edit'])->name('drinks.edit');
Route::post('drinks/{drink}', [DrinkController::class,'update'])->name('drinks.update');
Controller
public function edit(Drink $drink)
{
return view('profile.drinks.edit', [
'drink' => $drink
]);
}
profile.drinks.edit/edit.blade.php
@extends('layouts.app')
@section('content')
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form action="{{ route('drinks.update') }}" method="post" enctype="multipart/form-data">
@csrf
<label for="name">Name</label>
<input type="text" id="name" name="name" class="input-group-sm" value="{{ $drink->name }}"/>
<button type="submit" class="btn-primary btn">Create</button>
</form>
@endsection