pdphilip / laravel-elasticsearch

Laravel Elasticsearch: An Elasticsearch implementation of Laravel's Eloquent ORM
MIT License
86 stars 16 forks source link

[Implemented] How to handle the authentication? #6

Closed link2qaiser closed 10 months ago

pdphilip commented 10 months ago

Hey @link2qaiser,

The latest update will accommodate user authentication. For Laravel 10 and v2.10.2 of the plugin:

User.php

<?php

namespace App\Models;

use Illuminate\Auth\Passwords\CanResetPassword as CanResetPasswordTrait;
use Illuminate\Contracts\Auth\CanResetPassword;

use Illuminate\Notifications\Notifiable;
use PDPhilip\Elasticsearch\Eloquent\Model as Eloquent;
use Illuminate\Auth\Authenticatable as AuthenticatableTrait;
use Illuminate\Contracts\Auth\Authenticatable;

class User extends Eloquent implements Authenticatable, CanResetPassword
{
    use Notifiable, AuthenticatableTrait, CanResetPasswordTrait;

}

Side note: You're absolutely free to do this, but given what ElasticSearch was designed to do I personally would not go down the road of using ElasticSearch as a primary data store.