6
0
Fork 0
jiqu-library-server/app/Admin/Controllers/DealerEarningController.php

124 lines
3.7 KiB
PHP

<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\DealerEarning;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Show;
class DealerEarningController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
$earning = DealerEarning::with('user');
return Grid::make($earning, function (Grid $grid) {
$grid->column('id')->sortable();
$grid->column('user.phone');
$grid->column('type_name')->display(function () {
return $this->type_name;
})->label();
// $grid->column('earningable_type');
// $grid->column('earningable_id');
$grid->column('lvl')->display(function () {
return $this->lvl_text;
});
$grid->column('is_manager')->bool();
$grid->column('total_amount')->prepend('¥');
$grid->column('fee_rate')->append('%');
$grid->column('fee')->prepend('¥');
$grid->column('total_earnings')->prepend('¥');
$grid->column('payer_id');
// $grid->column('pay_info');
$grid->column('pay_at');
$grid->column('settle_at');
$grid->column('status_format')->display(function ($value) {
return $this->status_format;
})->using([
-1=>'待结算',
0=>'待打款',
1=>'待收款',
2=>'已完成',
])->dot();
$grid->column('remark');
// $grid->column('pay_image');
$grid->column('created_at')->sortable();
$grid->filter(function (Grid\Filter $filter) {
$filter->panel();
$filter->equal('user.phone')->width(3);
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new DealerEarning(), function (Show $show) {
$show->field('id');
$show->field('user_id');
$show->field('earningable_type');
$show->field('earningable_id');
$show->field('lvl');
$show->field('is_manager');
$show->field('total_amount');
$show->field('total_earnings');
$show->field('fee');
$show->field('fee_rate');
$show->field('payer_id');
$show->field('pay_info');
$show->field('pay_at');
$show->field('settle_at');
$show->field('status');
$show->field('remark');
$show->field('pay_image');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new DealerEarning(), function (Form $form) {
$form->display('id');
$form->text('user_id');
$form->text('earningable_type');
$form->text('earningable_id');
$form->text('lvl');
$form->text('is_manager');
$form->text('total_amount');
$form->text('total_earnings');
$form->text('fee');
$form->text('fee_rate');
$form->text('payer_id');
$form->text('pay_info');
$form->text('pay_at');
$form->text('settle_at');
$form->text('status');
$form->text('remark');
$form->text('pay_image');
$form->display('created_at');
$form->display('updated_at');
});
}
}