<?php
/**
 * @Statement: [ An Ordinary Person ]
 * @Author: 闻子 < QQ：270988107 >
 * @Copyright: 闻子 2016-2019 All rights reserved.
 *
 *    .--,       .--,
 *   ( (  \.---./  ) )
 *    '.__/o   o\__.'
 *       {=  ^  =}
 *        >  -  <
 *       /       \
 *      //       \
 *     //|   .   |\
 *     "'\       /'"_.-~^`'-.
 *        \  _  /--'         `
 *      ___)( )(___
 *     (((__) (__)))    高山仰止,景行行止.虽不能至,心向往之.
 *
 */
 
namespace app\ohbbs\controller;

use think\Db;

use app\common\logic\Scode as LogicScode;

use app\common\controller\Base as BaseController;

class Content extends BaseController
{ 
	/**
	 * 继承基类
	 * @Author: 闻子 < QQ：270988107 >
	 */
    use Base;

	/**
	 * 定义逻辑
	 * @Author: 闻子 < QQ：270988107 >
	 */
	private static $ScodeLogic = null;

    /**
     * 实例化逻辑
     * @Author: 闻子 < QQ：270988107 >
     */
    public function __construct()
    {
        parent::__construct();
        self::$ScodeLogic = get_sington_object('LogicScode', LogicScode::class);
    }

    /**
     * 源码列表
     * @Author: 闻子 < QQ：270988107 >
     */
    public function scode()
    {
    	return view();
    }

    /**
     * 编辑源码
     * @Author: 闻子 < QQ：270988107 >
     */
    public function scode_edit()
    {
    	$data = self::$ScodeLogic->getScodeInfo(['id'=>input('id')]);
    	$title = Db::name('menu')->where('id',$data['mid'])->find();
    	$columndata = Db::name('column')->where('pid',$title['id'])->order('sort asc')->select();
    	$value = $data['catid'];
		$ass = Db::name('assortment')->whereIn('id',$data['catid'])->orderRaw("field(id,$value)")->select();
        foreach ($columndata as $key => $value) {
        	$columndata[$key]['assid'] = $ass[$key]['id'];
        }
        $taginfo = Db::name('tag')->where('cid',$data['mid'])->select();
    	$this->request->isPost() && $this->jump(self::$ScodeLogic->formdata(input('post.')));
    	return view('',compact('data','columndata','taginfo'));
    }

}