Php 在laravel 5.0中,如何将数据从视图发布到控制器?
我是laravel的新手,我试图将数据从视图传递到控制器,但出现了一些错误。我已经搜索了,但没有找到如何解决此问题的方法。请查看我的代码并告诉我哪里错了 demoview.blade.php代码 DemoController.php代码 Routes.php代码 错误:Php 在laravel 5.0中,如何将数据从视图发布到控制器?,php,laravel,Php,Laravel,我是laravel的新手,我试图将数据从视图传递到控制器,但出现了一些错误。我已经搜索了,但没有找到如何解决此问题的方法。请查看我的代码并告诉我哪里错了 demoview.blade.php代码 DemoController.php代码 Routes.php代码 错误: 添加到routes.php此行: Route::post("savess", "DemoController@savess"); 因此,当用户提交表单时,您希望在savess()函数中捕获POST数据?@James yes。。
添加到
routes.php
此行:
Route::post("savess", "DemoController@savess");
因此,当用户提交表单时,您希望在
savess()
函数中捕获POST
数据?@James yes。。
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.
Route::post("savess", "DemoController@savess");