4 changed files with 113 additions and 0 deletions
-
92app/AdminAgent/Controllers/SupplierController.php
-
16app/AdminAgent/Repositories/Supplier.php
-
1app/AdminAgent/routes.php
-
4dcat_admin_ide_helper.php
@ -0,0 +1,92 @@ |
|||
<?php |
|||
|
|||
namespace App\AdminAgent\Controllers; |
|||
|
|||
use App\AdminAgent\Repositories\Supplier; |
|||
use Dcat\Admin\Admin; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Http\Controllers\AdminController; |
|||
|
|||
class SupplierController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
//考虑到供应商表数据相对较少,故直接从供应商表查询,外加条件判断即可
|
|||
return Grid::make(new Supplier(), function (Grid $grid) { |
|||
$grid->disableActions(); |
|||
$grid->disableCreateButton(); |
|||
$grid->disableRowSelector(); |
|||
$grid->disableFilterButton(); |
|||
|
|||
$grid->model()->where(function ($query) { |
|||
return $query->whereHas('AgentProductItem', function ($query) { |
|||
return $query->where('agent_id', Admin::user()->id); |
|||
}); |
|||
}); |
|||
|
|||
$grid->column('id')->sortable(); |
|||
$grid->column('name'); |
|||
$grid->column('company_name'); |
|||
$grid->column('address'); |
|||
$grid->column('director'); |
|||
$grid->column('contact_phone'); |
|||
$grid->column('logo')->image('', 60, 60); |
|||
$grid->column('avatar')->image('', 60, 60); |
|||
$grid->column('license_pic')->image('', 60, 60); |
|||
$grid->column('created_at', '入驻时间'); |
|||
|
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->panel(); |
|||
|
|||
$filter->equal('id'); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a show builder. |
|||
* |
|||
* @param mixed $id |
|||
* |
|||
* @return Show |
|||
*/ |
|||
protected function detail($id) |
|||
{ |
|||
return Show::make($id, new Supplier(), function (Show $show) { |
|||
$show->field('id'); |
|||
/*$show->field('name'); |
|||
$show->field('company_name'); |
|||
$show->field('address'); |
|||
$show->field('director'); |
|||
$show->field('contact_phone'); |
|||
$show->field('logo'); |
|||
$show->field('avatar'); |
|||
$show->field('license_pic'); |
|||
$show->field('created_at'); |
|||
$show->field('updated_at');*/ |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
return Form::make(new Supplier(), function (Form $form) { |
|||
$form->display('id'); |
|||
})->saving(function (Form $form) { |
|||
$form->response()->error('操作禁止'); |
|||
})->deleting(function (Form $form) { |
|||
$form->response()->error('操作禁止'); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
namespace App\AdminAgent\Repositories; |
|||
|
|||
use App\Models\Supplier as Model; |
|||
use Dcat\Admin\Repositories\EloquentRepository; |
|||
|
|||
class Supplier extends EloquentRepository |
|||
{ |
|||
/** |
|||
* Model. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $eloquentClass = Model::class; |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue