151 lines
3.6 KiB
PHP
151 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Admin\Actions\MobileImport;
|
|
use App\Models\Mobile;
|
|
use Encore\Admin\Controllers\AdminController;
|
|
use Encore\Admin\Form;
|
|
use Encore\Admin\Grid;
|
|
use Encore\Admin\Layout\Content;
|
|
use Encore\Admin\Show;
|
|
|
|
class MobileController extends AdminController
|
|
{
|
|
|
|
/**
|
|
* Index interface.
|
|
*
|
|
* @param Content $content
|
|
* @return Content
|
|
*/
|
|
public function index(Content $content)
|
|
{
|
|
|
|
return $content
|
|
->header('手机号管理')
|
|
->description('description')
|
|
->body($this->grid());
|
|
}
|
|
|
|
/**
|
|
* Edit interface.
|
|
*
|
|
* @param mixed $id
|
|
* @param Content $content
|
|
* @return Content
|
|
*/
|
|
public function edit($id, Content $content)
|
|
{
|
|
return $content
|
|
->header('编辑手机号')
|
|
->body($this->form()->edit($id));
|
|
}
|
|
|
|
/**
|
|
* Create interface.
|
|
*
|
|
* @param Content $content
|
|
* @return Content
|
|
*/
|
|
public function create(Content $content)
|
|
{
|
|
return $content
|
|
->header('新增手机号')
|
|
->body($this->form());
|
|
}
|
|
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
$grid = new Grid(new Mobile);
|
|
$grid->model()->orderBy('id', 'desc');
|
|
|
|
$grid->tools(function (Grid\Tools $tools) {
|
|
$tools->append(new MobileImport);
|
|
});
|
|
|
|
$grid->filter(function ($filter) {
|
|
$filter->column(1 / 2, function ($filter) {
|
|
$filter->like('number', '手机号');
|
|
$filter->equal('status', '状态')->select([
|
|
1 => '正常',
|
|
0 => '禁用',
|
|
]);
|
|
});
|
|
|
|
$filter->column(1 / 2, function ($filter) {
|
|
$filter->equal('operator', '运营商')->select(config('pick.operators'));
|
|
$filter->like('city_name', '所属(市)');
|
|
});
|
|
|
|
$filter->disableIdFilter();
|
|
|
|
});
|
|
|
|
$grid->id('ID');
|
|
$grid->number('手机号');
|
|
$grid->charge('服务费');
|
|
$grid->price('低消费');
|
|
$grid->type('靓号类型');
|
|
$grid->column('运营商')->display(function () {
|
|
return $this->operator_text;
|
|
});
|
|
|
|
$grid->column('所属地区')->display(function () {
|
|
return $this->city_name;
|
|
});
|
|
$grid->column('所属用户')->display(function () {
|
|
return $this->user ? $this->user->info->nickname : '---';
|
|
});
|
|
|
|
$grid->column('状态')->display(function () {
|
|
return $this->status_text;
|
|
});
|
|
|
|
$grid->created_at('创建时间');
|
|
return $grid;
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
$show = new Show(Mobile::findOrFail($id));
|
|
|
|
$show->id('编号');
|
|
$show->name('手机号名称');
|
|
$show->created_at('创建时间');
|
|
|
|
return $show;
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
$operators = (new Mobile)->operators;
|
|
|
|
$form = new Form(new Mobile);
|
|
|
|
$form->text('number', '手机号')->rules('required');
|
|
$form->text('type', '靓号类型')->rules('required');
|
|
$form->text('charge', '服务费')->rules('required');
|
|
$form->text('price', '低消')->rules('required');
|
|
$form->select('operator', '运营商')->options($operators)->rules('required');
|
|
return $form;
|
|
}
|
|
|
|
}
|