(Laravel) Missing required parameter for [Route:] - laravel

I have this issue: and im stuck i dont know what to do
Missing required parameter for [Route: bedrijven.delete] [URI: admin/bedrijven/{bedrijf}/delete] [Missing parameter: bedrijf].
my index page
<td> <a href= {{route('bedrijven.delete', ['bedrijven'=>$bedrijf->id])}}>Verwijder</a> </td>
my controller
{
return view('admin.bedrijven.delete', compact('bedrijf'));
}```
my route
```Route::get('admin/bedrijven/{bedrijf}/delete',[BedrijfController::class, 'delete'])
->name('bedrijven.delete');
Route::resource('/admin/bedrijven', BedrijfController::class);```

Related

Still error display: Missing required parameter

I facing the issue Missing required parameter for [Route: search.customer] [URI: agency/{slug}] [Missing parameter: slug]
Here is below my code
Route::get('/agency/{slug}', [SearchController::class, 'listing'])->name('search.customer');
#if ($agents->isNotEmpty())
#foreach ($agents as $value)
View More
#endforeach
#endif

Error: Ziggy error: 'id' parameter is required for route

I am working on single SPA using laravel and inertia js. I am using multi language as well. So I am passing language as prefix parameter like this.
Route::group(['prefix' => '{language}'],function(){
Route::get('events',[HomeController::class,'event'])->name('events');
Route::get('events-details/{id}',[HomeController::class,'eventDetail'])
->name('events.reservations.index');
});
my controller
public function eventDetail($land,$id)
{
$events = $this->repository->getAllEvents();
$event_details = $this->repository->findById($id);
$time_interval = ReservationHelper::getTimeInterval();
return Inertia::render('Frontend/Pages/Reservation/Index', compact('events','event_details','time_interval'));
}
Calling in vue component like this
<Link
:href="
route('events.reservations.index', [$page.props.current_locale, id])
"
>
<div class="sao-box1 text-center">
<img :src="imgSrc" alt="" class="img-fluid rounded_img" />
<h3>{{ title }}</h3>
<div class="event-description" v-html="description"></div>
<a class="sl-btnBook">Book</a>
</div>
</Link>
when I click on that link I am getting error as
Error: Ziggy error: 'id' parameter is required for route 'events.reservations.index'
I don't know where I am going wrong.
thank you
change this line only from :-
:href="route('events.reservations.index', [$page.props.current_locale, id])"
to :
:href="route('events.reservations.index', {language : $page.props.current_locale, id: id})"
thanks

Missing required parameters for [Route: about]

I installed cviebrock/eloquent-sluggable package.
I have an issue with the URLs i.e., with the hrefs and slug.
menu.blade.php
<a class="nav-link" href="{{ route('about') }}">
web.php
Route::get('content/{contentSlug}', 'PageController#content')->name('about');
RouteServiceProvider.php
Route::bind('contentSlug', function ($value) {
return Page::whereSlug($value)->firstOrFail();
});
I get this error
Illuminate\Routing\Exceptions\UrlGenerationException
Missing required parameters for [Route: about] [URI: en/content/{contentSlug}]. (
This is because you don't pass {contentSlug} value in route.
<a class="nav-link" href="{{ route('about',['contentSlug' =>'Hello']) }}">
If you want to make route with optional parameter then use ? .{contentSlug?}

How to pass multiple arguments with url (routing) in laravel

I am trying to pass argument on route but unfortunatly i am facing error please help me thanks.
Missing required parameters for [Route: products.detail] [URI:
products/{slug}/{id}/details]. (View:
/home/zubair/htdocs/wallmasterfurnishing.com/web/resources/views/wallpapers-product.blade.php)
let detailurl = '{{route("products.detail",[":slug",":id"])}}';
productdetail = detailurl.replace(':slug', element.slug);
productdetail = detailurl.replace(':id', element.id);
<a href="${productdetail}">
<h4 class="prodcardtitle">${element.code} - ${element.name}</h4>
</a>
It seams like you are combining Blade template with Javascript
let detailurl = '{{route("products.detail",[":slug",":id"])}}';
let keywords is part of JavaScript
and {{ route("products.details", [$element->slug, $element->id] }} is only available inside of blade template
As you are inside of javascript and not in blade template you should create the url using template literals and replace all placeholder with the the related value like this
let detailurl = `/products/${element.slug}/${element.id}/details`;
`<a href="${productdetail}">
<h4 class="prodcardtitle">${element.code} - ${element.name}</h4>
</a>`
You can pass multiple parameter to route as an array
<a href="{{ route('products.detail', ['slug' => $slugVariable, 'id' => $idVariable]) }}">
<h4 class="prodcardtitle">${element.code} - ${element.name}</h4>
</a>
for more info visit
Thanks
try with route name :
Route::get('products/{slug}/{id}/details','ProductController#productDetail')->name('productDetail');
<a href="{{ route('productDetail', ['laptop-slug','2']) }}">
<h4 class="prodcardtitle">${element.code} - ${element.name}</h4>
</a>

How to check which controller data object being executed?

I have faced a typical problem. The problem is which controller data object being executed in view page. Here the data object is $items. I have looked most of controller but can not find data object $items . Please help me to find it. Thank in advance. The portion of view page :
#foreach($items as $item)
<div class="partner-logo">
<div class="inner-div red-box">
<p>
<img src="{{ ($item->image) ? asset('file/images/' . $item->image) : "" }}" alt="" />
</p>
<h3>
<a
href="{{ isset($item->url) ?route('page.content.show', $item->url) : "#" }}"> {{ $item->title }}
</a>
</h3>
</div>
</div>
#endforeach
In Laravel, controllers usually pass their data to views in this format:
return view('nameOfView', [
'firstParam' => $firstParam,
'secondParam' => $secondParam,
'etc' => $etc
]);
So you can search in your controllers for the view name and then for the parameter name (in this case $items). If there are multiple controller functions with the $items param and the same view, add a test param to each and see which one your view renders. You can also check in routes/web.php for the current URL you are on, and find the correct controller function that way.

Resources