php - Passing 2 Parameters to Laravel Routes - Resources -


i'm trying build routes using resources can pass 2 parameters resources.

i'll give few examples of how urls look:

domain.com/dashboard domain.com/projects domain.com/project/100 domain.com/project/100/emails domain.com/project/100/email/3210 domain.com/project/100/files domain.com/project/100/file/56968 

so can see need have reference project_id , email/file id etc.

i realize can manually writing routes hand, i'm trying stick resource model.

i figured might work?

route::group(['prefix' => 'project'], function(){   route::group(['prefix' => '{project_id}'], function($project_id){      // files     route::resource('files', 'filecontroller');    }); }); 

as far know resources

route::resource('files', 'filecontroller'); 

the above mentioned resource route following urls.

few actions handled resource controller route::resource('files', 'filecontroller');

route::get('files',filecontroller@index) // req routed index() function in controller route::get('files/{val}',filecontroller@show) // req val routed show() function in controller route::post('files',filecontroller@store) // post req routed store() function in controller route::put('files/{id}',filecontroller@update) // put req id routed update() function in controller route::delete('files',filecontroller@destroy) // delete req routed destroy() function in controller 

the single resource mentioned above listed routing

apart have write custom route

in scenario of

route::group(['prefix' => 'project'], function(){   route::group(['prefix' => '{project_id}'], function($project_id){      // files     route::resource('files', 'filecontroller');    }); });  

domain.com/project/100/files

if get request routed filecontroller@index
if post request routed filecontroller@store

if "domain.com/project/100/file/56968" changed "domain.com/project/100/files/56968" (file files)then following rooting occur...

domain.com/project/100/files/56968

if get request routed filecontroller@show
if put request routed filecontroller@update
if delete request routed filecontroller@destroy

and has no impact on other urls have mentioned

provided, need have restful resource controllers


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -