添加后台保证金
parent
d9d9a95f55
commit
8208b04ec2
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Actions\Grid;
|
||||
|
||||
use App\Admin\Forms\DealerBonds as DealerBondsForm;
|
||||
use Dcat\Admin\Grid\RowAction;
|
||||
use Dcat\Admin\Widgets\Modal;
|
||||
|
||||
class DealerBonds extends RowAction
|
||||
{
|
||||
public function title()
|
||||
{
|
||||
if ($this->title) {
|
||||
return $this->title;
|
||||
}
|
||||
return '<i class="feather icon-stop-circle grid-action-icon"></i> 保证金 ';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model|Authenticatable|HasPermissions|null $user
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorize($user): bool
|
||||
{
|
||||
return $user->can('dcat.admin.dealer.bonds');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$form = DealerBondsForm::make()->payload(['id'=>$this->getKey()]);
|
||||
return Modal::make()
|
||||
->lg()
|
||||
->title($this->title())
|
||||
->body($form)
|
||||
->button($this->title());
|
||||
}
|
||||
}
|
||||
|
|
@ -2,10 +2,12 @@
|
|||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\Grid\DealerBonds;
|
||||
use App\Admin\Actions\Grid\DealerEditLvl;
|
||||
use App\Admin\Actions\Grid\DealerSignManager;
|
||||
use App\Admin\Actions\Grid\DealerUnsignManager;
|
||||
use App\Admin\Repositories\Dealer;
|
||||
use App\Enums\DealerLvl;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid;
|
||||
|
|
@ -33,7 +35,9 @@ class DealerController extends AdminController
|
|||
});
|
||||
$grid->column('is_sale');
|
||||
$grid->column('is_manager')->bool();
|
||||
// $grid->column('pay_info');
|
||||
$grid->column('bonds')->prepend('¥')->filter(
|
||||
Grid\Column\Filter\Between::make()
|
||||
);
|
||||
$grid->column('created_at')->sortable();
|
||||
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
|
|
@ -43,9 +47,12 @@ class DealerController extends AdminController
|
|||
if (!$actions->row->is_manager && Admin::user()->can('dcat.admin.dealers.sign_manager')) {
|
||||
$actions->append(new DealerSignManager());
|
||||
}
|
||||
if ($actions->row->is_manager && Admin::user()->can('dcat.admin.dealers.sign_manager')) {
|
||||
if ($actions->row->is_manager && Admin::user()->can('dcat.admin.dealers.unsign_manager')) {
|
||||
$actions->append(new DealerUnsignManager());
|
||||
}
|
||||
if ($actions->row->lvl->value >= DealerLvl::Special->value && Admin::user()->can('dcat.admin.dealers.bonds')) {
|
||||
$actions->append(new DealerBonds());
|
||||
}
|
||||
});
|
||||
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Forms;
|
||||
|
||||
use App\Models\Dealer;
|
||||
use Dcat\Admin\Contracts\LazyRenderable;
|
||||
use Dcat\Admin\Traits\LazyWidget;
|
||||
use Dcat\Admin\Widgets\Form;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Throwable;
|
||||
|
||||
class DealerBonds extends Form implements LazyRenderable
|
||||
{
|
||||
use LazyWidget;
|
||||
|
||||
/**
|
||||
* @param Model|Authenticatable|HasPermissions|null $user
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorize($user): bool
|
||||
{
|
||||
return $user->can('dcat.admin.dealer.bonds');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the form request.
|
||||
*
|
||||
* @param array $input
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(array $input)
|
||||
{
|
||||
$id = $this->payload['id'] ?? 0;
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$dealer = Dealer::findOrFail($id);
|
||||
$dealer->update([
|
||||
'bonds'=>$input['bonds'],
|
||||
]);
|
||||
DB::commit();
|
||||
} catch (Throwable $th) {
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
return $this->response()->error('操作失败:'.$th->getMessage());
|
||||
}
|
||||
|
||||
return $this->response()
|
||||
->success(__('admin.update_succeeded'))
|
||||
->refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a form here.
|
||||
*/
|
||||
public function form()
|
||||
{
|
||||
$this->currency('bonds')->required();
|
||||
}
|
||||
|
||||
public function default()
|
||||
{
|
||||
$id = $this->payload['id'] ?? 0;
|
||||
$dealer = Dealer::findOrFail($id);
|
||||
return [
|
||||
'bonds'=>$dealer->bonds,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -33,6 +33,7 @@ class Dealer extends Model
|
|||
'is_manager',
|
||||
'pay_info',
|
||||
'contracted_lvl_at',
|
||||
'bonds',
|
||||
];
|
||||
|
||||
public function user()
|
||||
|
|
|
|||
Loading…
Reference in New Issue