Route /$id logic cant access parent table data

ok i want to create route like showing data in another page like this

http://localhost:8000/uraian/1

my route like this

Route::get('/uraian/{id}', [PengadaanController::class, 'uraian'])->name('uraian');

i can access this and its normal . now its my livewire function

<?php

namespace App\Http\Livewire;

use Livewire\WithPagination;

use App\Models\Kegi;

use App\Models\Uraian;

use Livewire\Component;

class UraianLw extends Component

{

    use WithPagination;
       public $uraianid ,$kegiatan_id ,$kode_rekening ,$uraian ,$anggaran ;

    public $isOpen = 0;

    public $search = '';


    public function render($id)

    {

        $kegiatan = Kegi::findOrFail($id);

        $newid = $kegiatan->id ;

        

        return view('livewire.uraian-lw',[

            'uraian' => Uraian::where('id' ,$newid)->where('uraian', 'like', '%'.$this->search.'%')->paginate(10)

        ]);

    }
}

and have error

Unable to resolve dependency [Parameter #0 [ $id ]] in class App\Http\Livewire\Uraian

i think i’m wrong , how i can solved this ?

You need to declare a public property with the same name as in your route parameter and set it at mount.

For example:

public $id;

And then create this method:

public function mount($id)
{
$this->id = $id;
}

In your render method:

public function render()
{
$kegiatan = Kegi::findOrFail($this->id);

}