控制器 class 未找到 laravel 5.1
Controller class not found laravel 5.1
我是 laravel 的新手,我尝试 post 从视图到控制器的值。但我无法通过,因为我收到错误提示
FatalErrorException in routes.php line 26: Class 'registration' not found
提交表单时
Routes.php
Route::get('/', function () {
return view('welcome');
});
Route::get('/register', function(){
return view('register');
});
Route::post('/register_action', function()
{
$values = registration::store();
});
控制器
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\model\registration as register_model
class registration extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store()
{
echo 'hello';
register_model::saveFormData();
}
}
查看
<html>
<head>
<meta charset="UTF-8">
<title>Registration</title>
</head>
<body>
{!! Form::open(array('url' => 'register_action')) !!}
<p>Name : {!! Form::text('name') !!}</p>
<p>Email : {!! Form::text('email') !!}</p>
<p>Password : {!! Form::password('password') !!}</p>
<p>Confirm Password : {!! Form::password('cpassword') !!}</p>
<p>{!! Form::submit('Submit') !!}</p>
{!! Form::close() !!}
</body>
</html>
请帮助我解决问题并在控制器中获取 post 值。谢谢
路线应如下所示:
Route::post('/register_action', 'registration@store');
如果您需要在路由中调用控制器方法(这是个坏主意),您可以添加一个 use 语句
use App\Http\Controllers\registration;
但它仍然会给你一个错误,因为你正在静态调用一个非静态方法,所以你最好的选择是@Alexey Mezenin
你不能这样使用控制器:
$values = registration::store();
使用需要改变路线。
Route::post('/register_action', 'registration@store');
我是 laravel 的新手,我尝试 post 从视图到控制器的值。但我无法通过,因为我收到错误提示
FatalErrorException in routes.php line 26: Class 'registration' not found
提交表单时
Routes.php
Route::get('/', function () {
return view('welcome');
});
Route::get('/register', function(){
return view('register');
});
Route::post('/register_action', function()
{
$values = registration::store();
});
控制器
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\model\registration as register_model
class registration extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store()
{
echo 'hello';
register_model::saveFormData();
}
}
查看
<html>
<head>
<meta charset="UTF-8">
<title>Registration</title>
</head>
<body>
{!! Form::open(array('url' => 'register_action')) !!}
<p>Name : {!! Form::text('name') !!}</p>
<p>Email : {!! Form::text('email') !!}</p>
<p>Password : {!! Form::password('password') !!}</p>
<p>Confirm Password : {!! Form::password('cpassword') !!}</p>
<p>{!! Form::submit('Submit') !!}</p>
{!! Form::close() !!}
</body>
</html>
请帮助我解决问题并在控制器中获取 post 值。谢谢
路线应如下所示:
Route::post('/register_action', 'registration@store');
如果您需要在路由中调用控制器方法(这是个坏主意),您可以添加一个 use 语句
use App\Http\Controllers\registration;
但它仍然会给你一个错误,因为你正在静态调用一个非静态方法,所以你最好的选择是@Alexey Mezenin
你不能这样使用控制器:
$values = registration::store();
使用需要改变路线。
Route::post('/register_action', 'registration@store');