xiaogang 4 anni fa
parent
commit
888d9188eb

+ 14 - 0
app/Admin/Actions/Dynamic/TagList.php

xqd
@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Admin\Actions\Dynamic;
+use Dcat\Admin\Grid\RowAction;
+
+class TagList extends RowAction
+{
+    public $title = '<i class="feather icon-grid"></i>动态列表';
+
+    public function href()
+    {
+        return '/admin/dynamic?tag='.$this->row->id;
+    }
+}

+ 96 - 10
app/Admin/Controllers/DynamicController.php

xqd xqd xqd xqd
@@ -3,10 +3,12 @@
 namespace App\Admin\Controllers;
 
 use App\Models\DynamicModel;
+use App\Models\DynamicTag;
 use Dcat\Admin\Form;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Show;
 use Dcat\Admin\Http\Controllers\AdminController;
+use Illuminate\Support\Facades\DB;
 
 class DynamicController extends AdminController
 {
@@ -39,16 +41,42 @@ class DynamicController extends AdminController
                 return "";
             }
         });
-        $grid->column('content','动态内容');
+        $grid->tableCollapse(false);
+        $grid->column('content','动态内容')->limit(30);
         $grid->column('zan_num');
-        $grid->column('site');
-        $grid->column('tag');
+        $grid->column('city','所在位置');
+        $grid->column('status','状态')->switch();
+        $grid->column('tag')->display(function ($res){
+            $tag = DB::table("dynamic_tag")->whereIn('id',explode(',',$res))->get();
+            $str = '<div>';
+            foreach ($tag as $k=>$v){
+                $str .= '<span class="label" style="background:#21b978;margin-right: 5px">'.$v->title.'</span>';
+            }
+            $str .= '</div>';
+            return $str;
+        });
+        $grid->column('created_at','发布时间');
 
         $grid->filter(function (Grid\Filter $filter) {
             $filter->equal('id');
         });
 
         $grid->disableCreateButton();
+
+        $grid->filter(function (Grid\Filter $filter) {
+            $filter->equal('user_id','用户ID');
+            $filter->like('user_info.nickname','用户昵称');
+            $filter->like('user.mobile','手机号');
+            $filter->like('content','内容');
+            $filter->between('created_at', '发布时间')->datetime();
+
+            $tag = DynamicTag::query()->get();
+            $tag_arr = array();
+            foreach ($tag as $v){
+                $tag_arr[$v['id']] = $v['title'];
+            }
+            $filter->like('tag', '标签')->select($tag_arr);
+        });
         return $grid;
     }
 
@@ -61,14 +89,73 @@ class DynamicController extends AdminController
      */
     protected function detail($id)
     {
+
         return Show::make($id, new DynamicModel(), function (Show $show) {
             $show->field('id');
-            $show->field('user_id');
-            $show->field('img_url');
-            $show->field('status');
+            $show->field('user_id','用户ID');
+            $show->html(function ($res){
+                $str = "";
+                if($res['img_url']){
+                    $res = json_decode($res['img_url'],true);
+                    if(count($res)>0){
+
+                        foreach ($res as $k=>$v){
+                            $str.='<img data-action="preview-img" src="'.$v.'" style="max-width:100px;max-height:100px;cursor:pointer" class="img img-thumbnail">';
+                        }
+                    }else{
+                        $str = "无";
+                    }
+                }else{
+                    $str = "无";
+                }
+                $html = '<div class="show-field form-group row">
+                    <div class="col-sm-2 control-label">
+                        <span>图片</span>
+                    </div>
+
+                    <div class="col-sm-8">
+                        <div class="box box-solid box-default no-margin box-show">
+                            <div class="box-body">
+                                      '.$str.'
+                            </div>
+                        </div>
+                    </div>
+                </div>';
+                return $html;
+            });
+            $show->field('content')->unescape();
+//            $show->field('status');
             $show->field('zan_num');
-            $show->field('site');
-            $show->field('tag');
+            $show->html(function ($res){
+                $str = "";
+                $tag = DB::table("dynamic_tag")->whereIn('id',[$res['tag']])->get();
+
+                if(count($tag)>0){
+                    foreach ($tag as $k=>$v){
+                        $str .= '<span class="label" style="background:#21b978;margin-right: 5px">'.$v->title.'</span>';
+                    }
+                }else{
+                    $str = "无";
+                }
+
+                $html = '<div class="show-field form-group row">
+                    <div class="col-sm-2 control-label">
+                        <span>标签</span>
+                    </div>
+
+                    <div class="col-sm-8">
+                        <div class="box box-solid box-default no-margin box-show">
+                            <div class="box-body">
+                                      '.$str.'
+                            </div>
+                        </div>
+                    </div>
+                </div>';
+                return $html;
+            });
+            $show->field('city','城市');
+//            $show->field('latitude','纬度');
+//            $show->field('longitude','经度');
         });
     }
 
