| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Services\Common;
- use App\Models\AccountModel;
- use App\Models\ArticleCateModel;
- use App\Models\ArticleModel;
- use App\Services\BaseService;
- /**
- * 文章分类管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * Class ArticleCateService
- * @package App\Services\Common
- */
- class ArticleCateService extends BaseService
- {
- /**
- * 构造函数
- * @author laravel开发员
- * @since 2020/11/11
- * ArticleService constructor.
- */
- public function __construct()
- {
- $this->model = new ArticleCateModel();
- }
- /**
- * 静态入口
- * @return static|null
- */
- public static function make()
- {
- if (!self::$instance) {
- self::$instance = (new static());
- }
- return self::$instance;
- }
- /**
- * 添加或编辑
- * @return array
- * @since 2020/11/11
- * @author laravel开发员
- */
- public function edit()
- {
- $data = request()->all();
- return parent::edit($data); // TODO: Change the autogenerated stub
- }
- /**
- * 选项
- * @return array
- */
- public function options()
- {
- // 获取参数
- $param = request()->all();
- // 用户ID
- $keyword = getter($param, "keyword");
- $parentId = getter($param, "parent_id");
- $id = getter($param, "id");
- $datas = $this->model->where(function($query) use($parentId){
- if($parentId){
- $query->where(['id'=> $parentId,'mark'=>1]);
- }else{
- $query->where(['status'=> 1,'mark'=>1]);
- }
- })
- ->where(function($query) use($id){
- if($id){
- $query->whereNotIn('id', [$id]);
- }
- })
- ->where(function($query) use($keyword){
- if($keyword){
- $query->where('name','like',"%{$keyword}%")->orWhere('code','like',"%{$keyword}%");
- }
- })
- ->select(['id','name','status'])
- ->get();
- return $datas? $datas->toArray() : [];
- }
- }
|