'列表',
'show' => '详情',
'edit' => '编辑',
'create' => '创建',
];
protected function grid()
{
$grid = new Grid(new Dynamic());
$grid->id('ID')->sortable();
$grid->column('description', '内容')->limit(10);
$grid->column('topic.name', '所属话题');
$grid->column('user.lid', '发贴用户ID');
$grid->column('user.avatar', '用户头像')->image(config('love.QINIU_MY_DOMAINS'), 50, 50);
$grid->column('type', '类型')->display(function ($x) {
return $x == 1 ? '图片类型' : $x == 2 ? '视频类型' : '语音';
})->sortable();
$grid->column('like_size', '点赞数');
$grid->column('rose', '看需玫瑰');
$grid->column('view_size', '浏览数');
$grid->column('comment_size', '评论数');
$grid->column('status', '审核')->editable('select', [1 => '通过',0=>'申请']);
$grid->created_at('创建时间');
$grid->updated_at('修改时间');
$grid->disableExport();
$grid->disableRowSelector();
$grid->disableColumnSelector();
$grid->disableCreateButton();
$grid->expandFilter();
$grid->model()->orderBy('id', 'desc');
$grid->actions(function ($actions) {
$actions->disableEdit();
//$actions->disableEdit();
});
$grid->filter(function ($filter) {
$filter->disableIdFilter();
$filter->equal('user.lid','客户ID')->placeholder('请输入客户ID');
});
return $grid;
}
protected function form()
{
$form = new Form(new Dynamic);
$form->number('status', '审核')->rules('required|min:1');
return $form;
}
public function show($id,Content $content){
$d=Dynamic::findOrFail($id);
$show = new Show($d);
$show->user()->as(function ($u) {
return $u->name.'--ID'.$u->lid;
})->lable('发布用户');
$show->topic()->as(function ($u) {
return $u->name;
})->lable('所属话题');
$show->field('rose', '看次动态需玫瑰');
$show->addField('数量','数量')->as(function ($q)use($d){return '点赞数:'.$d->like_size.'浏览数:'.$d->view_size.'评论数:'.$d->comment_size;});
$show->field('description', trans('描述'));
$show->panel()->tools(function ($tools) {
$tools->disableEdit();
$tools->disableDelete();
});
if($d->type==3){
$show->files('语音')->unescape()->as(function ($u) use ($d) {
$a=Arr::pluck($u->toArray(),'file') ;
$url='';
foreach ($a as $k=>$v){
$k++;
$url.="语音文件{$k}--|";
}
return $url;
});
}
if($d->type==1){
$show->files('图片')->as(function ($u) {
return Arr::pluck($u->toArray(),'file') ;
})->carousel();
}
if($d->type==2){
$show->files('视频')->unescape()->as(function ($u) {
$a=Arr::pluck($u->toArray(),'file') ;
$url='';
foreach ($a as $k=>$v){
$k++;
$url.="视频文件{$k}--|";
}
return $url;
});
}
$show->comments('评论', function ($comments) {
$comments->id('ID')->sortable();
$comments->column('description', '内容')->limit(50);
$comments->column('user.lid', '发贴用户ID');
$comments->column('user.avatar', '用户头像')->image(config('love.QINIU_MY_DOMAINS'), 50, 50);
$comments->created_at('创建时间');
$comments->updated_at('修改时间');
$comments->disableExport();
$comments->disableRowSelector();
$comments->disableColumnSelector();
$comments->disableCreateButton();
$comments->actions(function ($actions) {
$actions->disableEdit();
$actions->disableView();
});
$comments->filter(function ($filter) {
$filter->disableIdFilter();
$filter->equal('user.lid','客户ID')->placeholder('请输入客户ID');
$filter->like('description')->placeholder('内容');
});
});
$show->like('点赞', function ($comments) {
$comments->id('ID')->sortable();
$comments->column('user.lid', '点赞用户ID');
$comments->column('user.avatar', '用户头像')->image(config('love.QINIU_MY_DOMAINS'), 50, 50);
$comments->created_at('创建时间');
$comments->updated_at('修改时间');
$comments->disableExport();
$comments->disableRowSelector();
$comments->disableColumnSelector();
$comments->disableCreateButton();
$comments->disableActions();
$comments->filter(function ($filter) {
$filter->disableIdFilter();
$filter->equal('user.lid','客户ID')->placeholder('请输入客户ID');
});
});
$show->pays('支付', function ($comments) {
$comments->id('ID')->sortable();
$comments->column('user.lid', '支付用户ID');
$comments->column('user.avatar', '用户头像')->image(config('love.QINIU_MY_DOMAINS'), 50, 50);
$comments->created_at('创建时间');
$comments->updated_at('修改时间');
$comments->disableExport();
$comments->disableRowSelector();
$comments->disableColumnSelector();
$comments->disableCreateButton();
$comments->disableActions();
$comments->filter(function ($filter) {
$filter->disableIdFilter();
$filter->equal('user.lid','客户ID')->placeholder('请输入客户ID');
});
});
return $content
->title($this->title)
->description($this->description['show'])
->row($show);
}
public function destroy($id)
{
Cache::forget('Topic');
$student=Dynamic::where('id',$id)->first();
$this->imsendmassage('admin',$student->uid,'动态被管理删除!请谨慎操作');
$student->delete();
if($student->trashed()){
$response = [
'status' => true,
'message' => trans('admin.delete_succeeded'),
];
}else{
$response = [
'status' => false,
'message' => '删除失败',
];
}
return response()->json($response);
}
public function delete($did,$id){
if(DynamicComment::where('id',$id)->delete()){
$response = [
'status' => true,
'message' => trans('admin.delete_succeeded'),
];
}else{
$response = [
'status' => false,
'message' => '删除失败',
];
}
return response()->json($response);
}
}