xiaogang 4 年之前
父节点
当前提交
7618c42a0b

+ 73 - 0
app/Admin/Controllers/ChatListController.php

xqd
@@ -0,0 +1,73 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\ChatList;
+use Dcat\Admin\Form;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Show;
+use Dcat\Admin\Http\Controllers\AdminController;
+
+class ChatListController extends AdminController
+{
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        return Grid::make(new ChatList(), function (Grid $grid) {
+            $grid->column('id')->sortable();
+            $grid->column('user_id');
+            $grid->column('to_user_id');
+            $grid->column('last_msg');
+            $grid->column('last_time');
+            $grid->column('atime');
+            $grid->column('un_read');
+        
+            $grid->filter(function (Grid\Filter $filter) {
+                $filter->equal('id');
+        
+            });
+        });
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     *
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        return Show::make($id, new ChatList(), function (Show $show) {
+            $show->field('id');
+            $show->field('user_id');
+            $show->field('to_user_id');
+            $show->field('last_msg');
+            $show->field('last_time');
+            $show->field('atime');
+            $show->field('un_read');
+        });
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        return Form::make(new ChatList(), function (Form $form) {
+            $form->display('id');
+            $form->text('user_id');
+            $form->text('to_user_id');
+            $form->text('last_msg');
+            $form->text('last_time');
+            $form->text('atime');
+            $form->text('un_read');
+        });
+    }
+}

+ 2 - 1
app/Http/Controllers/Api/ChatController.php

xqd xqd
@@ -4,6 +4,7 @@
 namespace App\Http\Controllers\Api;
 
 
+use App\Models\ChatList;
 use App\Models\User;
 use App\Services\TencentImAccountService;
 use App\Services\TencentImFriendService;
@@ -39,7 +40,7 @@ class ChatController extends Controller
                 throw new Exception("对方账户错误");
             }
             $res = $tencent_friend->friendAddItem($user->tencent_im_user_id,$request->tencent_im_user_id);
