Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sameed_editz's avatar

Please help me how i can fix this error, im new to livewire

Illuminate\Contracts\Container\BindingResolutionException Unable to resolve dependency [Parameter #0 [ $data ]] in class App\Livewire\BlogAdd

my blogAdd component

my blade component

i want to add the tags value whenever a tag is selected then add that tag value in $tag like a array

0 likes
4 replies
Snapey's avatar

you seem to not be passing data to the updateTag event. Check in javascript if the event is being fired with null data

sameed_editz's avatar

@Snapey i found the answer i was passing the wrong parameter

old:

$wire.dispatch('updateTag', { tag: selectedOptions });

as im using $data here as variable

public function updateTag($data)
    {
        dd($data);
        $this->tag = array_unique($data['tag']);
    }

i should also use in js of blade component also like this

$wire.dispatch('updateTag', { data: selectedOptions });
frankhosaka's avatar

I'm new in LiveWire, too. I tried to run your code with routes >web.php

<?php
use App\Http\Controllers\BlogAdd;
use Illuminate\Support\Facades\Route;

Route::middleware(['auth','verified'])->group(function()
{
	Route::get('blog',[BlogAdd::class,'render']);
});

app>Http>Controllers>BlogAdd.php

<?php
namespace App\Http\Controllers;
use App\Models\Category;
use App\Models\Tag;
class BlogAdd 
{
	public $thumbnail;
	public $categories;
    public $tags;
	public function render()
    {
        $this->categories=Category::all();
        $this->tags=Tag::all();
        return view('livewire.blog-add',[
            'thumbnail'=>$this->thumbnail,
            'categories'=>$this->categories,
            'tags'=>$this->tags]);
    }

Please or to participate in this conversation.