я могу разработать одну форму входа с несколькими таблицами в Laravel 5.8? Пожалуйста, предложите - PullRequest
0 голосов
/ 13 мая 2019

Надеюсь, у тебя все хорошо!Я модернизирую портал, там есть две таблицы разных пользователей-2, так что я могу создать одну форму авторизации для обеих таблиц?Я определил охрану и провайдера в App \ config \ auth.php и создал модель (Admin и Staff), но вызов модели пользователя, когда я захожу с staff / admin.Любое решение?

Охрана

'guards' => [

    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

     'admin' => [
        'driver' => 'session',
        'provider' => 'admins',
    ],



    'staff' => [
        'driver' => 'session',
        'provider' => 'staffs',
    ],


    'api' => [
        'driver' => 'token',
        'provider' => 'users',
        'hash' => false,
    ],
],

провайдеров

'providers' => [

    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
    ],

    'staffs' => [
        'driver' => 'eloquent',
        'model' => App\Staff::class,
    ],

    'admins' => [
        'driver' => 'eloquent',
        'model' => App\Admin::class,
    ],




],

Модель администратора

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Admin extends Authenticatable
{
    use Notifiable;
    protected $table = 'allusers';
    protected $guard = 'admin';
    /**
     * 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',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}

Модель персонала

   <?php

namespace App;


use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Staff extends Authenticatable
{
    use Notifiable;
    protected $table = 'allusers';
    protected $guard = 'staff';


/**
 * 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',
];

/**
 * The attributes that should be cast to native types.
 *
 * @var array
 */
protected $casts = [
    'email_verified_at' => 'datetime',
];
}

При входе в систему с правами администратора или персонала, я получаю

**#provider: EloquentUserProvider {#214 ▼
    #hasher: HashManager {#232 ▶}
    #model: "App\User"
  }**

Любое решение, пожалуйста, предложите. Спасибо

...