12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- declare(strict_types=1);
- namespace app\logics;
- use app\model\DailyWechatArticle as Model;
- class DailyWechatArticleLogic
- {
- /**
- * 每日发圈列表
- */
- public function list($where, $page=null, $limit=null, $order=null)
- {
- $modelObj = Model::with(['dailyWechatLabel'])->where($where);
- if(!is_null($page)) $modelObj->page((int)$page);
- if(!is_null($limit)) $modelObj->limit((int)$limit);
- if(!is_null($order)) $modelObj->order($order);
- $data = $modelObj->select()->toArray();
- return $data;
- }
-
- /**
- * 总数获取
- */
- public function count($where)
- {
- $modelObj = Model::where($where);
- $num = $modelObj->count();
- return $num;
- }
-
- /**
- * 添加每日发圈内容
- */
- public function addArticle($data)
- {
- Model::insert($data);
- }
-
- /**
- * 内容上下架
- */
- public function shelf($id)
- {
- $shelf = Model::where('id', $id)->value('shelf');
- $shelf = $shelf == 1 ? 0 : 1;
- Model::where('id',$id)->setField('shelf',$shelf);
- }
-
- /**
- * 删除每日发圈内容
- */
- public function del($id)
- {
- Model::where('id',$id)->setField('del',1);
- }
-
- /**
- * 内容编辑
- */
- public function edit($id)
- {
- $data = Model::where('id', $id)->find();
- return $data;
- }
-
- /**
- * 内容编辑保存
- */
- public function save($data)
- {
- Model::where('id', $data['id'])->update($data);
- }
- }
|