Ad
Can We Connect Laravel Routing Parameter And Controller Parameter?
So I want to fill key but it fill another parameter when inside controller and i see it will fill the first parameter first. Is There Anyway to make key? will go to $key parameter and type? to $type and fill? to $fill too ?
I'm Using Laravel 5.6.*
Route::get('/report', '[email protected]')->name('api.report');
Route::get('/report/all', '[email protected]')->name('api.report.all');
Route::get('/report/all/key/{key?}', '[email protected]')->name('api.report.all.key');
Route::get('/report/all/search/{type?}/{fill?}', '[email protected]')->name('api.report.all.type.fill');
Route::get('/report/all/search/{type?}/{fill?}/key/{key?}', '[email protected]')->name('api.report.all.type.fill.key');
expected result : null null testing /report/all/key/testing
public function all($type = null,$fill = null,$key = null)
{
dd($type.$fill.$key);
}
actual result : testing null null /report/all/key/testing
public function all($type = null,$fill = null,$key = null)
{
dd($type.$fill.$key);
}
Ad
Answer
You could replace the parameters inside all()
and type-hint Illuminate\Http\Request
instead.
Then, you could just do this:
use Illuminate\Http\Request;
public function all(Request $request)
{
$key = $request->key;
$type = $request->type;
$fill = $request->fill;
dd($type.$fill.$key);
}
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms
Ad