[App \ Http \ Controllers \ UserController]上不存在[postSignin]方法。 我试图在表单中创建登录。注册有效,但是当我登录时,我收到此错误。 我现在收到Parse错误:语法错误,意外&#39 ;;',期待','或者'
这是我的路线:
Auth::routes();
Route::get('/', function () {
return view('welcome');
})->name('home');
Route::post('/signup', [
'uses' => 'UserController@postSignUp',
'as' => 'signup'
]);
Route::post('/signin', [
'uses' => 'UserController@postSignIn',
'as' => 'signin'
]);
Route::get('/dashboard', [
'uses' => 'UserController@getDashboard',
'as' => 'dashboard'
]);
我的控制器:
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
UserController中:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Auth\Authenticatable;
class UserController extends Controller
{
public function getDashboard()
{
return view('dashboard');
}
public function postSignUp(Request $request)
{
$email = $request['email'];
$first_name = $request['first_name'];
$password = bcrypt($request['password']);
$user = new User();
$user->email = $email;
$user->first_name = $first_name;
$user->password = $password;
$user->save();
Auth::login($user);
return redirect()->route('dashboard');
}
public function postSignIn(Request $request)
{
if (Auth::attempt(['email' => $request['email'], 'password' => $request['password']])) {
return redirect()->route('dashboard');
}
return redirect()->back();
}
public function method(Request $req)
{
dd($req->all();
}
}
我的刀片:
<form action="{{ route('signin') }}" method="post">
我做错了什么?
答案 0 :(得分:1)
yum install php-process
在您的App \ Http \ Controllers \ UserController中添加如下
route::post('signin','UserControllerr@method')->name('signin');