我有一个以下身份验证表:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class CreateAuthTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('auth', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('email', 255)->index()->unique();
$table->string('password', 96);
$table->timestamps();
});
DB::statement('ALTER TABLE auth ALTER COLUMN id SET DEFAULT uuid_generate_v4();');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('auth');
}
}
这是模型:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticable;
use Illuminate\Support\Facades\Hash;
use Laravel\Passport\HasApiTokens;
class User extends Authenticable
{
use HasApiTokens;
protected $table = "auth";
protected $fillable = ["email", "password"];
public $incrementing = false;
protected $keyType = 'string';
protected $casts = [
'id' => 'string'
];
private $hashOptions = [
'memory' => 1024,
'time' => 2,
'threads' => 1
];
public function setPasswordAttribute($value)
{
$this->attributes['password'] = Hash::make($value, $this->hashOptions);
}
}
慕工程0101907