@@ -83,9 +170,8 @@ class DynamicController extends AdminController
             $form->display('id');
             $form->text('user_id');
             $form->text('img_url');
-            $form->text('status');
+            $form->switch('status')->default(1);
             $form->text('zan_num');
-            $form->text('site');
             $form->text('tag');
         });
     }

+ 67 - 0
app/Admin/Controllers/DynamicTagController.php

xqd
@@ -0,0 +1,67 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Admin\Actions\Dynamic\TagList;
+use App\Models\DynamicTag;
+use Dcat\Admin\Form;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Show;
+use Dcat\Admin\Http\Controllers\AdminController;
+
+class DynamicTagController extends AdminController
+{
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new DynamicTag());
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id')->sortable();
+        $grid->column('title');
+        $grid->column('hot');
+
+        $grid->filter(function (Grid\Filter $filter) {
+            $filter->equal('id');
+            $filter->like('title','话题内容');
+        });
+
+        $grid->actions(function (Grid\Displayers\Actions $actions) {
+            $actions->append(new TagList());
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     *
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        return Show::make($id, new DynamicTag(), function (Show $show) {
+            $show->field('id');
+            $show->field('title');
+            $show->field('hot');
+        });
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        return Form::make(new DynamicTag(), function (Form $form) {
+            $form->display('id');
+            $form->text('title');
+            $form->text('hot')->default(0);
+        });
+    }
+}

+ 75 - 0
app/Admin/Controllers/VipController.php

xqd
@@ -0,0 +1,75 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\Vip;
+use App\Models\VipModel;
+use Dcat\Admin\Form;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Http\Controllers\AdminController;
+use Dcat\Admin\Show;
+
+class VipController extends AdminController
+{
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        return Grid::make(new VipModel(), function (Grid $grid) {
+            $grid->column('id')->sortable();
+            $grid->column('title');
+            $grid->column('price');
+            $grid->column('day');
+            $grid->column('day_price');
+            $grid->column('rights')->display(function ($res){
+
+            });
+            $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 VipModel(), function (Show $show) {
+            $show->field('id');
+            $show->field('title');
+            $show->field('price');
+            $show->field('day');
+            $show->field('day_price');
+            $show->field('rights');
+        });
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        return Form::make(new VipModel(), function (Form $form) {
+            $form->display('id');
+            $form->text('title');
+            $form->text('price');
+            $form->text('day');
+            $form->text('day_price');
+            $form->array('rights', function ($form) {
+                $form->image('img_url','权益图片');
+                $form->text('title','权益名称');
+            })->saveAsJson();
+        });
+    }
+}

+ 2 - 0
app/Admin/routes.php

xqd
@@ -16,4 +16,6 @@ Route::group([
     $router->resource('/banner', 'BannerController');
     $router->resource('/users', 'UserController');
     $router->resource('/dynamic', 'DynamicController');
+    $router->resource('/dynamic-tag', 'DynamicTagController');
+    $router->resource('/vip', 'VipController');
 });

+ 6 - 0
app/Models/BaseModel.php

xqd xqd
@@ -2,6 +2,7 @@
 
 namespace App\Models;
 
+use DateTimeInterface;
 use Illuminate\Database\Eloquent\Model;
 use Spatie\Activitylog\Traits\LogsActivity;
 class BaseModel extends Model
