| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 | <?phpnamespace App\Services\Recuperate;use App\Models\RecuperateApply;use App\Repositories\RecuperateRepository;class RecuperateService{    protected $recuperateRepository;    public function __construct(RecuperateRepository $recuperateRepository)    {        $this->recuperateRepository = $recuperateRepository;    }    /**     * 前台获取列表     */    public function list($key = '', $page = '')    {        //搜索条件        $where   = [];        $where[] = ['is_display', '=', '1'];        if ($key) {            $where[] = ['title', 'like', '%' . $key . '%'];        }        //获取列表        $list = $this->recuperateRepository->getRecuperate($where, $page);        //列表处理        if ($list->toArray()) {            foreach ($list as $k => $v) {                $list[$k]->origin_title = $v->title;                $style                  = '';                if ($v->tit_color) {                    $style .= 'color:' . $v->tit_color . ';';                }                if ($v->tit_b == '1') {                    $style .= 'font-weight:bold;';                }                if ($style) {                    $list[$k]->title = '<span style=' . $style . '>' . $v->title . '</span>';                }            }        }        return $list;    }    /**     * 获取前台显示的疗养信息     */    public function getRecuperateInfo($id)    {        $where        = array(            'id'         => $id,            'is_display' => '1',        );        $article_info = $this->recuperateRepository->firstWhere($where);        return $article_info;    }    /**     * 增加数量     */    public function incrementData($where, $num, $filed)    {        return $this->recuperateRepository->incrementData($where, $num, $filed);    }}
 |