lundi 21 décembre 2015

I created login features manually when i sat down to test errorException in EloquentUserProvider.php line 110: error comes

I am new to laravel and i am using laravel 5 .I know laravel 5 has inbuilt login features but i was unable to use it in my app.So i manually created login features.My registration working quite good but once i want to login it shows following error:

    ErrorException in EloquentUserProvider.php line 110: Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\user given, called in C:\Users\Pujan\Desktop\projectlaravel\vendor\laravel\framework\src\Illuminate\Auth\Guard.php on line 390 and defined
    I am not getting clear sense of Auth,traits and its feature where i am mistaken.
    my usercontroller is:
    <?php

    namespace App\Http\Controllers;

    use Illuminate\Http\Request;

    use App\Http\Requests;
    use App\Http\Controllers\Controller;
    use View;

    use App\user;
    use Input;
    use App\Http\Requests\YourFormRequest;
    use Auth;


    class UserController extends Controller
    {
        /**
         * Display a listing of the resource.
         *
         * @return \Illuminate\Http\Response
         */
         public $restful = true;

        public function index()
        {
            return View::make('users.new')->with('title', 'Make it snappy Q&A - Register');
        }

       /**
     * Show the form for creating a new resource.
     * Import the YourFormRequest class
     *
     * @param \App\Http\Requests\YourFormRequest $request
     * @return \Illuminate\Http\Redirect
     */
    public function create(YourFormRequest $request)
    {
        User::create($request->all());

        return redirect('/')->with('message','Thanks for registering!');
    }
    public function getlogin()
    {
        return View::make('users.login')->with('title','Make it snappy Q&A - Login ');
    }
    public function createlogin(){
        $user = array(
            'username'=>Input::get('username'),
            'password'=>Input::get('password')
            );
        if (Auth::attempt($user))
        {
            return redirect('/')->with('message','You are logged in:');
        }else{
            return redirect('login')
            ->with('message','Your username or password are incorrect pls chk it out')
            ->with_input();
        }

 Is there any code mistaken or i have forgotten any important thing regarding Auth/traits/guard.
My routes are:
Route::get('/','Questions@index');
Route::get('register','UserController@index');
Route::get('login','UserController@getlogin');
Route::post('register','UserController@create');
Route::post('login','UserController@createlogin');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire