Skip to content
Advertisement

ArgumentCountError Too few arguments to function 0 passed and exactly 1 expected in Laravel

I’m trying to update a record in my laravel application

In my app management blade I have a link to a single record

<a href="{{ route('activities.index',$app->appId) }}" class="btn btn-warning"> Activate</a>   

So once the user clicks on the link user will sent to a update record blade which is at

views/activities/index.blade.php

I have a controller called, ActivateController.php in my controllers where I have written my functions related to the update.

Now in that controller I have an index function,

public function index($id)
    {
        //echo $id;
        $datas = Website::WHERE('appId','=',$id);
        return view('activities.index',compact('datas'));         
    }

In my Routes/web.php, I have declared my route as follows

Route::get('/activities.index/{id}', 'ActivateController@index')->name('activities.index');

Now I have faces two issues,

1/ I want my url to be like TEST.SITE/activities/12 but currently it shows like TEST.SITE/activities?12

2/ When I tried to access the acivities.index, it gives me an error saying

ArgumentCountError
Too few arguments to function AppHttpControllersActivateController::index(), 0 passed and exactly 1 expected

What I’m doing wrong here and How can I fix above Issues?

Advertisement

Answer

check this if this can help you

{{ url('activities/index/', [$id]) }}

Route :

Route::get('/activities/index/{id}', 'ActivateController@index')->name('activities.index');
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement