You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
3.9 KiB
74 lines
3.9 KiB
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\EditToMigration;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class InitAdminSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public $guardName = "admin";
|
|
|
|
public function run()
|
|
{
|
|
$this->initPermissions();
|
|
$this->initRole();
|
|
$this->initAdmin();
|
|
$this->initEditToMigration();
|
|
$permissions = \Spatie\Permission\Models\Permission::get();
|
|
$role = \Spatie\Permission\Models\Role::orderBy("id", "desc")->first();
|
|
$admin = \App\Models\Admin::orderBy("id", "desc")->first();
|
|
$role->syncPermissions($permissions);
|
|
$admin->syncRoles([$role]);
|
|
}
|
|
|
|
public function initPermissions()
|
|
{
|
|
\Spatie\Permission\Models\Permission::create(["id" => 1, "guard_name" => $this->guardName, "name" => "系统管理", "url" => "#", "icon" => "el-icon-setting"]);
|
|
\Spatie\Permission\Models\Permission::create(["id" => 2, "pid" => 1, "guard_name" => $this->guardName, "name" => "权限菜单", "url" => "/system/menu", "api_prefix" => "api/admin/menu", "icon" => "el-icon-s-operation"]);
|
|
\Spatie\Permission\Models\Permission::create(["id" => 3, "pid" => 1, "guard_name" => $this->guardName, "name" => "角色管理", "url" => "/system/role", "api_prefix" => "api/admin/role", "icon" => "Icon/ios-people"]);
|
|
\Spatie\Permission\Models\Permission::create(["id" => 4, "pid" => 1, "guard_name" => $this->guardName, "name" => "权限管理", "url" => "/system/permission", "api_prefix" => "api/admin/permission", "icon" => "el-icon-s-check"]);
|
|
\Spatie\Permission\Models\Permission::create(["id" => 5, "pid" => 1, "guard_name" => $this->guardName, "name" => "用户管理", "url" => "/system/user", "api_prefix" => "api/admin/admin", "icon" => "el-icon-s-custom"]);
|
|
\Spatie\Permission\Models\Permission::create(["id" => 6, "pid" => 1, "guard_name" => $this->guardName, "name" => "数据字典", "url" => "/system/dictionary", "api_prefix" => "api/admin/parameter", "icon" => "el-icon-set-up"]);
|
|
\Spatie\Permission\Models\Permission::create(["id" => 7, "pid" => 1, "guard_name" => $this->guardName, "name" => "部门管理", "url" => "/system/department", "api_prefix" => "api/admin/department", "icon" => "tree"]);
|
|
}
|
|
|
|
public function initRole()
|
|
{
|
|
\Spatie\Permission\Models\Role::create([
|
|
"guard_name" => $this->guardName,
|
|
"name" => "系统管理员"
|
|
]);
|
|
}
|
|
|
|
public function initAdmin()
|
|
{
|
|
\App\Models\Admin::create([
|
|
"username" => "admin",
|
|
"name" => "系统管理员",
|
|
"password" => \Illuminate\Support\Facades\Hash::make("Admin" . date("Y"))
|
|
]);
|
|
}
|
|
|
|
public function initEditToMigration()
|
|
{
|
|
EditToMigration::create(['name' => '小文本框', 'edit_input' => 'text', 'migration_type' => 'string']);
|
|
EditToMigration::create(['name' => '中文本框', 'edit_input' => 'textarea', 'migration_type' => 'text']);
|
|
EditToMigration::create(['name' => '富文本框', 'edit_input' => 'richtext', 'migration_type' => 'mediumText']);
|
|
EditToMigration::create(['name' => '单选框', 'edit_input' => 'radio', 'migration_type' => 'integer']);
|
|
EditToMigration::create(['name' => '复选框', 'edit_input' => 'checkbox', 'migration_type' => 'json']);
|
|
EditToMigration::create(['name' => '日期', 'edit_input' => 'date', 'migration_type' => 'date']);
|
|
EditToMigration::create(['name' => '日期时间', 'edit_input' => 'datetime', 'migration_type' => 'dateTime']);
|
|
EditToMigration::create(['name' => '单文件上传', 'edit_input' => 'file', 'migration_type' => 'integer']);
|
|
EditToMigration::create(['name' => '多文件上传', 'edit_input' => 'files', 'migration_type' => 'json']);
|
|
EditToMigration::create(['name' => '地图', 'edit_input' => 'map', 'migration_type' => 'string']);
|
|
}
|
|
|
|
}
|