作者 lyh

gx

... ... @@ -6,7 +6,9 @@ use App\Helper\Arr;
use App\Models\Base;
use App\Models\RouteMap;
use App\Services\Facades\Upload;
use App\Services\ProjectServer;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
/**
* @method static get()
... ... @@ -18,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;
... ... @@ -152,6 +154,8 @@ 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();
}
... ...