Reputation: 654
I'm new in laravel, i'm trying to pass data from view to controller but getting some errors. I have searched but didn't got how can i solve this issue. Please view my code and advice me where i'm wrong?
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();
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::get('demo', 'DemoController@demofunction');
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.
Upvotes: 7
Views: 2707
Reputation: 8350
Add to routes.php
this line:
Route::post("savess", "DemoController@savess");
Upvotes: 2