How can I send data from a view to a controller in laravel 5.0?

I am new to laravel, I am trying to pass data from a view to a controller, but am getting some errors. I searched but did not get how I can solve this problem. Please review my code and let me know where I am going wrong?

demoview.blade.php Code

echo Form::open(array( 'method' => 'post','action' => ' DemoController@savess ')); echo Form::label('name', 'Name'); echo Form::text('name'); echo Form::label('email', 'E-Mail Address'); echo Form::text('email'); echo Form::close(); 

Code DemoController.php

  namespace App\Http\Controllers; use Illuminate\Http\Request; class DemoController extends Controller { /* |-------------------------------------------------------------------------- | Welcome Controller |-------------------------------------------------------------------------- | | This controller renders the "marketing page" for the application and | is configured to only allow guests. Like most of the other sample | controllers, you are free to modify or remove it as you desire. | */ /** * Create a new controller instance. * * @return void */ public function __construct() { $this->middleware('guest'); } /** * Show the application welcome screen to the user. * * @return Response */ public function demofunction() { $users = \DB::table('user')->get(); foreach ($users as $user) { echo $user->name; echo $user->email; } return view('demoview'); } public function savess(){ } } 

Route Code .php

 Route::get('demo', ' DemoController@demofunction '); 

Mistake:

 ErrorException in compiled.php line 8658: Action App\Http\Controllers\ DemoController@savess not defined. (View: E:\xampp\htdocs\ayaz\resources\views\demoview.blade.php) InvalidArgumentException in compiled.php line 8658: Action App\Http\Controllers\ DemoController@savess not defined. 
+7
php laravel
source share
1 answer

Add this line to routes.php :

 Route::post("savess", " DemoController@savess "); 
+2
source share

All Articles