我是laravel的新手,我试图将数据从视图传递到控制器,但却出现了一些错误。我搜索过但没有得到如何解决这个问题。请查看我的代码,并告诉我哪里错了?
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.
答案 0 :(得分:2)
将此行添加到routes.php
:
Route::post("savess", "DemoController@savess");