正在显示
1 个修改的文件
包含
31 行增加
和
19 行删除
@@ -11,7 +11,7 @@ use app\common\controller\Backend; | @@ -11,7 +11,7 @@ use app\common\controller\Backend; | ||
11 | */ | 11 | */ |
12 | class SellerTalk extends Backend | 12 | class SellerTalk extends Backend |
13 | { | 13 | { |
14 | - | 14 | + |
15 | /** | 15 | /** |
16 | * SellerTalk模型对象 | 16 | * SellerTalk模型对象 |
17 | * @var \app\admin\model\SellerTalk | 17 | * @var \app\admin\model\SellerTalk |
@@ -24,13 +24,13 @@ class SellerTalk extends Backend | @@ -24,13 +24,13 @@ class SellerTalk extends Backend | ||
24 | $this->model = new \app\admin\model\SellerTalk; | 24 | $this->model = new \app\admin\model\SellerTalk; |
25 | 25 | ||
26 | } | 26 | } |
27 | - | 27 | + |
28 | /** | 28 | /** |
29 | * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 | 29 | * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 |
30 | * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | 30 | * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 |
31 | * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | 31 | * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 |
32 | */ | 32 | */ |
33 | - | 33 | + |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * 查看 | 36 | * 查看 |
@@ -41,32 +41,34 @@ class SellerTalk extends Backend | @@ -41,32 +41,34 @@ class SellerTalk extends Backend | ||
41 | $this->relationSearch = true; | 41 | $this->relationSearch = true; |
42 | //设置过滤方法 | 42 | //设置过滤方法 |
43 | $this->request->filter(['strip_tags', 'trim']); | 43 | $this->request->filter(['strip_tags', 'trim']); |
44 | - if ($this->request->isAjax()) | ||
45 | - { | 44 | + if ($this->request->isAjax()) { |
46 | //如果发送的来源是Selectpage,则转发到Selectpage | 45 | //如果发送的来源是Selectpage,则转发到Selectpage |
47 | - if ($this->request->request('keyField')) | ||
48 | - { | 46 | + if ($this->request->request('keyField')) { |
49 | return $this->selectpage(); | 47 | return $this->selectpage(); |
50 | } | 48 | } |
51 | list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | 49 | list($where, $sort, $order, $offset, $limit) = $this->buildparams(); |
52 | $total = $this->model | 50 | $total = $this->model |
53 | - ->with(['user','seller']) | ||
54 | - ->where($where) | ||
55 | - ->order($sort, $order) | ||
56 | - ->count(); | 51 | + ->with(['user', 'seller']) |
52 | + ->where($where) | ||
53 | + ->order($sort, $order) | ||
54 | + ->count(); | ||
57 | 55 | ||
58 | $list = $this->model | 56 | $list = $this->model |
59 | - ->with(['user','seller']) | ||
60 | - ->where($where) | ||
61 | - ->order($sort, $order) | ||
62 | - ->limit($offset, $limit) | ||
63 | - ->select(); | 57 | + ->with(['user', 'seller']) |
58 | + ->where($where) | ||
59 | + ->order($sort, $order) | ||
60 | + ->limit($offset, $limit) | ||
61 | + ->select(); | ||
64 | 62 | ||
65 | foreach ($list as $row) { | 63 | foreach ($list as $row) { |
66 | - | ||
67 | - $row->getRelation('user')->visible(['avatar','nickname']); | ||
68 | - $row->getRelation('seller')->visible(['title','avatar']); | 64 | + |
65 | + $row->getRelation('user')->visible(['avatar', 'nickname']); | ||
66 | + $row->getRelation('seller')->visible(['title', 'avatar']); | ||
69 | } | 67 | } |
68 | +// foreach ($list as $k => $v) { | ||
69 | +// } | ||
70 | + dump($list); | ||
71 | + die; | ||
70 | $list = collection($list)->toArray(); | 72 | $list = collection($list)->toArray(); |
71 | $result = array("total" => $total, "rows" => $list); | 73 | $result = array("total" => $total, "rows" => $list); |
72 | 74 | ||
@@ -74,4 +76,14 @@ class SellerTalk extends Backend | @@ -74,4 +76,14 @@ class SellerTalk extends Backend | ||
74 | } | 76 | } |
75 | return $this->view->fetch(); | 77 | return $this->view->fetch(); |
76 | } | 78 | } |
79 | + | ||
80 | + | ||
81 | + function substr_format($text, $length, $replace = '...', $encoding = 'UTF-8') | ||
82 | + { | ||
83 | + if ($text && mb_strlen($text, $encoding) > $length) { | ||
84 | + return mb_substr($text, 0, $length, $encoding) . $replace; | ||
85 | + } | ||
86 | + return $text; | ||
87 | + } | ||
88 | + | ||
77 | } | 89 | } |
-
请 注册 或 登录 后发表评论