seeder
parent
9da8638346
commit
7b313886ec
|
|
@ -43,6 +43,7 @@ class StoreController extends AdminController
|
||||||
$grid->disableCreateButton(!$canAdmin);
|
$grid->disableCreateButton(!$canAdmin);
|
||||||
$grid->showEditButton();
|
$grid->showEditButton();
|
||||||
$grid->showViewButton();
|
$grid->showViewButton();
|
||||||
|
$grid->showDeleteButton($canAdmin);
|
||||||
|
|
||||||
$grid->filter(function (Grid\Filter $filter) {
|
$grid->filter(function (Grid\Filter $filter) {
|
||||||
$filter->panel();
|
$filter->panel();
|
||||||
|
|
@ -174,6 +175,14 @@ class StoreController extends AdminController
|
||||||
$form->text('remarks');
|
$form->text('remarks');
|
||||||
|
|
||||||
$form->disableDeleteButton();
|
$form->disableDeleteButton();
|
||||||
|
|
||||||
|
// 管理员删除店铺
|
||||||
|
if ($form->isDeleting() && $canAdmin) {
|
||||||
|
$info = Store::find($form->getKey());
|
||||||
|
// 删除店铺关联的数据
|
||||||
|
$info->adminUsers()->detach();
|
||||||
|
$info->productSkus()->detach();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ class AdminMenuSeeder extends Seeder
|
||||||
'icon' => 'fa fa-shopping-bag',
|
'icon' => 'fa fa-shopping-bag',
|
||||||
'uri' => '',
|
'uri' => '',
|
||||||
'children'=>[
|
'children'=>[
|
||||||
|
[ 'title' => '店铺管理', 'icon' => '', 'uri' => 'store' ],
|
||||||
[
|
[
|
||||||
'title' =>'文章管理',
|
'title' =>'文章管理',
|
||||||
'icon' => '',
|
'icon' => '',
|
||||||
|
|
|
||||||
|
|
@ -306,6 +306,10 @@ class AdminPermissionSeeder extends Seeder
|
||||||
'remark'=>['name' =>'备注'],
|
'remark'=>['name' =>'备注'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'store' => [
|
||||||
|
'name' => '店铺管理',
|
||||||
|
'curd' => ['index', 'create', 'store', 'edit', 'update', 'destroy'],
|
||||||
|
]
|
||||||
];
|
];
|
||||||
// try {
|
// try {
|
||||||
// DB::begintransaction();
|
// DB::begintransaction();
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Database\Seeders;
|
|
||||||
|
|
||||||
use Illuminate\Database\Seeder;
|
|
||||||
|
|
||||||
class AdminSeeder extends Seeder
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Seed the application's database.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function run()
|
|
||||||
{
|
|
||||||
$this->call([
|
|
||||||
// AdminMenuSeeder::class,
|
|
||||||
AdminPermissionSeeder::class,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class AdminUserSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$roleModel = config('admin.database.roles_model');
|
||||||
|
$userModel = config('admin.database.users_model');
|
||||||
|
|
||||||
|
$role = $roleModel::create([
|
||||||
|
'name' => 'Administrator',
|
||||||
|
'slug' => 'administrator',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = $userModel::create([
|
||||||
|
'username' => 'admin',
|
||||||
|
'password' => 'admin',
|
||||||
|
'name' => '管理员',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->roles()->attach($role);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -15,9 +15,11 @@ class DatabaseSeeder extends Seeder
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
$this->call([
|
$this->call([
|
||||||
AdminSeeder::class,
|
AdminMenuSeeder::class,
|
||||||
|
AdminPermissionSeeder::class,
|
||||||
AppSettingSeeder::class,
|
AppSettingSeeder::class,
|
||||||
VipSeeder::class,
|
VipSeeder::class,
|
||||||
|
AdminUserSeeder::class,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (! App::isProduction()) {
|
if (! App::isProduction()) {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class UserSeeder extends Seeder
|
||||||
DB::table('balances')->truncate();
|
DB::table('balances')->truncate();
|
||||||
DB::table('users')->truncate();
|
DB::table('users')->truncate();
|
||||||
$this->faker = $this->withFaker();
|
$this->faker = $this->withFaker();
|
||||||
// $this->createUsers(1);
|
$this->createUsers(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createUsers($vip, $parent = null)
|
protected function createUsers($vip, $parent = null)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue