Home > OS >  Too few arguments to function App\Http\Controllers\Home\ClientLogoController::EditClientImage()
Too few arguments to function App\Http\Controllers\Home\ClientLogoController::EditClientImage()

Time:08-29

I am using Laravel 9 and I am getting this error I tried various methods to fix this issue but I'm stuck on this . Please help me.

Here is my code:

@php($i=1)
@foreach($client_image as $item)
    <tr>
        <td>{{ $i   }}</td>
        <td>
            <img style="width:60px;height:50px;" src="{{ asset($item->client_logo_images) }}"/>
        </td>
        <td>
            <a href="{{ route('edit.client.logoimage',$item->id) }}">
                <i ></i>
            </a> 
            <a  href="">
                <i ></i>
            </a>
        </td>
    </tr>
@endforeach

I have passed Id with the route and capture. Here is the code. :-

Route::get('/edit/client/image/{id}','EditClientImage')->name('edit.client.logoimage');

And this is my controller code .

public function EditClientImage($id) {
    $client_logo=ClientLogoImage::findOrFail($id);
    return view('admin.home.edit_client',compact('client_logo'));
}

and an error is showing in line 51. This is my line 51. public function EditClientImage($id) and I am redirecting it to edit_client Here is the code for edit_client 

<form method="post" action="{{ route('update.client.image') }}" enctype="multipart/form-data">   
    @csrf
    <input name="id" type="hidden" value="{{ $client_logo->id }}"  >
    <div >
        <div >
            <h3 >Edit Profile</h3>
        </div>
        <div >
            <div >
            <div >
                <label for="formFile" >Profile Image Upload</label>
                <input name="client_image" id="image"  type="file" >
            </div>
        </div>
        <button  type="submit">Update</button>
    </div>
    
</form>

Thank You

CodePudding user response:

<a href="{{ route('edit.client.logoimage', ['id' => $item->id]) }}">

You need to name it as id...

CodePudding user response:

the problem is with the way you are using name routing:

  1. if you are using routed names you need to pass the parameter the same as the route:
Route::get('/edit/client/image/{id}','EditClientImage')>name('edit.client.logoimage');

in this, you have the id parameter and your link have to be as:

<a href="{{ route('edit.client.logoimage', ['id' => $item->id]) }}">
    <i ></i>
</a> 

the other way you can use is just use the URL:

<a href="{{ url('/edit/client/image/' . $item->id) }}">
    <i ></i>
</a> 
  • Related