Laravel: Pass parameters on routes

Asked

Viewed 972 times

2

I am developing a CMS system, where I choose the component that the user that on your site page.

In this line of code I load the data of the components, this data is coming from a file components.yaml that brings this configuration.

    <div class="list-group">
    @foreach( $components as $component)
        <a href="" class="list-group-item list-group-item-action btn btn-outline-primary">{{ $component->title }} : {{ $component->component }}</a>
    @endforeach
    </div>

inserir a descrição da imagem aqui

At the moment I want to click on a comoponete of that I generate that route: website/{website}/pages/{page}/components/create?componente=page-simpleheader

In case I wanted to know how I pass this parameter in the routes of the Laravel? ?componente=page-simpleheader, on this route I will load the view with the form to register this component on the page.

Routes

        Route::group([
        'as' => 'pages.',
        'prefix' => 'pages/{page}',
        'middleware' => 'managercontext:website_page'
    ], function() {

        Route::resource('components', 'Website\PageContentComponentsController', [
            'only' => ['show', 'create', 'store', 'edit', 'update', 'destroy']
        ]);
    });

1 answer

2


From what I understand you will do by GET just pass the parameters with bar equal to this example:

Route::get('/rota/{parametro1}/{parametro2}', 'MeuController@minhaFuncao')->name('dashboard');

and in the function of the controller would thus receive the parameters.

function minhaFuncao($parametro1, $parametro2){

}

example of route with parameters

localhost:8000/rota/valor1/valor2

Browser other questions tagged

You are not signed in. Login or sign up in order to post.