You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
zhishifufei_php/application/web/model/topic/Relation.php

68 lines
3.0 KiB

<?php
// +----------------------------------------------------------------------
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
// +----------------------------------------------------------------------
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
// +----------------------------------------------------------------------
namespace app\web\model\topic;
use traits\ModelTrait;
use basic\ModelBasic;
use app\web\model\special\Special;
use app\web\model\topic\TestPaper;
use app\web\model\material\DataDownload;
/**关联表
* Class Relation
* @package app\web\model\topic
*/
class Relation extends ModelBasic
{
use ModelTrait;
public static function setWhere($relationship = 0, $relationship_id = 0)
{
return self::where(['is_del' => 0, 'relationship' => $relationship, 'relationship_id' => $relationship_id]);
}
/**获取试题关联的专题
* @param int $relationship
* @param int $relationship_id
*/
public static function getRelationSpecial($relationship = 0, $relationship_id = 0, $page = false, $limit = false)
{
$model = self::alias('r')->join('Special s', 'r.relation_id=s.id')
->where(['r.is_del' => 0, 's.is_show' => 1, 's.is_del' => 0, 'r.relationship' => $relationship, 'r.relationship_id' => $relationship_id]);
if ($page) {
$model = $model->page((int)$page, !$limit ? 20 : (int)$limit);
}
$data = $model->field('s.id,s.title,s.is_light,s.light_type,s.image,s.label,s.money,s.type,r.id as rid,r.sort')
->order('r.sort DESC,rid DESC')->select();
$data = count($data) > 0 ? $data->toArray() : [];
return $data;
}
public static function getRelationTestPaper($relationship = 0, $relationship_id = 0)
{
$data = self::alias('r')->join('TestPaper t', 'r.relation_id=t.id')
->where(['r.is_del' => 0, 't.is_show' => 1, 't.is_del' => 0, 'r.relationship' => $relationship, 'r.relationship_id' => $relationship_id])
->field('t.id,t.title,r.id as rid,r.sort')->order('r.sort DESC,rid DESC')->select();
$data = count($data) > 0 ? $data->toArray() : [];
return $data;
}
public static function getRelationDataDownload($relationship = 0, $relationship_id = 0)
{
$data = self::alias('r')->join('DataDownload d', 'r.relation_id=d.id')
->where(['r.is_del' => 0, 'd.is_show' => 1, 'd.is_del' => 0, 'r.relationship' => $relationship, 'r.relationship_id' => $relationship_id])
->field('d.id,d.title,r.id as rid,r.sort')->order('r.sort DESC,rid DESC')->select();
$data = count($data) > 0 ? $data->toArray() : [];
return $data;
}
}