Browse Source

后端增加消息管理页面

黄宗昌 2 năm trước cách đây
mục cha
commit
bf2c81a057

+ 82 - 0
app/Admin/Controllers/MsgController.php

xqd
@@ -0,0 +1,82 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Admin\Repositories\Msg;
+use Dcat\Admin\Form;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Show;
+use Dcat\Admin\Http\Controllers\AdminController;
+
+class MsgController extends AdminController
+{
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        return Grid::make(new Msg(), function (Grid $grid) {
+            $grid->model()->orderByDesc("id");
+            $grid->column('id')->sortable();
+//            $grid->column('type');
+//            $grid->column('user_id');
+//            $grid->column('to_user_id');
+            $grid->column('title');
+            $grid->column('content');
+            $grid->column('created_at');
+            $grid->column('updated_at')->sortable();
+            $grid->actions(function (Grid\Displayers\Actions $actions) {
+                $actions->disableEdit();
+                $actions->disableView();
+            });
+            $grid->filter(function (Grid\Filter $filter) {
+                $filter->panel();
+                $filter->like('title');
+                $filter->like('content');
+            });
+        });
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     *
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        return Show::make($id, new Msg(), function (Show $show) {
+            $show->field('id');
+            $show->field('type');
+            $show->field('user_id');
+            $show->field('to_user_id');
+            $show->field('title');
+            $show->field('content');
+            $show->field('created_at');
+            $show->field('updated_at');
+        });
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        return Form::make(new Msg(), function (Form $form) {
+            $form->display('id');
+            $form->hidden('type')->default(6);
+            $form->hidden('user_id')->default(0);
+            $form->hidden('to_user_id')->default(0);
+            $form->hidden('title')->default("系统通知");
+            $form->textarea('content');
+
+            $form->display('created_at');
+            $form->display('updated_at');
+        });
+    }
+}

+ 16 - 0
app/Admin/Repositories/Msg.php

xqd
@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Admin\Repositories;
+
+use App\Models\Msg as Model;
+use Dcat\Admin\Repositories\EloquentRepository;
+
+class Msg extends EloquentRepository
+{
+    /**
+     * Model.
+     *
+     * @var string
+     */
+    protected $eloquentClass = Model::class;
+}

+ 1 - 0
app/Admin/routes.php

xqd
@@ -22,4 +22,5 @@ Route::group([
     $router->resource('/report', 'ReportController'); //举报问题
     $router->resource('/report_log', 'ReportLogController'); //举报记录
     $router->resource('/setting', 'SettingController'); //系统设置
+    $router->resource('/msg', 'MsgController'); //消息
 });

+ 4 - 1
app/Http/Controllers/V1/MsgController.php

xqd
@@ -30,7 +30,10 @@ class MsgController extends Controller
 
         $limit = $request->get('limit',10);
 
