$signature
$signature : string
The name and signature of the console command.
<?php
/**
* JingYao-backend
*
* @link https://gitee.com/wang-zhihui-release/jingyao-backend
* @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
*/
namespace App\Console\Commands;
use App\Enums\CheckStatusEnum;
use App\Models\AdminAction;
use App\Models\AdminRole;
use App\Models\AdminRoleAction;
use App\Models\AdminUser;
use App\Models\Company;
use App\Models\User;
use App\Services\UserService;
use Faker\Generator;
use Illuminate\Console\Command;
class Debug extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'debug:run';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
protected $service;
/**
* Create a new command instance.
*/
public function __construct(UserService $userService)
{
$this->service = $userService;
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle(Generator $generator)
{
$text = '';
for ($i = 0; $i < 30; ++$i) {
$text .= $generator->randomHtml();
}
Company::query()->where('id', 46)->update(['brief' => $text]);
return 0;
/*
$actions = config('role_actions');
foreach ($actions as $action) {
$action['action_name'] = 'App\\Http\\Controllers\\' . $action['action_name'];
AdminAction::query()->create($action);
}
*/
AdminUser::query()->create([
'phone' => '18131588815',
'password' => 'e10adc3949ba59abbe56e057f20f883e',
'admin_role_id' => 1,
]);
/*
$this->service->checkUserProfile(1, CheckStatusEnum::CHECK_ADOPT, 'adopt');
$this->setUser();
$this->initAdminActions();
$this->initAdminRoles();
$this->initRoleActionBind();
*/
return 0;
}
public function initAdminRoles()
{
$adminRoles = [
[
'name' => '村委人员',
'desc' => '村委人员的desc',
'remark' => 'remarkremarkremarkremarkremark',
'code' => 'xxx',
],
[
'name' => '决策人员',
'desc' => '决策人员的desc',
'remark' => 'remarkremarkremarkremarkremark',
'code' => 'LLL',
],
];
foreach ($adminRoles as $adminRole) {
AdminRole::query()->create($adminRole);
}
}
public function initAdminActions()
{
$actions = [
[
'action_name' => 'DevController@devGet',
'action_desc' => 'DevController 的 dev get',
],
[
'action_name' => 'DevController@devPost',
'action_desc' => 'action_desc',
],
[
'action_name' => 'DevController@devError',
'action_desc' => 'action_desc',
],
[
'action_name' => 'GridController@getLists',
'action_desc' => 'action_desc',
],
[
'action_name' => 'SearchNoticeController@getLists',
'action_desc' => 'action_desc',
],
];
foreach ($actions as $action) {
$action['action_name'] = 'App\Http\Controllers\\' . $action['action_name'];
AdminAction::query()->create($action);
}
}
public function initRoleActionBind()
{
$roleActions = [
[
'admin_role_id' => 1,
'admin_action_id' => 1,
],
[
'admin_role_id' => 1,
'admin_action_id' => 2,
],
[
'admin_role_id' => 1,
'admin_action_id' => 3,
],
[
'admin_role_id' => 1,
'admin_action_id' => 4,
],
[
'admin_role_id' => 2,
'admin_action_id' => 1,
],
[
'admin_role_id' => 2,
'admin_action_id' => 2,
],
[
'admin_role_id' => 2,
'admin_action_id' => 5,
],
];
foreach ($roleActions as $roleAction) {
AdminRoleAction::query()->create($roleAction);
}
}
public function setUser()
{
User::query()->create([
'name' => '情歌手阿花',
'wx_nick_name' => '情歌手阿花',
'phone' => '15108384833',
'sex' => 2,
'avatar' => 'https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLsXVTj03LN9ib6S3LLxQPxsUiap7UrvTYCUDL41qUPqoTXkyInFES2ZYS9jQlYZrko1PstVUdjaJUw/132',
'wx_openid' => 'oYhtv5B5sEWxIs5E4oh1KbXGnFx8',
'role' => 1,
]);
}
}