Ad
Laravel5.7 Routing Using Route:match Not Working
I'm using Laravel 5.7 I'm trying to route my function for get and post. I want to load a view and post a form. As I have studied
Route::match(['GET','POST'], '/', [email protected]);
Route::any('/', [email protected]);`
one of these should work.
But its not working for me,is there any other way or I'm doing something wrong?
UPDATE
Route to admin:
Route::match(['get','post'], 'cp/', '[email protected]');
Function in Admin controller:
public function test( Request $request){
$data=array();
if ($request->isMethod('POST')) {
echo "here it is";
exit;
}else{
echo "still in get!";
}
return view('admin/login', $data);
}
And my view in short is something like this:
<form action="{{ url('/cp') }}" method="POST">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<form>
Ad
Answer
Can you try changing
Route::match(['GET','POST'], '/', [email protected]);
to
Route::match(['GET','POST'], '/', '[email protected]');
OR
Route::any('/', [email protected]);
to
Route::any('/', '[email protected]');
The second param should be wrapped in quotes!
UPDATE:
Your route match code should be something like this :
Route::match(array('GET', 'POST', 'PUT'), "/", array(
'uses' => '[email protected]',
'as' => 'index'
));
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