-        $list = Msg::query()->with('user:id,name,avatar')->where('to_user_id',$this->userId)->paginate($limit);
+        $list = Msg::query()->with('user:id,name,avatar')->where('to_user_id',$this->userId)
+            ->orWhere('to_user_id',0)
+            ->orderByDesc("id")
+            ->paginate($limit);
 
         foreach ($list as $v){
             if($v){

+ 5 - 5
app/Models/Msg.php

xqd
@@ -1,15 +1,15 @@
 <?php
 
 namespace App\Models;
+
 use Dcat\Admin\Traits\HasDateTimeFormatter;
-use Illuminate\Database\Eloquent\Factories\HasFactory;
+
 use Illuminate\Database\Eloquent\Model;
+
 class Msg extends Model
 {
-    use HasDateTimeFormatter;
-    use HasFactory;
-
-    protected $table='msg';
+	use HasDateTimeFormatter;
+    protected $table = 'msg';
 
     protected $fillable = [
         'type',

+ 72 - 24
dcat_admin_ide_helper.php

xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -16,12 +16,10 @@ namespace Dcat\Admin {
      * @property Grid\Column|Collection value
      * @property Grid\Column|Collection id
      * @property Grid\Column|Collection name
-     * @property Grid\Column|Collection type
      * @property Grid\Column|Collection version
-     * @property Grid\Column|Collection detail
+     * @property Grid\Column|Collection is_enabled
      * @property Grid\Column|Collection created_at
      * @property Grid\Column|Collection updated_at
-     * @property Grid\Column|Collection is_enabled
      * @property Grid\Column|Collection parent_id
      * @property Grid\Column|Collection order
      * @property Grid\Column|Collection icon
@@ -75,7 +73,10 @@ namespace Dcat\Admin {
      * @property Grid\Column|Collection account
      * @property Grid\Column|Collection code
      * @property Grid\Column|Collection state
+     * @property Grid\Column|Collection type
+     * @property Grid\Column|Collection to_user_id
      * @property Grid\Column|Collection content
+     * @property Grid\Column|Collection msg_id
      * @property Grid\Column|Collection image
      * @property Grid\Column|Collection level
      * @property Grid\Column|Collection zh_alias
@@ -86,6 +87,8 @@ namespace Dcat\Admin {
      * @property Grid\Column|Collection is_filter_display
      * @property Grid\Column|Collection filter_display_pid
      * @property Grid\Column|Collection upload_display_pid
+     * @property Grid\Column|Collection product_id
+     * @property Grid\Column|Collection report_id
      * @property Grid\Column|Collection ko_title
      * @property Grid\Column|Collection desc
      * @property Grid\Column|Collection is_delete
@@ -95,10 +98,17 @@ namespace Dcat\Admin {
      * @property Grid\Column|Collection verify_key
      * @property Grid\Column|Collection sms_code
      * @property Grid\Column|Collection sms_result
+     * @property Grid\Column|Collection is_arrange
+     * @property Grid\Column|Collection images
+     * @property Grid\Column|Collection is_private
+     * @property Grid\Column|Collection is_del
+     * @property Grid\Column|Collection folder_id
      * @property Grid\Column|Collection pay_type
-     * @property Grid\Column|Collection start_time
-     * @property Grid\Column|Collection end_time
+     * @property Grid\Column|Collection days
      * @property Grid\Column|Collection money
+     * @property Grid\Column|Collection order_no
+     * @property Grid\Column|Collection pay_time
+     * @property Grid\Column|Collection month
      * @property Grid\Column|Collection nickname
      * @property Grid\Column|Collection email
      * @property Grid\Column|Collection online
@@ -108,7 +118,7 @@ namespace Dcat\Admin {
      * @property Grid\Column|Collection last_login_ip
      * @property Grid\Column|Collection register_ip
      * @property Grid\Column|Collection last_login_time
-     * @property Grid\Column|Collection member_id
+     * @property Grid\Column|Collection member_type
      * @property Grid\Column|Collection company_image
      * @property Grid\Column|Collection company_card_color
      * @property Grid\Column|Collection company_name
@@ -116,18 +126,18 @@ namespace Dcat\Admin {
      * @property Grid\Column|Collection company_url
      * @property Grid\Column|Collection company_phone
      * @property Grid\Column|Collection other_contacts
+     * @property Grid\Column|Collection start_time
+     * @property Grid\Column|Collection end_time
      *
      * @method Grid\Column|Collection ko_name(string $label = null)
      * @method Grid\Column|Collection zh_name(string $label = null)
      * @method Grid\Column|Collection value(string $label = null)
      * @method Grid\Column|Collection id(string $label = null)
      * @method Grid\Column|Collection name(string $label = null)
-     * @method Grid\Column|Collection type(string $label = null)
      * @method Grid\Column|Collection version(string $label = null)
-     * @method Grid\Column|Collection detail(string $label = null)
+     * @method Grid\Column|Collection is_enabled(string $label = null)
      * @method Grid\Column|Collection created_at(string $label = null)
      * @method Grid\Column|Collection updated_at(string $label = null)
-     * @method Grid\Column|Collection is_enabled(string $label = null)
      * @method Grid\Column|Collection parent_id(string $label = null)
      * @method Grid\Column|Collection order(string $label = null)
      * @method Grid\Column|Collection icon(string $label = null)
@@ -181,7 +191,10 @@ namespace Dcat\Admin {
      * @method Grid\Column|Collection account(string $label = null)
      * @method Grid\Column|Collection code(string $label = null)
      * @method Grid\Column|Collection state(string $label = null)
+     * @method Grid\Column|Collection type(string $label = null)
+     * @method Grid\Column|Collection to_user_id(string $label = null)
      * @method Grid\Column|Collection content(string $label = null)
+     * @method Grid\Column|Collection msg_id(string $label = null)
      * @method Grid\Column|Collection image(string $label = null)
      * @method Grid\Column|Collection level(string $label = null)
      * @method Grid\Column|Collection zh_alias(string $label = null)
@@ -192,6 +205,8 @@ namespace Dcat\Admin {
      * @method Grid\Column|Collection is_filter_display(string $label = null)
      * @method Grid\Column|Collection filter_display_pid(string $label = null)
      * @method Grid\Column|Collection upload_display_pid(string $label = null)
+     * @method Grid\Column|Collection product_id(string $label = null)
+     * @method Grid\Column|Collection report_id(string $label = null)
      * @method Grid\Column|Collection ko_title(string $label = null)
      * @method Grid\Column|Collection desc(string $label = null)
      * @method Grid\Column|Collection is_delete(string $label = null)
@@ -201,10 +216,17 @@ namespace Dcat\Admin {
      * @method Grid\Column|Collection verify_key(string $label = null)
      * @method Grid\Column|Collection sms_code(string $label = null)
      * @method Grid\Column|Collection sms_result(string $label = null)
+     * @method Grid\Column|Collection is_arrange(string $label = null)
+     * @method Grid\Column|Collection images(string $label = null)
+     * @method Grid\Column|Collection is_private(string $label = null)
+     * @method Grid\Column|Collection is_del(string $label = null)
+     * @method Grid\Column|Collection folder_id(string $label = null)
      * @method Grid\Column|Collection pay_type(string $label = null)
-     * @method Grid\Column|Collection start_time(string $label = null)
-     * @method Grid\Column|Collection end_time(string $label = null)
+     * @method Grid\Column|Collection days(string $label = null)
      * @method Grid\Column|Collection money(string $label = null)
+     * @method Grid\Column|Collection order_no(string $label = null)
+     * @method Grid\Column|Collection pay_time(string $label = null)
+     * @method Grid\Column|Collection month(string $label = null)
      * @method Grid\Column|Collection nickname(string $label = null)
      * @method Grid\Column|Collection email(string $label = null)
      * @method Grid\Column|Collection online(string $label = null)
@@ -214,7 +236,7 @@ namespace Dcat\Admin {
      * @method Grid\Column|Collection last_login_ip(string $label = null)
      * @method Grid\Column|Collection register_ip(string $label = null)
      * @method Grid\Column|Collection last_login_time(string $label = null)
-     * @method Grid\Column|Collection member_id(string $label = null)
+     * @method Grid\Column|Collection member_type(string $label = null)
      * @method Grid\Column|Collection company_image(string $label = null)
      * @method Grid\Column|Collection company_card_color(string $label = null)
      * @method Grid\Column|Collection company_name(string $label = null)
@@ -222,6 +244,8 @@ namespace Dcat\Admin {
      * @method Grid\Column|Collection company_url(string $label = null)
      * @method Grid\Column|Collection company_phone(string $label = null)
      * @method Grid\Column|Collection other_contacts(string $label = null)
+     * @method Grid\Column|Collection start_time(string $label = null)
+     * @method Grid\Column|Collection end_time(string $label = null)
      */
     class Grid {}
 
@@ -233,12 +257,10 @@ namespace Dcat\Admin {
      * @property Show\Field|Collection value
      * @property Show\Field|Collection id
      * @property Show\Field|Collection name
-     * @property Show\Field|Collection type
      * @property Show\Field|Collection version
-     * @property Show\Field|Collection detail
+     * @property Show\Field|Collection is_enabled
      * @property Show\Field|Collection created_at
      * @property Show\Field|Collection updated_at
-     * @property Show\Field|Collection is_enabled
      * @property Show\Field|Collection parent_id
      * @property Show\Field|Collection order
      * @property Show\Field|Collection icon
@@ -292,7 +314,10 @@ namespace Dcat\Admin {
      * @property Show\Field|Collection account
      * @property Show\Field|Collection code
      * @property Show\Field|Collection state
+     * @property Show\Field|Collection type
+     * @property Show\Field|Collection to_user_id
      * @property Show\Field|Collection content
+     * @property Show\Field|Collection msg_id
      * @property Show\Field|Collection image
      * @property Show\Field|Collection level
      * @property Show\Field|Collection zh_alias
@@ -303,6 +328,8 @@ namespace Dcat\Admin {
      * @property Show\Field|Collection is_filter_display
      * @property Show\Field|Collection filter_display_pid
      * @property Show\Field|Collection upload_display_pid
+     * @property Show\Field|Collection product_id
+     * @property Show\Field|Collection report_id
      * @property Show\Field|Collection ko_title
      * @property Show\Field|Collection desc
      * @property Show\Field|Collection is_delete
@@ -312,10 +339,17 @@ namespace Dcat\Admin {
      * @property Show\Field|Collection verify_key
      * @property Show\Field|Collection sms_code
      * @property Show\Field|Collection sms_result
+     * @property Show\Field|Collection is_arrange
+     * @property Show\Field|Collection images
+     * @property Show\Field|Collection is_private
+     * @property Show\Field|Collection is_del
+     * @property Show\Field|Collection folder_id
      * @property Show\Field|Collection pay_type
-     * @property Show\Field|Collection start_time
-     * @property Show\Field|Collection end_time
+     * @property Show\Field|Collection days
      * @property Show\Field|Collection money
+     * @property Show\Field|Collection order_no
+     * @property Show\Field|Collection pay_time
+     * @property Show\Field|Collection month
      * @property Show\Field|Collection nickname
      * @property Show\Field|Collection email
      * @property Show\Field|Collection online
@@ -325,7 +359,7 @@ namespace Dcat\Admin {
      * @property Show\Field|Collection last_login_ip
      * @property Show\Field|Collection register_ip
      * @property Show\Field|Collection last_login_time
-     * @property Show\Field|Collection member_id
+     * @property Show\Field|Collection member_type
      * @property Show\Field|Collection company_image
      * @property Show\Field|Collection company_card_color
      * @property Show\Field|Collection company_name
@@ -333,18 +367,18 @@ namespace Dcat\Admin {
      * @property Show\Field|Collection company_url
      * @property Show\Field|Collection company_phone
      * @property Show\Field|Collection other_contacts
+     * @property Show\Field|Collection start_time
+     * @property Show\Field|Collection end_time
      *
      * @method Show\Field|Collection ko_name(string $label = null)
      * @method Show\Field|Collection zh_name(string $label = null)
      * @method Show\Field|Collection value(string $label = null)
      * @method Show\Field|Collection id(string $label = null)
      * @method Show\Field|Collection name(string $label = null)
-     * @method Show\Field|Collection type(string $label = null)
      * @method Show\Field|Collection version(string $label = null)
-     * @method Show\Field|Collection detail(string $label = null)
+     * @method Show\Field|Collection is_enabled(string $label = null)
      * @method Show\Field|Collection created_at(string $label = null)
      * @method Show\Field|Collection updated_at(string $label = null)
-     * @method Show\Field|Collection is_enabled(string $label = null)
      * @method Show\Field|Collection parent_id(string $label = null)
      * @method Show\Field|Collection order(string $label = null)
      * @method Show\Field|Collection icon(string $label = null)
@@ -398,7 +432,10 @@ namespace Dcat\Admin {
      * @method Show\Field|Collection account(string $label = null)
      * @method Show\Field|Collection code(string $label = null)
      * @method Show\Field|Collection state(string $label = null)
+     * @method Show\Field|Collection type(string $label = null)
+     * @method Show\Field|Collection to_user_id(string $label = null)
      * @method Show\Field|Collection content(string $label = null)
+     * @method Show\Field|Collection msg_id(string $label = null)
      * @method Show\Field|Collection image(string $label = null)
      * @method Show\Field|Collection level(string $label = null)
      * @method Show\Field|Collection zh_alias(string $label = null)
@@ -409,6 +446,8 @@ namespace Dcat\Admin {
      * @method Show\Field|Collection is_filter_display(string $label = null)
      * @method Show\Field|Collection filter_display_pid(string $label = null)
      * @method Show\Field|Collection upload_display_pid(string $label = null)
+     * @method Show\Field|Collection product_id(string $label = null)
+     * @method Show\Field|Collection report_id(string $label = null)
      * @method Show\Field|Collection ko_title(string $label = null)
      * @method Show\Field|Collection desc(string $label = null)
      * @method Show\Field|Collection is_delete(string $label = null)
@@ -418,10 +457,17 @@ namespace Dcat\Admin {
      * @method Show\Field|Collection verify_key(string $label = null)
      * @method Show\Field|Collection sms_code(string $label = null)
      * @method Show\Field|Collection sms_result(string $label = null)
+     * @method Show\Field|Collection is_arrange(string $label = null)
+     * @method Show\Field|Collection images(string $label = null)
+     * @method Show\Field|Collection is_private(string $label = null)
+     * @method Show\Field|Collection is_del(string $label = null)
+     * @method Show\Field|Collection folder_id(string $label = null)
      * @method Show\Field|Collection pay_type(string $label = null)
-     * @method Show\Field|Collection start_time(string $label = null)
-     * @method Show\Field|Collection end_time(string $label = null)
+     * @method Show\Field|Collection days(string $label = null)
      * @method Show\Field|Collection money(string $label = null)
+     * @method Show\Field|Collection order_no(string $label = null)
+     * @method Show\Field|Collection pay_time(string $label = null)
+     * @method Show\Field|Collection month(string $label = null)
      * @method Show\Field|Collection nickname(string $label = null)
      * @method Show\Field|Collection email(string $label = null)
      * @method Show\Field|Collection online(string $label = null)
@@ -431,7 +477,7 @@ namespace Dcat\Admin {
      * @method Show\Field|Collection last_login_ip(string $label = null)
      * @method Show\Field|Collection register_ip(string $label = null)
      * @method Show\Field|Collection last_login_time(string $label = null)
-     * @method Show\Field|Collection member_id(string $label = null)
+     * @method Show\Field|Collection member_type(string $label = null)
      * @method Show\Field|Collection company_image(string $label = null)
      * @method Show\Field|Collection company_card_color(string $label = null)
      * @method Show\Field|Collection company_name(string $label = null)
@@ -439,6 +485,8 @@ namespace Dcat\Admin {
      * @method Show\Field|Collection company_url(string $label = null)
      * @method Show\Field|Collection company_phone(string $label = null)
      * @method Show\Field|Collection other_contacts(string $label = null)
+     * @method Show\Field|Collection start_time(string $label = null)
+     * @method Show\Field|Collection end_time(string $label = null)
      */
     class Show {}
 

+ 2 - 1
resources/lang/ko/menu.php

xqd
@@ -26,6 +26,7 @@ return [
         'user_member' => '회원 종류',
         'reports' => '고발',
         'report' => '문제를 고발하다',
-        'report_log' => '고발 기록'
+        'report_log' => '고발 기록',
+        'msg' => '소식',
     ],
 ];

+ 16 - 0
resources/lang/ko/msg.php

xqd
@@ -0,0 +1,16 @@
+<?php
+return [
+    'labels' => [
+        'Msg' => '메시지 관리',
+        'msg' => '메시지 관리',
+    ],
+    'fields' => [
+        'type' => '유형',
+        'user_id' => '사용자 id',
+        'to_user_id' => '메시지 받는 사용자 id',
+        'title' => '제목',
+        'content' => '내용',
+    ],
+    'options' => [
+    ],
+];

+ 2 - 1
resources/lang/zh/menu.php

xqd
@@ -27,6 +27,7 @@ return [
         'user_member_order' => '续费订单',
         'reports' => '举报',
         'report' => '举报问题',
-        'report_log' => '举报记录'
+        'report_log' => '举报记录',
+        'msg' => '消息',
     ],
 ];

+ 16 - 0
resources/lang/zh/msg.php

xqd
@@ -0,0 +1,16 @@
+<?php
+return [
+    'labels' => [
+        'Msg' => '消息管理',
+        'msg' => '消息管理',
+    ],
+    'fields' => [
+        'type' => '类型',
+        'user_id' => '用户ID',
+        'to_user_id' => '接收消息用户ID',
+        'title' => '标题',
+        'content' => '内容',
+    ],
+    'options' => [
+    ],
+];