6

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

4
  • What is the id on vuejs component? try debugging that with vue dev tools Commented Nov 29, 2021 at 9:04
  • ID is there. I can able to see but when I am clicking on that I am getting this error Commented Nov 29, 2021 at 9:27
  • if you run php artisan route:list, how does the url in question look like from that output? Commented Nov 29, 2021 at 9:49
  • its coming like this {language}/events-details/{id} Commented Nov 29, 2021 at 10:04

2 Answers 2

5

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

Sign up to request clarification or add additional context in comments.

Comments

0

in your home controller event class. Check to see if you included "id" in the select in the query.

Eg., select('*') or select('id','eventname','eventdate')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.