优化表
This commit is contained in:
parent
5b587bb9d2
commit
56f2964248
@ -3,6 +3,7 @@
|
|||||||
namespace App\Models\Admin;
|
namespace App\Models\Admin;
|
||||||
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
@ -23,7 +24,7 @@ class Admin extends Model
|
|||||||
// protect password
|
// protect password
|
||||||
public function setPasswordAttribute($value)
|
public function setPasswordAttribute($value)
|
||||||
{
|
{
|
||||||
$this->attributes['password'] = bcrypt($value);
|
$this->attributes['password'] = Crypt::encrypt($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// before create admin, generate api_token
|
// before create admin, generate api_token
|
||||||
@ -36,7 +37,7 @@ public static function boot()
|
|||||||
if (!$admin->api_token) {
|
if (!$admin->api_token) {
|
||||||
$admin->api_token = Str::random(60);
|
$admin->api_token = Str::random(60);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class extends Migration
|
||||||
{
|
{
|
||||||
@ -35,7 +36,7 @@ public function up()
|
|||||||
$admin = new Admin();
|
$admin = new Admin();
|
||||||
$admin->name = 'admin';
|
$admin->name = 'admin';
|
||||||
$admin->email = 'admin@admin.test';
|
$admin->email = 'admin@admin.test';
|
||||||
$admin->password = bcrypt('admin');
|
$admin->password = 'admin';
|
||||||
$admin->api_token = 123456;
|
$admin->api_token = 123456;
|
||||||
$admin->save();
|
$admin->save();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user