Product.php
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace App\Models\ASide\Product;
use App\Enums\Common\Code;
use App\Models\Base;
use App\Services\ProjectServer;
/**
* @method static get()
*/
class Product extends Base
{
//设置关联表名
protected $table = 'gl_product';
const STATUS_DRAFT = 0;
const STATUS_ON = 1;
const STATUS_RECYCLE = 2;
protected $connection;
public function __construct($project_id)
{
$project = ProjectServer::useProject($project_id);
if(empty($project)){
return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'数据库未配置']);
}
$this->connection = 'custom_mysql';
}
public static function statusMap(){
return [
self::STATUS_DRAFT => '草稿',
self::STATUS_ON => '已发布',
self::STATUS_RECYCLE => '回收站',
];
}
/**
* @var 获取产品类型
*/
public $productType = [
1=>'一般产品',
2=>'推荐产品',
3=>'热销产品'
];
public static function getNumByProjectId($project_id){
return self::where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
}
}