|
@@ -14,15 +14,24 @@ use Dcat\Admin\Show;
|
|
|
|
|
|
class DistMessageController extends AdminController
|
|
|
{
|
|
|
+ public function title()
|
|
|
+ {
|
|
|
+ return admin_trans('admin.messages');
|
|
|
+
|
|
|
+ }
|
|
|
/**
|
|
|
* page index
|
|
|
*/
|
|
|
public function index(Content $content)
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return $content
|
|
|
- ->header('列表')
|
|
|
- ->description('全部')
|
|
|
- ->breadcrumb(['text'=>'列表','url'=>''])
|
|
|
+
|
|
|
+ ->header(admin_trans( 'admin.messages'))
|
|
|
+ ->description(admin_trans('admin.all'))
|
|
|
+ ->breadcrumb(['text'=>'list','url'=>''])
|
|
|
->body($this->grid());
|
|
|
}
|
|
|
|
|
@@ -36,24 +45,30 @@ class DistMessageController extends AdminController
|
|
|
|
|
|
return Grid::make(new DistCustomMessage(), function (Grid $grid) {
|
|
|
|
|
|
+
|
|
|
// $grid->setActionClass(Grid\Displayers\Actions::class);
|
|
|
// // 添加“查看”按钮
|
|
|
// $grid->actions(function (Grid\Displayers\Actions $actions) {
|
|
|
// $actions->append('<a href="/dist/messages/' . $actions->row->id . '" class="btn btn-sm btn-primary">View Detail</a>');
|
|
|
// });
|
|
|
|
|
|
- $grid->column('created_at','time');
|
|
|
+ $grid->column('created_at',admin_trans_field('time'));
|
|
|
+
|
|
|
+ $grid->column('is_read', admin_trans_field('is_read'))->display(function ($isRead) {
|
|
|
+ $text = $isRead == 1 ? admin_trans_label('read') : "<strong>".admin_trans_label('unread')."</strong>";
|
|
|
+ return $text;
|
|
|
+ });
|
|
|
|
|
|
- $grid->column('title','message_title')->display(function ($title) {
|
|
|
+ $grid->column('title',admin_trans_field('message_title'))->display(function ($title) {
|
|
|
$isRead = $this->is_read;
|
|
|
$style = $isRead == 0 ? 'font-weight: bold;' : '';
|
|
|
$label = $isRead == 0 ? ' (Unread) ' : '';
|
|
|
- return "<span style='{$style}'>{$title} {$label}</span>";
|
|
|
+ return "<span style='{$style}'>{$title}</span>";
|
|
|
});
|
|
|
$grid->column('content');
|
|
|
- $grid->column('is_read');
|
|
|
|
|
|
- $grid->column('custom_column', admin_trans_field('action'))->display(function () {
|
|
|
+
|
|
|
+ $grid->column('custom_column', admin_trans('admin.action'))->display(function () {
|
|
|
return view('admin.grid.actions-view', ['id' => $this->id,'text'=>admin_trans('admin.view')]);
|
|
|
});
|
|
|
|
|
@@ -74,12 +89,16 @@ class DistMessageController extends AdminController
|
|
|
*/
|
|
|
protected function detail($id)
|
|
|
{
|
|
|
+
|
|
|
+ if(!DistCustomMessage::canViewMessage($id))
|
|
|
+ {
|
|
|
+ abort('403');
|
|
|
+ };
|
|
|
+
|
|
|
$this->markAsRead($id);
|
|
|
return Show::make($id, new DistMessage(), function (Show $show) {
|
|
|
//$show->field('id');
|
|
|
-
|
|
|
- //$show->field('sender_id');
|
|
|
- $show->field('created_at');
|
|
|
+ $show->field('created_at',admin_trans_field('time'));
|
|
|
$show->field('title');
|
|
|
$show->field('content');
|
|
|
// Disable all toolbar actions and buttons
|