Blog.php
708 字节
<?php
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';
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();
}
}