<?php
/**
* @author 龙虾 <15108148@qq.com>
* @version 2.0 2020-11-11
* @copyright 睿谷信息 <www.rgxx.com>
*/
namespace app\user\controller;

use app\common\model\Cmsmodels;
use app\common\model\User;
use Request;
use Db;

class Favorite extends Base
{
	protected function initialize()
    {
        parent::initialize();
        if(!isInstall('favorite')) $this->error('请先安装插件');
    }
	// 地址首页
	public function index($model='product')
	{
		$pagetitle = '我的收藏';
		$mlist= Cmsmodels::whereType(1)->select();
		$modelinfo = $mlist->where('name','eq',$model)->shift();
		$modelname = $modelinfo['name'];
		$fids = Db::name('favorite')->whereUserId(session('userid'))->whereCmsmodelsId($modelinfo['id'])->order('id desc')->column('cid');
		$fids = empty($fids)?0:implode(',',$fids);
		return $this->fetch('',compact('pagetitle','fids','mlist','modelname'));
	}
}