当用户登录或注册时,他应该去仪表板,但不是它,它位于/ login页面,甚至不存在,因此出现错误:
抱歉,找不到您要查找的页面。
1/1 RouteCollection.php第161行中的NotFoundHttpException:
路线:
Route::get('/', function () {
return view('welcome');
})->name('home');
Route::group(['middleware' => ['web']], function(){
Route::get('upload',function(){
return view('files.upload');
});
Route::get('/wallet',[
'uses' => 'WalletController@getwallet',
'as' => 'wallet'
]);
Route::post('/addmoney',[
'uses' => 'WalletController@addmoney',
'as' => 'addmoney'
]);
Route::post('/signup',[
'uses' => 'UserController@postSignUp',
'as' => 'signup'
]);
Route::post('/signin',[
'uses' => 'UserController@postSignIn',
'as' => 'signin'
]);
Route::get('/dashboard',[
'uses' => 'UserController@getDashboard',
'as' => 'dashboard',
'middleware' => 'auth'
]);
Route::post('/handleUpload','FilesController@handleUpload');
Route::get('/pay', ['as' => 'pay', 'uses' => 'PaymentController@pay']);
# You will need one more.
Route::get('/payment/status', ['as' => 'payment_status', 'uses' => 'PaymentController@status']);
/**
* Using Named Routs to demonstrate all the possibilities.
*/
});
用户控制器:
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Input;
use InvalidConfirmationCodeException;
use Flash;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Mail;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class UserController extends Controller
{
public function getDashboard(){
return view('files.dashboard');
}
public function postSignUp(Request $request)
{
$this -> validate($request,[
'email' => 'required|email|unique:users',
'name' => 'required|max:20',
'password' => 'required|min:4'
]);
$email = $request['email'];
$name = $request['name'];
$password = bcrypt($request['password']);
$user = new User();
$user->email =$email;
$user->name = $name;
$user->password = $password;
$user->save();
return redirect()->route('dashboard');
//Auth::login($user);
}
public function postSignIn(Request $request)
{
$this -> validate($request,[
'email' => 'required',
'password' => 'required'
]);
if (Auth::attempt(['email' => $request['email'], 'password' => $request['password']])) {
return redirect()->route('dashboard');
}
return redirect()->back();
}
}
WalletController
public function getwallet(){
return view('files.wallet');
}
public function addmoney(Request $request){
$this->validate($request,[
'amount'=>'required'
]);
$amount = $request['amount'];
$wallet = new Wallet();
$wallet->amount=$amount;
$wallet->save();
return redirect()->route('/addmoney');
}
即使我尝试localhost:8000 / dashboard,它也会加载为localhost:8000 / login,因为显示相同的错误。同样,当我尝试加载/ addmoney页面时,当用户提交金额和重定向时出现同样的问题到下一个addmoney页面。
答案 0 :(得分:0)
我看到您的仪表板视图视图位于file.controller中,但您使用的是auth中间件。将仪表板视图放在auth文件夹的仪表板视图中。
Laravel中的默认值:resources/views/auth/yourviewhere