vendredi 13 juillet 2018

Laravel routes continue url slug

I don't know how to make 1 route display url/something, and the next route display url/something/anotherthing

Right now except the third route everything works fine. It displays the url/company_name and it shows a view with another list of links. I want when I click one link to pass $table_name, $company_name to the next view but I also want the url to be url/company_name/table_name.

I have this in my home.blade that display some links:

@foreach($companies as  $data)                   
<a href="" class="btn btn-primary" >

</a>
@endforeach

When I click the link in controller I have this:

   public function index($company_name) {
        $tables = DB::connection($company_name)->table('tables')->get();
        return view('apps.welcome', compact('tables', 'company_name'));
    } 

and this is my apps.welcome.blade view:

        <div class="card-body">
            @csrf
            @foreach($tables as  $data)                   
            <a href="" class="btn btn-primary" >
                
            </a>
            @endforeach

And this are my web routes :

Route::get('/home', 'HomeController@index')->name('home');
Route::get('/{company_name}', 'Apps\WelcomeController@index')->name('show_tables');
Route::get('{company_name}/{table_name}', 'Apps\SetupController@index')->name('choose_table');

I'm getting this error:

Missing required parameters for [Route: choose_table] [URI: {company_name}/{table_name}]. (View: apps.welcome.blade)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire