作者 lyh

gx

... ... @@ -2,19 +2,25 @@
namespace App\Models\Blog;
use App\Enums\Common\Code;
use App\Models\Base;
use App\Models\User\User;
use App\Services\ProjectServer;
class Blog extends Base
{
protected $table = 'gl_blog';
//连接数据库
// protected $connection = 'custom_mysql';
protected $connection = 'custom_mysql';
public function user(){
return $this->hasMany(User::class,'operator_id','id');
}
public static function getNumByProjectId($project_id){
$project = ProjectServer::useProject($project_id);
if(empty($project)){
return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'数据库未配置']);
}
return self::where('project_id', $project_id)->where('status', 1)->count();
}
}
... ...
... ... @@ -2,7 +2,9 @@
namespace App\Models\News;
use App\Enums\Common\Code;
use App\Models\Base;
use App\Services\ProjectServer;
class News extends Base
{
... ... @@ -11,6 +13,10 @@ class News extends Base
protected $connection = 'custom_mysql';
public static function getNumByProjectId($project_id){
$project = ProjectServer::useProject($project_id);
if(empty($project)){
return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'数据库未配置']);
}
return self::where('project_id', $project_id)->where('status', 1)->count();
}
}
... ...
... ... @@ -2,10 +2,12 @@
namespace App\Models\Product;
use App\Enums\Common\Code;
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;
/**
... ... @@ -152,6 +154,10 @@ class Product extends Base
// }
public static function getNumByProjectId($project_id){
$project = ProjectServer::useProject($project_id);
if(empty($project)){
return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'数据库未配置']);
}
return self::where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
}
... ...