2016-09-29 2 views
2

Я использую Laravel 5.3 Мой ForgotPasswordController выглядит следующим образом:Приложение класса Http Controllers Auth Request не существует. Laravel 5,3

<?php 

namespace App\Http\Controllers\Auth; 

use App\Http\Controllers\Base\BaseController; 
use Illuminate\Foundation\Auth\SendsPasswordResetEmails; 

class ForgotPasswordController extends BaseController 
{ 

use SendsPasswordResetEmails; 
public function __construct() 
{ 
    $this->middleware('guest'); 
} 
public function showLinkRequestForm() 
{ 
    $title = $this->title; 
    $appName = $this->appName; 
    $action = $this->action; 
    return view('password.forgotPassword')->with(compact('title', 'appName', 'action')); 
} 
} 

ResetPasswordController код:

<?php 

namespace App\Http\Controllers\Auth; 

use App\Http\Controllers\Base\BaseController; 
use Illuminate\Foundation\Auth\ResetsPasswords; 

class ResetPasswordController extends BaseController 
{ 

use ResetsPasswords; 
public function __construct() 
{ 
    $this->middleware('guest'); 
} 

public function showResetForm(Request $request, $token = null) 
{ 
    return view('passwords.resetPassword')->with(
     ['token' => $token, 'email' => $request->email] 
    ); 
} 
public function reset(Request $request) 
{ 
    $this->validate($request, [ 
     'token' => 'required', 
     'password' => 'required|confirmed|min:6', 
    ]); 

    // Here we will attempt to reset the user's password. If it is successful we 
    // will update the password on an actual user model and persist it to the 
    // database. Otherwise we will parse the error and return the response. 
    $response = $this->broker()->reset(
     $this->credentials($request), function ($user, $password) { 
      $this->resetPassword($user, $password); 
     } 
    ); 

    // If the password was successfully reset, we will redirect the user back to 
    // the application's home authenticated view. If there is an error we can 
    // redirect them back to where they came from with their error message. 
    return $response == Password::PASSWORD_RESET 
       ? $this->sendResetResponse($response) 
       : $this->sendResetFailedResponse($request, $response); 
} 

} 

Мой Администратор Маршрут:

Route::group(['namespace' => 'Auth'], function() { 
Route::get('/forgotpassword/reset', '[email protected]'); 
Route::post('/forgotpassword/email', '[email protected]'); 
Route::get('/password/reset/{token}', '[email protected]'); 
Route::post('/password/reset', '[email protected]'); 
}); 

BaseController Код:

<?php 

namespace App\Http\Controllers\Base; 

use App\Http\Controllers\Controller; 


class BaseController extends Controller 
{ 
protected $appName = 'Stackoverflow'; 
protected $title = 'Welcome to Stackoverflow'; 
protected $action; 
} 

Я могу отправить ссылку на мой адрес электронной почты, но как только я нажму кнопку/кнопку. Он выдает ошибку, как указано выше. Есть идеи ?

+0

Возможный дубликат [Laravel Request :: все() не следует называть статически] (http://stackoverflow.com/questions/28573860/laravel-requestall-should-not-be- востребованная Стать cally) – patricus

ответ

16

Вы не используете требуемое пространство имен, попробуйте использовать следующие в контроллере:

use Illuminate\Http\Request; 

Вы получаете ошибку из-за того, что ваш сценарий пытается загрузить Request класс из текущего пространства имен : App\Http\Controllers\Auth

Request docs for Laravel 5.3

+0

он работает, но пропустил еще одну ошибку, так как вы можете видеть выше моего возвратного компакт-диска ForgotPasswordController. в ResetPasswordContorller я пытаюсь вернуть представление с помощью этого кода return view ('password.resetPassword') -> with ( ['title' => $ title 'appName' => $ appName 'action' => $ action 'token' => $ token, 'email' => $ request-> email] ); результат: yntax error, неожиданный '' appName '' (T_CONSTANT_ENCAPSED_STRING), ожидающий ']' –

+0

Какая ошибка вы получаете? –

+1

Отсутствует ',' return view ('password.resetPassword') -> with (['title' => $ title, 'appName' => $ appName, 'action' => $ action, 'token' => $ токен, 'email' => $ request-> email]); – Komal

Смежные вопросы