Ad
404 Not Found Laravel Routing
what's wrong with my routes? it can't redirect to my edit-info form inside InfosController
web.php
route::get('/info-admin/{$info}/edit','[email protected]');
info-admin.blade.php
@foreach ( $info as $infos )
<tr>
<th scope="row" class="align-middle">{{ $loop->iteration }}</th>
<td class="align-middle">{{ $infos->judul }}</td>
<td class="align-middle">{{ $infos->konten }}</td>
<td class="align-middle">{{ $infos->image }}</td>
<td class="align-middle">{{ $infos->created_at }}</td>
<td class="align-middle">{{ $infos->Updated_at }}</td>
<td class="align-middle form">
<a target="_blank" rel="nofollow noreferrer" href="/info-admin/{{ $infos->id }}/edit"><button type="submit" class="btn btn-info mb-3">Edit</button></a>
<form method="POST" action="{{ route('infos.destroy', [$infos->id]) }}">
{{ csrf_field() }}
{{ method_field('DELETE') }}
<button type="submit" class="btn btn-danger">Hapus</button>
</form>
</td>
</tr>
@endforeach
public function edit($id)
{
return view('admin.edit-info');
}
what did I do wrong, why laravel can't find my routes?
Ad
Answer
You route is defined wrong.
route::get('/info-admin/{$info}/edit','[email protected]');
Should be without $
and name the route for easier linking.
route::get('/info-admin/{info}/edit','[email protected]')->name('infos.edit');
Instead of hard coding it, use route as you do with destroy on the edit link too.
<a target="_blank" rel="nofollow noreferrer" href="{{ route('infos.edit', [$infos->id]) }}">
To check if you routes are defined correctly, try running in the project.
php artisan route:list
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms
Ad