發表文章

目前顯示的是 1月, 2022的文章

[Laravel] Custom guard and auth provider

圖片
前言 如果要客製自己的 auth gard 用來處理驗證與登入 首先可以從官網的 Authentication 中找到! 但是寫的有一點點不全面,在這邊重新整理一下。 如果是要用 jwt 登入這種,則可以直接參考官網即可! 大致需要 自己定義的 Auth Guard 自己定義的 User Provider (後面解釋) 用來驗證的 model 建立用來驗證的 model <?php namespace App\Models\Member; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Foundation\Auth\User as Authenticatable; class Member extends Authenticatable { use SoftDeletes; protected $table = 'members'; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', 'cell_phone', 'verified', 'status', 'facebook_id', 'line_id', ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', ]; protected $dates = [ 'deleted_at', ]; } 在這邊我主要是先建立一個 Member.php 的 model 這裡有些