fdt2k / laravel-webshop-customers

1.0.10 2024-04-11 20:46 UTC

This package is auto-updated.

Last update: 2024-09-11 19:38:47 UTC


README

客户认证

sail artisan vendor:publish --provider="KDA\Webshop\CustomerProvider" --tag="config" --force

安装

配置 Laravel 身份验证保护者

为了启用身份验证,您必须添加 config/auth.php

'guards' => [
    ...
    'customers'=> [
        'driver' => 'session',
        'provider' => 'users' // <- change this if  you need another model
    ]
    ...
],

如果您需要使用其他模型

'providers' => [
    ...
    'users' => [
        'driver' => 'eloquent',
        'model' => App\Models\Customer::class,
    ],
    ...

],

在您的模型中(默认模型或自定义模型),您必须声明保护者

class User extends Authenticatable
{

    protected $guard_name = 'customers';

安装钩子重定向中间件

app/http/Kernel.php

添加

protected $routeMiddleware = [
    ....
    'hook'=> \KDA\Shop\Customer\Http\Middleware\HookAuthRedirect::class
    ...
];

通过添加调整优先级

 protected $middlewarePriority = [
    \Illuminate\Session\Middleware\StartSession::class,
    \Illuminate\View\Middleware\ShareErrorsFromSession::class,
    \KDA\Shop\Customer\Http\Middleware\HookAuthRedirect::class,  // <-- right after Session
    // other middlewares
    \App\Http\Middleware\Authenticate::class,
    \Illuminate\Session\Middleware\AuthenticateSession::class,
    \Illuminate\Routing\Middleware\SubstituteBindings::class,
    \Illuminate\Auth\Middleware\Authorize::class,
];

订单

cf laravel-shop-order

产品

正在更新

购物车

cf laravel-cart