12 changed files with 221 additions and 15 deletions
-
4app/Admin/Actions/Grid/v3/GoodsCopy.php
-
2app/Admin/Controllers/v3/CategoryController.php
-
4app/Admin/Controllers/v3/GoodsController.php
-
92app/Admin/Controllers/v3/LanzuEmployeesController.php
-
14app/Admin/Controllers/v3/StoreController.php
-
4app/Admin/Forms/GoodsNewCopyForm.php
-
2app/Admin/Forms/v3/CategoryTieForm.php
-
2app/Admin/Forms/v3/GoodsCopyForm.php
-
16app/Admin/Repositories/v3/LanzuEmployees.php
-
8app/Admin/routes.php
-
70app/Models/v3/LanzuEmployees.php
-
18resources/lang/zh-CN/lanzu-employees.php
@ -1,10 +1,10 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Actions\Grid; |
|||
namespace App\Admin\Actions\Grid\v3; |
|||
|
|||
use Dcat\Admin\Grid\RowAction; |
|||
use Dcat\Admin\Widgets\Modal; |
|||
use App\Admin\Forms\GoodsCopyForm; |
|||
use App\Admin\Forms\v3\GoodsCopyForm; |
|||
|
|||
class GoodsCopy extends RowAction |
|||
{ |
|||
@ -0,0 +1,92 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers\v3; |
|||
|
|||
use App\Admin\Repositories\v3\LanzuEmployees; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use App\Models\v3\LanzuEmployees as EmployeesModel; |
|||
use App\Models\v3\User as UserModel; |
|||
use App\Models\v3\Store as StoreModel; |
|||
|
|||
class LanzuEmployeesController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new LanzuEmployees(), function (Grid $grid) { |
|||
$grid->column('id')->sortable(); |
|||
$grid->column('market_id'); |
|||
$grid->column('user_id')->display(function($userId){ |
|||
$item = UserModel::getUserInfo($userId,'real_name'); |
|||
return empty($item) ? '' : $$item['real_name']; |
|||
}); |
|||
$grid->column('store_id')->display(function($storeId){ |
|||
$item = StoreModel::getStoreInfo($storeId,'real_name'); |
|||
return empty($item) ? '' : $$item['real_name']; |
|||
}); |
|||
|
|||
$grid->column('role')->display(function($role){ |
|||
return $role; |
|||
}); |
|||
$grid->column('status')->select(EmployeesModel::$_STATUS); |
|||
|
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->equal('id'); |
|||
|
|||
}); |
|||
$grid->model()->orderBy('id','desc'); |
|||
// 每页10条
|
|||
$grid->paginate(10); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a show builder. |
|||
* |
|||
* @param mixed $id |
|||
* |
|||
* @return Show |
|||
*/ |
|||
protected function detail($id) |
|||
{ |
|||
return Show::make($id, new LanzuEmployees(), function (Show $show) { |
|||
$show->field('id'); |
|||
$show->field('user_id'); |
|||
$show->field('store_id'); |
|||
$show->field('market_id'); |
|||
$show->field('role'); |
|||
$show->field('status'); |
|||
$show->field('note'); |
|||
$show->field('created_at'); |
|||
$show->field('updated_at'); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
return Form::make(new LanzuEmployees(), function (Form $form) { |
|||
$form->display('id'); |
|||
$form->text('user_id'); |
|||
$form->text('store_id'); |
|||
$form->text('market_id'); |
|||
$form->text('role'); |
|||
$form->text('status'); |
|||
$form->text('note'); |
|||
|
|||
$form->display('created_at'); |
|||
$form->display('updated_at'); |
|||
}); |
|||
} |
|||
} |
|||
@ -1,6 +1,6 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Forms; |
|||
namespace App\Admin\Forms\v3; |
|||
|
|||
use Dcat\Admin\Widgets\Form; |
|||
use Symfony\Component\HttpFoundation\Response; |
|||
@ -1,6 +1,6 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Forms; |
|||
namespace App\Admin\Forms\v3; |
|||
|
|||
use Dcat\Admin\Widgets\Form; |
|||
use Symfony\Component\HttpFoundation\Response; |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Repositories\v3; |
|||
|
|||
use App\Models\v3\LanzuEmployees as Model; |
|||
use Dcat\Admin\Repositories\EloquentRepository; |
|||
|
|||
class LanzuEmployees extends EloquentRepository |
|||
{ |
|||
/** |
|||
* Model. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $eloquentClass = Model::class; |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
<?php |
|||
|
|||
namespace App\Models\v3; |
|||
|
|||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
|||
use Illuminate\Database\Eloquent\SoftDeletes; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class LanzuEmployees extends Model |
|||
{ |
|||
use HasDateTimeFormatter; |
|||
use SoftDeletes; |
|||
|
|||
protected $table = 'lanzu_employees'; |
|||
protected $dateFormat = 'U'; |
|||
|
|||
/* 查询记录数 limit */ |
|||
protected $perPage = 10; |
|||
|
|||
public static $_TYPE= ['']; |
|||
public static $_STATUS = [-1=>'离职',0=>'禁用',1=>'正常']; |
|||
|
|||
protected $appends = [ |
|||
'is_rest_text', |
|||
'is_open_text' |
|||
]; |
|||
|
|||
public function getTypeTextAttribute($value) |
|||
{ |
|||
$value = $value ? $value : $this->type; |
|||
return isset(self::$_TYPE[$value]) ? self::$_TYPE[$value] : ''; |
|||
} |
|||
public function getIsRestTextAttribute($value) |
|||
{ |
|||
$value = $value ? $value : $this->status; |
|||
return isset(self::$_STATUS[$value]) ? self::$_STATUS[$value] : ''; |
|||
} |
|||
|
|||
/** |
|||
* 根据id获取单条信息 |
|||
* @param int $id |
|||
* @param string $field |
|||
* @return string |
|||
*/ |
|||
public static function getInfo($id,$field = '*') |
|||
{ |
|||
return self::select($field)->find($id); |
|||
} |
|||
|
|||
/** |
|||
* 获取数组 |
|||
* id为键 |
|||
* @return array |
|||
*/ |
|||
public static function getArray($where = [], $options = []) |
|||
{ |
|||
$model = self::whereNull('deleted_at'); |
|||
|
|||
if(!empty($where)){ |
|||
$model->where($where); |
|||
} |
|||
$list = $model->pluck('id','user_id')->toArray(); |
|||
if(!empty($options)){ |
|||
$new = array_merge($options,$list); |
|||
return array_flip($new); |
|||
}else{ |
|||
return array_flip($list); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
<?php |
|||
return [ |
|||
'labels' => [ |
|||
'LanzuEmployees' => '懒族员工', |
|||
'lanzuEmployees' => '懒族员工', |
|||
'lanzu_employees' => '懒族员工', |
|||
], |
|||
'fields' => [ |
|||
'user_id' => '用户懒ID', |
|||
'store_id' => '店铺', |
|||
'market_id' => '服务站ID', |
|||
'role' => '用户角色', |
|||
'status' => '状态', |
|||
'note' => '备注', |
|||
], |
|||
'options' => [ |
|||
], |
|||
]; |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue