APublicModel.php 1.3 KB
<?php
/**
 * @remark :
 * @name   :APublicModel.php
 * @author :lyh
 * @method :post
 * @time   :2023/8/10 18:16
 */

namespace App\Models\ASide;

use App\Helper\AyrShare as AyrShareHelper;
use App\Models\AyrShare\AyrShare as AyrShareModel;
use App\Models\Base;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;

class APublicModel extends Base
{


    const STATUS_ON = 1;

    /**
     * @remark :查询对应项目对应产品博客新闻数量
     * @name   :getNumByProjectId
     * @author :lyh
     * @method :post
     * @time   :2023/8/30 9:35
     */
    public static function getNumByProjectId($project_id){
        ProjectServer::useProject($project_id);
        $productNumber = DB::connection('custom_mysql')->table('gl_product')
            ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
        $blogNumber = DB::connection('custom_mysql')->table('gl_blog')
            ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
        $newsNumber = DB::connection('custom_mysql')->table('gl_news')
            ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
        DB::disconnect('custom_mysql');
        return ['product'=>$productNumber,'blog'=>$blogNumber,'news'=>$newsNumber];
    }

}