作者 lyh

gx

... ... @@ -45,6 +45,7 @@ class ProjectLogic extends BaseLogic
public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20)
{
parent::setWith(['payment', 'deploy_build', 'deploy_optimize','online_check']);
$list = parent::getList($map, $sort, ['id', 'title', 'channel', 'type', 'created_at'], $limit);
foreach ($list['list'] as &$item){
... ...
<?php
/**
* @remark :
* @name :Product.php
* @author :lyh
* @method :post
* @time :2023/8/10 18:16
*/
namespace App\Models\ASide;
use App\Models\Base;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
class Product extends Base
{
protected $table = 'gl_product';
const STATUS_ON = 1;
public static function getNumByProjectId($project_id){
ProjectServer::useProject($project_id);
DB::connection('custom_mysql');
return self::where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
}
}
... ...
... ... @@ -20,7 +20,7 @@ class Product extends Base
//设置关联表名
protected $table = 'gl_product';
//连接数据库
// protected $connection = 'custom_mysql';
protected $connection = 'custom_mysql';
const STATUS_DRAFT = 0;
const STATUS_ON = 1;
const STATUS_RECYCLE = 2;
... ... @@ -154,8 +154,6 @@ class Product extends Base
// }
public static function getNumByProjectId($project_id){
$project = ProjectServer::useProject($project_id);
DB::connection('custom_mysql')->reconnect(); // 连接到目标数据库
return self::where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
}
... ...