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.
105 lines
3.0 KiB
105 lines
3.0 KiB
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Models\MchApp;
|
|
use App\Models\Merchant;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Show;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
use Illuminate\Support\Str;
|
|
|
|
class MchAppController extends AdminController
|
|
{
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
return Grid::make(new MchApp(), function (Grid $grid) {
|
|
$grid->model()->orderBy('id', 'desc');
|
|
|
|
$grid->column('id')->sortable();
|
|
$grid->column('mch_no');
|
|
$grid->column('app_id');
|
|
$grid->column('alipay_account');
|
|
$grid->column('company_name');
|
|
$grid->column('account_book_id');
|
|
$grid->column('created_at');
|
|
$grid->column('updated_at')->sortable();
|
|
|
|
$grid->enableDialogCreate();
|
|
$grid->showQuickEditButton();
|
|
$grid->disableEditButton();
|
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->equal('mch_no')->width(3)->select(Merchant::getAllMerchant());
|
|
$filter->equal('app_id')->width(3);
|
|
$filter->equal('alipay_account')->width(3);
|
|
$filter->like('company_name')->width(3);
|
|
$filter->equal('account_book_id')->width(3);
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return Show::make($id, new MchApp(), function (Show $show) {
|
|
$show->field('id');
|
|
$show->field('mch_no');
|
|
$show->field('app_id');
|
|
$show->field('secret_key');
|
|
$show->field('alipay_account');
|
|
$show->field('company_name');
|
|
$show->field('account_book_id');
|
|
$show->field('created_at');
|
|
$show->field('updated_at');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new MchApp(), function (Form $form) {
|
|
$form->display('id');
|
|
|
|
if ($form->isCreating()) {
|
|
$form->select('mch_no')
|
|
->options(Merchant::getAllMerchant())
|
|
->required();
|
|
$form->hidden('app_id');
|
|
$form->hidden('secret_key');
|
|
} else {
|
|
$form->display('mch_no');
|
|
$form->display('app_id');
|
|
}
|
|
|
|
$form->text('alipay_account')->required();
|
|
$form->text('company_name')->required();
|
|
|
|
$form->display('created_at');
|
|
$form->display('updated_at');
|
|
|
|
$form->saving(function (Form $form) {
|
|
if ($form->isCreating()) {
|
|
$form->app_id = uniqid().substr(md5(time()), 0, 11);
|
|
$form->secret_key = Str::random(128);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|