53 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
		
		
			
		
	
	
			53 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
|  | <?php | ||
|  | 
 | ||
|  | namespace app\model; | ||
|  | 
 | ||
|  | /** | ||
|  |  * 文档模型 | ||
|  |  * Class ArchivesModel | ||
|  |  * @package app\model | ||
|  |  */ | ||
|  | class ArchivesModel extends Base | ||
|  | { | ||
|  |     /** | ||
|  |      * 获取恒美内容模型 问题文章|日记分享|效果模拟|科普视频 | ||
|  |      * | ||
|  |      * @return string[] | ||
|  |      */ | ||
|  |     public static function models(): array | ||
|  |     { | ||
|  |         return ['question', 'diary', 'effect', 'science']; | ||
|  |     } | ||
|  | 
 | ||
|  |     /** | ||
|  |      * 内容模型关联栏目 | ||
|  |      * | ||
|  |      * @return mixed | ||
|  |      */ | ||
|  |     public static function categories() | ||
|  |     { | ||
|  |         return self::alias('am') | ||
|  |             ->leftJoin('archives_category ac', 'ac.model_id = am.id') | ||
|  |             ->field('ac.id,ac.title,ac.model_id, ac.sort,am.name as model_name') | ||
|  |             ->order('ac.sort', 'desc') | ||
|  |             ->order('ac.id', 'asc') | ||
|  |             ->whereIn('am.name', self::models()) | ||
|  |             ->select(); | ||
|  |     } | ||
|  | 
 | ||
|  |     /** | ||
|  |      * 关于我们栏目 | ||
|  |      * | ||
|  |      * @return mixed | ||
|  |      */ | ||
|  |     public static function about() | ||
|  |     { | ||
|  |         return self::alias('am') | ||
|  |             ->leftJoin('archives_category ac', 'ac.model_id = am.id') | ||
|  |             ->field('ac.id,ac.title,ac.model_id, ac.sort,am.name as model_name') | ||
|  |             ->order('ac.sort', 'desc') | ||
|  |             ->order('ac.id', 'asc') | ||
|  |             ->whereIn('ac.id', ArchivesCategory::aboutCategoryId()) | ||
|  |             ->select(); | ||
|  |     } | ||
|  | } |