增加回调地址
This commit is contained in:
42
app/Admin/Actions/User/Callback.php
Normal file
42
app/Admin/Actions/User/Callback.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Actions\User;
|
||||||
|
|
||||||
|
use Encore\Admin\Actions\RowAction;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class Callback extends RowAction
|
||||||
|
{
|
||||||
|
|
||||||
|
public $name = '设置回调地址';
|
||||||
|
|
||||||
|
public function handle(Model $model, Request $request)
|
||||||
|
{
|
||||||
|
$validator = \Validator::make($request->all(), [
|
||||||
|
'callback' => 'required|url',
|
||||||
|
], [
|
||||||
|
'callback.required' => '缺少回调地址',
|
||||||
|
'callback.url' => '回调地址不正确,不是有效的url地址',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return $this->response()->error($validator->errors()->first());
|
||||||
|
}
|
||||||
|
|
||||||
|
$model->callback = $request->callback;
|
||||||
|
|
||||||
|
if ($model->save()) {
|
||||||
|
return $this->response()->success('设置成功')->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response()->error('设置失败')->refresh();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function form(Model $model)
|
||||||
|
{
|
||||||
|
$this->text('callback', '回调地址')->default($model->callback)->required();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Admin\Controllers\User;
|
namespace App\Admin\Controllers\User;
|
||||||
|
|
||||||
|
use App\Admin\Actions\User\Callback;
|
||||||
use App\Admin\Actions\User\Profit;
|
use App\Admin\Actions\User\Profit;
|
||||||
use App\Admin\Actions\User\ReCode;
|
use App\Admin\Actions\User\ReCode;
|
||||||
use App\Admin\Actions\User\RefD3Key;
|
use App\Admin\Actions\User\RefD3Key;
|
||||||
@@ -38,9 +39,8 @@ class IndexController extends AdminController
|
|||||||
|
|
||||||
if ($actions->row->identity_id == 1) {
|
if ($actions->row->identity_id == 1) {
|
||||||
$actions->add(new RefD3Key);
|
$actions->add(new RefD3Key);
|
||||||
}
|
|
||||||
if ($actions->row->identity_id == 1) {
|
|
||||||
$actions->add(new ReCode);
|
$actions->add(new ReCode);
|
||||||
|
$actions->add(new Callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($actions->row->type == 'pingan' && $actions->row->identity_id == 1 && $user->id == 1) {
|
if ($actions->row->type == 'pingan' && $actions->row->identity_id == 1 && $user->id == 1) {
|
||||||
@@ -97,6 +97,19 @@ class IndexController extends AdminController
|
|||||||
return $this->type_text;
|
return $this->type_text;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$grid->column('回调地址')->display(function ($title, $column) {
|
||||||
|
return '点击查看';
|
||||||
|
})->modal(function ($model) {
|
||||||
|
$data = [
|
||||||
|
[
|
||||||
|
$this->callback,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
return new Table(['url'], $data);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
$grid->column('密钥')->display(function ($title, $column) {
|
$grid->column('密钥')->display(function ($title, $column) {
|
||||||
return '点击查看';
|
return '点击查看';
|
||||||
})->modal(function ($model) {
|
})->modal(function ($model) {
|
||||||
@@ -174,14 +187,16 @@ class IndexController extends AdminController
|
|||||||
|
|
||||||
$form = new Form(new User);
|
$form = new Form(new User);
|
||||||
$identity = Identity::find(1);
|
$identity = Identity::find(1);
|
||||||
|
|
||||||
$form->text('username', '登录账户')
|
$form->text('username', '登录账户')
|
||||||
->creationRules(['required', "unique:users", 'max:11'], ['max' => '小于11个字符'])
|
->creationRules(['required', "unique:users", 'max:11'], ['max' => '小于11个字符'])
|
||||||
->updateRules(['required', "unique:users,username,{{id}}"])->required();
|
->updateRules(['required', "unique:users,username,{{id}}"])->required();
|
||||||
|
|
||||||
$form->password('password', '登录密码')->creationRules('required|min:6', [
|
$form->password('password', '登录密码')
|
||||||
'required' => '必填',
|
->creationRules('required|min:6', [
|
||||||
'min' => '密码不能少于6个字符',
|
'required' => '必填',
|
||||||
]);
|
'min' => '密码不能少于6个字符',
|
||||||
|
]);
|
||||||
|
|
||||||
$form->text('PaOutletId', '平安网点id');
|
$form->text('PaOutletId', '平安网点id');
|
||||||
|
|
||||||
@@ -252,9 +267,9 @@ class IndexController extends AdminController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取隶属
|
* 获取隶属
|
||||||
* @author 玄尘 2020-03-12
|
* @author 玄尘 2020-03-12
|
||||||
* @param Request $request [description]
|
* @param Request $request [description]
|
||||||
* @return [type] [description]
|
* @return [type] [description]
|
||||||
*/
|
*/
|
||||||
public function getParent(Request $request)
|
public function getParent(Request $request)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,10 +39,12 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function grant(Request $request)
|
public function grant(Request $request)
|
||||||
{
|
{
|
||||||
$inputdata = $request->all();
|
$inputdata = $request->all();
|
||||||
$res = $this->checkSign($request);
|
$res = $this->checkSign($request);
|
||||||
|
|
||||||
$inputdata['jiemi'] = $res;
|
$inputdata['jiemi'] = $res;
|
||||||
$log = $this->createLog($request->url(), 'POST', $inputdata, 'grant'); //添加日志
|
$log = $this->createLog($request->url(), 'POST', $inputdata, 'grant'); //添加日志
|
||||||
|
|
||||||
if (is_string($res)) {
|
if (is_string($res)) {
|
||||||
return $this->error($res, $log);
|
return $this->error($res, $log);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user