增加下级数
This commit is contained in:
@@ -32,6 +32,7 @@ class IndexController extends AdminController
|
||||
protected function grid()
|
||||
{
|
||||
$user = Auth::guard('admin')->user();
|
||||
|
||||
$grid = new Grid(new User);
|
||||
$grid->model()->with(['parent']);
|
||||
$grid->actions(function ($actions) use ($user) {
|
||||
@@ -55,6 +56,8 @@ class IndexController extends AdminController
|
||||
|
||||
$grid->model()->orderBy('id', 'desc');
|
||||
|
||||
$grid->fixColumns(4, -1);
|
||||
|
||||
$grid->quickSearch('username')->placeholder('登录账户');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
@@ -95,9 +98,16 @@ class IndexController extends AdminController
|
||||
return $this->PaOutletId ?? '---';
|
||||
});
|
||||
|
||||
$grid->column('门店号')->display(function () {
|
||||
return $this->shop_id ?? '---';
|
||||
})->help('银联pos机配置的门店号');
|
||||
$grid->column('门店号')
|
||||
->display(function () {
|
||||
return $this->shop_id ?? '---';
|
||||
})
|
||||
->help('银联pos机配置的门店号');
|
||||
|
||||
$grid->column('下级网点数')
|
||||
->display(function () {
|
||||
return "<a href='/admin/users?server_id={$this->server_id}' style='font-size:16px'>{$this->children->count()}</a>";
|
||||
});
|
||||
|
||||
$grid->column('所属项目')->display(function () {
|
||||
return $this->type_text;
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace App\Models;
|
||||
use App\Models\Traits\HasAccount;
|
||||
use App\Models\Traits\HasArea;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -78,18 +80,18 @@ class User extends Authenticatable
|
||||
return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
protected function getNicknameAttribute()
|
||||
protected function getNicknameAttribute(): string
|
||||
{
|
||||
return $this->info ? $this->info->nickname : '';
|
||||
}
|
||||
|
||||
public function info()
|
||||
public function info(): HasOne
|
||||
{
|
||||
return $this->hasOne(UserInfo::class);
|
||||
}
|
||||
|
||||
//渠道商配置
|
||||
public function code()
|
||||
public function code(): HasMany
|
||||
{
|
||||
return $this->hasMany(UserCode::class);
|
||||
}
|
||||
@@ -99,6 +101,11 @@ class User extends Authenticatable
|
||||
return $this->hasOne(User::class, 'id', 'parent_id');
|
||||
}
|
||||
|
||||
public function children(): hasMany
|
||||
{
|
||||
return $this->hasMany(User::class, 'parent_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 密码加密
|
||||
* @Author: <C.Jason>
|
||||
|
||||
Reference in New Issue
Block a user