laravel 5.3 authentication with jenssegers-mongodb

laravel5 5 ต.ค. 2016

Add package to laravel

Install using composer:

composer require jenssegers/mongodb-session

Change the session driver in app/config/session.php to mongodb:

'driver' => 'mongodb',

Optional: change the connection to a connection using the mongodb driver from app/config/database.php:

'connection' => 'mongodb',


'providers' => [

User model

namespace App;

use Illuminate\Notifications\Notifiable;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class User extends Eloquent implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract
    use Authenticatable, Authorizable, CanResetPassword;
    use Notifiable;

     * The database table used by the model.
     * @var string
    protected $collection = 'users';

    * The database primary key value.
    * @var string
    protected $primaryKey = '_id';

     * The attributes that are mass assignable.
     * @var array
    protected $fillable = [
        'name', 'email', 'password',

     * The attributes that should be hidden for arrays.
     * @var array
    protected $hidden = [
        'password', 'remember_token',

and try to register/login



Just a middle-aged programmer, Can do many things but not the most.