simplePaginate();
$grid->quickSearch(['id', 'user_id', 'path'])->placeholder('搜索id, 用户id,路径名...')->width(35);
$grid->column('id')->sortable();
$grid->column('users', '头像')->display(function ($v) {
if($this->user['user_avatar'] ?? '') {
return '
';
}
return '';
})->width('50px');
$grid->column('user')->display(function ($v) {
if($v && $v['user_name']){
return ''.$v['user_name'].'' ?? '用户已删除';
}
return '';
})->width('100px');
// $grid->column('path')->image('',80,200);
$grid->column('paths', '路径')->display(function () {
return ''. $this->domain . '/' . $this->path . '';
});
$grid->column('show', '路径')->display(function ($v) {
$url = $this->domain . '/' . $this->path;
if(StrUtils::endsWith($url, '.mp4')){
$file_type = 'video';
}else if(StrUtils::endsWith($url, ['.jpg', '.png', 'jpeg', '.webp', '.gif'])){
$file_type = 'image';
}else if(StrUtils::endsWith($url, ['.mp3'])){
$file_type = 'audio';
}else{
$file_type = 'other';
}
if(in_array($file_type, ['video', 'image', 'audio'])){
if($file_type == 'image'){
return '
';
}else if($file_type == 'audio'){
return '';
}else if($file_type == 'video'){
return '';
}
return '';
}
});
$grid->column('store_type','保存位置');
$grid->column('created_at');
$grid->column('cos_review')->using([0 => '正常', 1 => '确认违规', 2=> '疑似违规', 3=>'未审', 4=>'送审中', 5=>'待查询结果'])->label([
0 => '#5ac725',
1 => '#f56c6c',
2 => '#f9ae3d',
3 => 'gray',
4 => 'gray',
5 => 'gray'
])->display(function ($v){
if($this->cos_review == 4){
VideoCosReviewSubmit::dispatch($this->id);
}
return $v;
})->sortable();
$grid->column('state', '附件状态')->using([0 => '未引用', 1 => '已引用', 2=> '已清理', 3=>'cos冻结中', 4=>'cos已转移'])->label([
0 => 'red',
1 => 'primary',
2 => 'default',
3 => '#f9ae3d',
4 => '#f9ae3d'
])->sortable();
// $grid->column('updated_at');
$grid->model()->orderBy('id', 'desc');
$grid->filter(function (Grid\Filter $filter) {
$filter->equal('id');
$filter->equal('user_id');
});
// $grid->disableActions();
$grid->disableViewButton();
$grid->disableEditButton();
$grid->disableCreateButton();
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new WxAttachment(), function (Show $show) {
$show->field('id');
$show->field('path');
$show->field('cos_review');
$show->field('created_at');
$show->field('updated_at');
$show->disableEditButton();
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new WxAttachment(), function (Form $form) {
$form->display('id');
$form->text('path');
$form->deleting(function (Form $form){
global $__MINI_GLOBAL_TENANT_ID__;
if($__MINI_GLOBAL_TENANT_ID__ > 0){
return $form->response()->error('权限不足,不可以删除其他分站对象');
}
});
});
}
}