作者 开飞机的舒克

后台更新

... ... @@ -51,15 +51,15 @@ class Study extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['user','team'])
->with(['team','user'])
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->getRelation('user')->visible(['username']);
$row->getRelation('team')->visible(['title']);
$row->getRelation('team')->visible(['title']);
$row->getRelation('user')->visible(['username']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
... ...
... ... @@ -17,6 +17,6 @@ return [
'Qrcode' => '条形码',
'Createtime' => '创建时间',
'Updatetime' => '更新时间',
'User.username' => '用户名',
'Team.title' => '战队昵称'
'Team.title' => '战队昵称',
'User.username' => '用户名'
];
... ...
... ... @@ -46,14 +46,14 @@ class Study extends Model
public function user()
public function team()
{
return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
return $this->belongsTo('Team', 'team_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function team()
public function user()
{
return $this->belongsTo('Team', 'team_id', 'id', [], 'LEFT')->setEagerlyType(0);
return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
... ...
... ... @@ -71,7 +71,7 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Team_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-team_id" data-rule="required" data-source="team/index" class="form-control selectpage" name="row[team_id]" type="text" value="">
<input id="c-team_id" data-rule="required" data-source="team/index" class="form-control selectpage" data-field="title" name="row[team_id]" type="text" value="">
</div>
</div>
<div class="form-group">
... ...
... ... @@ -42,8 +42,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'qrcode', title: __('Qrcode'), operate: 'LIKE'},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'user.username', title: __('User.username'), operate: 'LIKE'},
{field: 'team.title', title: __('Team.title'), operate: 'LIKE'},
{field: 'user.username', title: __('User.username'), operate: 'LIKE'},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
... ...