-            DB::table("chat_list")->firstOrCreate([
+            ChatList::query()->firstOrCreate([
                 'user_id'=>$user->id,
                 'to_user_id'=>$toUser->id,
                 'atime'=>date('Y-m-d H:i:s'),

+ 15 - 0
app/Models/ChatList.php

xqd
@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Models;
+
+use Dcat\Admin\Traits\HasDateTimeFormatter;
+
+use Illuminate\Database\Eloquent\Model;
+
+class ChatList extends Model
+{
+	use HasDateTimeFormatter;
+    protected $table = 'chat_list';
+    public $timestamps = false;
+
+}

+ 32 - 32
dcat_admin_ide_helper.php

xqd xqd xqd xqd xqd xqd xqd xqd
@@ -105,14 +105,6 @@ namespace Dcat\Admin {
      * @property Grid\Column|Collection con2
      * @property Grid\Column|Collection con3
      * @property Grid\Column|Collection con4
-     * @property Grid\Column|Collection figure
-     * @property Grid\Column|Collection feeling
-     * @property Grid\Column|Collection education
-     * @property Grid\Column|Collection income
-     * @property Grid\Column|Collection drink
-     * @property Grid\Column|Collection hobby
-     * @property Grid\Column|Collection photo
-     * @property Grid\Column|Collection video
      * @property Grid\Column|Collection nickname
      * @property Grid\Column|Collection birthday
      * @property Grid\Column|Collection height
@@ -121,6 +113,14 @@ namespace Dcat\Admin {
      * @property Grid\Column|Collection info
      * @property Grid\Column|Collection area
      * @property Grid\Column|Collection area_code
+     * @property Grid\Column|Collection figure
+     * @property Grid\Column|Collection feeling
+     * @property Grid\Column|Collection education
+     * @property Grid\Column|Collection income
+     * @property Grid\Column|Collection hobby
+     * @property Grid\Column|Collection drink
+     * @property Grid\Column|Collection photo
+     * @property Grid\Column|Collection video
      * @property Grid\Column|Collection weixin
      * @property Grid\Column|Collection like_id
      * @property Grid\Column|Collection look_id
@@ -229,14 +229,6 @@ namespace Dcat\Admin {
      * @method Grid\Column|Collection con2(string $label = null)
      * @method Grid\Column|Collection con3(string $label = null)
      * @method Grid\Column|Collection con4(string $label = null)
-     * @method Grid\Column|Collection figure(string $label = null)
-     * @method Grid\Column|Collection feeling(string $label = null)
-     * @method Grid\Column|Collection education(string $label = null)
-     * @method Grid\Column|Collection income(string $label = null)
-     * @method Grid\Column|Collection drink(string $label = null)
-     * @method Grid\Column|Collection hobby(string $label = null)
-     * @method Grid\Column|Collection photo(string $label = null)
-     * @method Grid\Column|Collection video(string $label = null)
      * @method Grid\Column|Collection nickname(string $label = null)
      * @method Grid\Column|Collection birthday(string $label = null)
      * @method Grid\Column|Collection height(string $label = null)
@@ -245,6 +237,14 @@ namespace Dcat\Admin {
      * @method Grid\Column|Collection info(string $label = null)
      * @method Grid\Column|Collection area(string $label = null)
      * @method Grid\Column|Collection area_code(string $label = null)
+     * @method Grid\Column|Collection figure(string $label = null)
+     * @method Grid\Column|Collection feeling(string $label = null)
+     * @method Grid\Column|Collection education(string $label = null)
+     * @method Grid\Column|Collection income(string $label = null)
+     * @method Grid\Column|Collection hobby(string $label = null)
+     * @method Grid\Column|Collection drink(string $label = null)
+     * @method Grid\Column|Collection photo(string $label = null)
+     * @method Grid\Column|Collection video(string $label = null)
      * @method Grid\Column|Collection weixin(string $label = null)
      * @method Grid\Column|Collection like_id(string $label = null)
      * @method Grid\Column|Collection look_id(string $label = null)
@@ -358,14 +358,6 @@ namespace Dcat\Admin {
      * @property Show\Field|Collection con2
      * @property Show\Field|Collection con3
      * @property Show\Field|Collection con4
-     * @property Show\Field|Collection figure
-     * @property Show\Field|Collection feeling
-     * @property Show\Field|Collection education
-     * @property Show\Field|Collection income
-     * @property Show\Field|Collection drink
-     * @property Show\Field|Collection hobby
-     * @property Show\Field|Collection photo
-     * @property Show\Field|Collection video
      * @property Show\Field|Collection nickname
      * @property Show\Field|Collection birthday
      * @property Show\Field|Collection height
@@ -374,6 +366,14 @@ namespace Dcat\Admin {
      * @property Show\Field|Collection info
      * @property Show\Field|Collection area
      * @property Show\Field|Collection area_code
+     * @property Show\Field|Collection figure
+     * @property Show\Field|Collection feeling
+     * @property Show\Field|Collection education
+     * @property Show\Field|Collection income
+     * @property Show\Field|Collection hobby
+     * @property Show\Field|Collection drink
+     * @property Show\Field|Collection photo
+     * @property Show\Field|Collection video
      * @property Show\Field|Collection weixin
      * @property Show\Field|Collection like_id
      * @property Show\Field|Collection look_id
@@ -482,14 +482,6 @@ namespace Dcat\Admin {
      * @method Show\Field|Collection con2(string $label = null)
      * @method Show\Field|Collection con3(string $label = null)
      * @method Show\Field|Collection con4(string $label = null)
-     * @method Show\Field|Collection figure(string $label = null)
-     * @method Show\Field|Collection feeling(string $label = null)
-     * @method Show\Field|Collection education(string $label = null)
-     * @method Show\Field|Collection income(string $label = null)
-     * @method Show\Field|Collection drink(string $label = null)
-     * @method Show\Field|Collection hobby(string $label = null)
-     * @method Show\Field|Collection photo(string $label = null)
-     * @method Show\Field|Collection video(string $label = null)
      * @method Show\Field|Collection nickname(string $label = null)
      * @method Show\Field|Collection birthday(string $label = null)
      * @method Show\Field|Collection height(string $label = null)
@@ -498,6 +490,14 @@ namespace Dcat\Admin {
      * @method Show\Field|Collection info(string $label = null)
      * @method Show\Field|Collection area(string $label = null)
      * @method Show\Field|Collection area_code(string $label = null)
+     * @method Show\Field|Collection figure(string $label = null)
+     * @method Show\Field|Collection feeling(string $label = null)
+     * @method Show\Field|Collection education(string $label = null)
+     * @method Show\Field|Collection income(string $label = null)
+     * @method Show\Field|Collection hobby(string $label = null)
+     * @method Show\Field|Collection drink(string $label = null)
+     * @method Show\Field|Collection photo(string $label = null)
+     * @method Show\Field|Collection video(string $label = null)
      * @method Show\Field|Collection weixin(string $label = null)
      * @method Show\Field|Collection like_id(string $label = null)
      * @method Show\Field|Collection look_id(string $label = null)

+ 17 - 0
resources/lang/zh_CN/chat-list.php

xqd
@@ -0,0 +1,17 @@
+<?php 
+return [
+    'labels' => [
+        'ChatList' => '聊天列表',
+        'chat-list' => '聊天列表',
+    ],
+    'fields' => [
+        'user_id' => '发消息的人',
+        'to_user_id' => '接收消息的人',
+        'last_msg' => '最后一条消息',
+        'last_time' => '上次发消息的时间',
+        'atime' => '聊天发起时间',
+        'un_read' => '未读消息数量',
+    ],
+    'options' => [
+    ],
+];