mercredi 8 décembre 2021

Laravel, passing parameters to livewire form view give syntax error

I have this route:

Route::get("/bourse/add/{user}", function (User $user) {
     return view("bourse.new")->with('user', $user);    
})->name("bourse-add");

My new.blade.php file loads the form with livewire. according to the documentation (https://laravel-livewire.com/docs/2.x/rendering-components), I can insert my user id as a parameter like this:

<x-app-layout>
    <x-slot name="header">  </x-slot>
    @livewire('bourse.form', ['id'=> $user->id])
</x-app-layout>

but, however it is functional and the object "bourse" created is well assigned to my user, the comma is refused by IDE and therefore my parameter which comes after.

public function mount($reference = '', $id = null){
     if (!is_null($id)){
          $this->id_user=$id;
     }else{
          $this->id_user = Auth::id();
     }
    ...

have you had this problem and is there any other syntax that is not reported as error?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3ItYqB1
via IFTTT

Aucun commentaire:

Enregistrer un commentaire