@@ -10,4 +11,9 @@ class BaseModel extends Model
     use LogsActivity;
     protected static $logName = 'Model';
     protected static $logAttributes = ['*'];
+
+    protected function serializeDate(DateTimeInterface $date)
+    {
+        return $date->format('Y-m-d H:i:s');
+    }
 }

+ 15 - 0
app/Models/DynamicTag.php

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

+ 1 - 1
app/Services/DynamicService.php

xqd
@@ -119,7 +119,7 @@ class DynamicService
 
             $dynamic['data'][$k]['distance'] = 0;
             $dynamic['data'][$k]['atime'] = uc_time_ago(strtotime($v['created_at']));
-            $dynamic['data'][$k]['tag'] = DB::table("dynamic_tag")->whereIn('id',[$v['tag']])->get();
+            $dynamic['data'][$k]['tag'] = DB::table("dynamic_tag")->whereIn('id',explode(',',$v['tag']))->get();
 
             $is_zan = 0;
             if($user = auth('api')->user()){

+ 1 - 1
app/Services/HomeService.php

xqd
@@ -75,7 +75,7 @@ class HomeService
             ->where('users.id',$user_id)
             ->select(['users.id','users.sex','users.is_auth','users.is_vip','users.tencent_im_user_id','users.online','users_info.*'])
             ->first();
-        $userinfo->hobby = explode(',',$userinfo->hobby);
+        $userinfo->hobby = !empty($userinfo->hobby)?explode(',',$userinfo->hobby):"";
         $userinfo->photo = json_decode($userinfo->photo,true);
         $userinfo->video = json_decode($userinfo->video,true);
 

+ 12 - 12
dcat_admin_ide_helper.php

xqd xqd xqd xqd xqd xqd xqd xqd
@@ -62,6 +62,9 @@ namespace Dcat\Admin {
      * @property Grid\Column|Collection content
      * @property Grid\Column|Collection zan_num
      * @property Grid\Column|Collection tag
+     * @property Grid\Column|Collection city
+     * @property Grid\Column|Collection latitude
+     * @property Grid\Column|Collection longitude
      * @property Grid\Column|Collection hot
      * @property Grid\Column|Collection dynamic_id
      * @property Grid\Column|Collection uuid
@@ -91,9 +94,6 @@ namespace Dcat\Admin {
      * @property Grid\Column|Collection ycode
      * @property Grid\Column|Collection last_login_time
      * @property Grid\Column|Collection last_login_ip
-     * @property Grid\Column|Collection city
-     * @property Grid\Column|Collection latitude
-     * @property Grid\Column|Collection longitude
      * @property Grid\Column|Collection online
      * @property Grid\Column|Collection notice_status
      * @property Grid\Column|Collection like_num
@@ -181,6 +181,9 @@ namespace Dcat\Admin {
      * @method Grid\Column|Collection content(string $label = null)
      * @method Grid\Column|Collection zan_num(string $label = null)
      * @method Grid\Column|Collection tag(string $label = null)
+     * @method Grid\Column|Collection city(string $label = null)
+     * @method Grid\Column|Collection latitude(string $label = null)
+     * @method Grid\Column|Collection longitude(string $label = null)
      * @method Grid\Column|Collection hot(string $label = null)
      * @method Grid\Column|Collection dynamic_id(string $label = null)
      * @method Grid\Column|Collection uuid(string $label = null)
@@ -210,9 +213,6 @@ namespace Dcat\Admin {
      * @method Grid\Column|Collection ycode(string $label = null)
      * @method Grid\Column|Collection last_login_time(string $label = null)
      * @method Grid\Column|Collection last_login_ip(string $label = null)
-     * @method Grid\Column|Collection city(string $label = null)
-     * @method Grid\Column|Collection latitude(string $label = null)
-     * @method Grid\Column|Collection longitude(string $label = null)
      * @method Grid\Column|Collection online(string $label = null)
      * @method Grid\Column|Collection notice_status(string $label = null)
      * @method Grid\Column|Collection like_num(string $label = null)
@@ -305,6 +305,9 @@ namespace Dcat\Admin {
      * @property Show\Field|Collection content
      * @property Show\Field|Collection zan_num
      * @property Show\Field|Collection tag
+     * @property Show\Field|Collection city
+     * @property Show\Field|Collection latitude
+     * @property Show\Field|Collection longitude
      * @property Show\Field|Collection hot
      * @property Show\Field|Collection dynamic_id
      * @property Show\Field|Collection uuid
@@ -334,9 +337,6 @@ namespace Dcat\Admin {
      * @property Show\Field|Collection ycode
      * @property Show\Field|Collection last_login_time
      * @property Show\Field|Collection last_login_ip
-     * @property Show\Field|Collection city
-     * @property Show\Field|Collection latitude
-     * @property Show\Field|Collection longitude
      * @property Show\Field|Collection online
      * @property Show\Field|Collection notice_status
      * @property Show\Field|Collection like_num
@@ -424,6 +424,9 @@ namespace Dcat\Admin {
      * @method Show\Field|Collection content(string $label = null)
      * @method Show\Field|Collection zan_num(string $label = null)
      * @method Show\Field|Collection tag(string $label = null)
+     * @method Show\Field|Collection city(string $label = null)
+     * @method Show\Field|Collection latitude(string $label = null)
+     * @method Show\Field|Collection longitude(string $label = null)
      * @method Show\Field|Collection hot(string $label = null)
      * @method Show\Field|Collection dynamic_id(string $label = null)
      * @method Show\Field|Collection uuid(string $label = null)
@@ -453,9 +456,6 @@ namespace Dcat\Admin {
      * @method Show\Field|Collection ycode(string $label = null)
      * @method Show\Field|Collection last_login_time(string $label = null)
      * @method Show\Field|Collection last_login_ip(string $label = null)
-     * @method Show\Field|Collection city(string $label = null)
-     * @method Show\Field|Collection latitude(string $label = null)
-     * @method Show\Field|Collection longitude(string $label = null)
      * @method Show\Field|Collection online(string $label = null)
      * @method Show\Field|Collection notice_status(string $label = null)
      * @method Show\Field|Collection like_num(string $label = null)

+ 15 - 0
resources/lang/zh_CN/banner.php

xqd
@@ -0,0 +1,15 @@
+<?php 
+return [
+    'labels' => [
+        'Banner' => 'Banner',
+        'banner' => 'Banner',
+    ],
+    'fields' => [
+        'title' => '名称',
+        'img_url' => '图片展示',
+        'site' => '位置',
+        'status' => '状态',
+    ],
+    'options' => [
+    ],
+];

+ 13 - 0
resources/lang/zh_CN/dynamic-tag.php

xqd
@@ -0,0 +1,13 @@
+<?php
+return [
+    'labels' => [
+        'DynamicTag' => '动态话题',
+        'dynamic-tag' => '动态话题',
+    ],
+    'fields' => [
+        'title' => '话题内容',
+        'hot' => '热度',
+    ],
+    'options' => [
+    ],
+];

+ 17 - 0
resources/lang/zh_CN/dynamic.php

xqd
@@ -0,0 +1,17 @@
+<?php
+return [
+    'labels' => [
+        'Dynamic' => '动态',
+        'dynamic' => '动态',
+    ],
+    'fields' => [
+        'user_id' => '用户ID',
+        'img_url' => '图片',
+        'status' => '状态',
+        'zan_num' => '点赞数量',
+        'site' => '位置信息',
+        'tag' => '标签',
+    ],
+    'options' => [
+    ],
+];

+ 16 - 0
resources/lang/zh_CN/vip.php

xqd
@@ -0,0 +1,16 @@
+<?php
+return [
+    'labels' => [
+        'Vip' => 'VIP设置',
+        'vip' => 'VIP设置',
+    ],
+    'fields' => [
+        'title' => '套餐名称',
+        'price' => '价格(元)',
+        'day' => '会员期限(天)',
+        'day_price' => '每天价格(元)',
+        'rights' => '权益',
+    ],
+    'options' => [
+    ],
+];