0

im using Laravel-Backpack. could we parse some param from view to backpack controller? imagine i have some list of a package. each package has 5 round so every package has 5 button in its row. when i click first button(round 1) it will open the list of item that has round_id = 1.

what can i think is each round button in package list will parse id to route that will call backpackCrud Controller. and that id will used for advance queries for the item list

my button

<a href="{{ url($crud->route.'/'.'round/1'}}" class="btn btn-xs btn-primary btn-flat"  title="Delete"><i>2</i></a>

my route

CRUD::resource('package/round/{RoundId}', 'Admin\CrudController');

my crud controller

$round= \Route::current()->parameter('RoundId');

$this->crud->addClause('where', 'round', '=', $round);

but it return an error

Route pattern "/admin/package/round/{RoundId}/{{RoundId}}" cannot reference variable name "RoundId" more than once.

what i know is we cannot parse param to restfull controller cause restfull is for quick crud. so what should i do for parse id from view to controller. or maybe there is beautifull way to make the queries? i trully appreciate that

Many thanks!

Frasaccordi
  • 29
  • 1
  • 4

1 Answers1

2

i found the way to avoid that.

it CANNOT be like:

CRUD::resource('package/round/{RoundId}', 'Admin\CrudController');

we have to follow the pattern of the default route like

CRUD::resource('someRoute/{someId}/someSecondRoute{someSecondId}', 'Admin\CrudController');

with that way, we can get the first and second paramater in controller with this:

$firstParam= \Route::current()->parameter('someID');
$SecondParam= \Route::current()->parameter('someSecondID');

hope this help someone else ;)

Frasaccordi
  • 29
  • 1
  • 4