BtSites.php
1.4 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
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2022/11/1
* Time: 15:44
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Class BtSites
* @package App\Models
*/
class BtSites extends Model
{
/**
* @var string $table
*/
protected $table = 'bt_sites';
const IS_DEL_FALSE = 0;
const IS_DEL_TRUE = 1;
const STATUS_OPEN = 1;
const STATUS_CLOSE = 2;
/**
* @param $domain
* @param $site_id
* @param $ssl_open
* @param $ssl_status
* @param $ssl_auto
* @param $ssl_auto_day
* @return BtSites
*/
public static function createBtSite($domain, $site_id, $ssl_open, $ssl_status, $ssl_auto, $ssl_auto_day)
{
$site = self::where(['domain' => $domain])->first();
if (empty($site)) {
$site = new self();
}
$site->domain = $domain;
$site->site_id = $site_id;
$site->ssl_open = $ssl_open;
$site->ssl_status = $ssl_status;
$site->ssl_auto = $ssl_auto;
$site->ssl_auto_day = $ssl_auto_day;
$site->status = self::STATUS_OPEN;
$site->is_del = self::IS_DEL_FALSE;
$site->save();
return $site;
}
/**
* @param $domain
* @return mixed
*/
public static function getSiteByDomain($domain)
{
return self::where(['domain' => $domain, 'is_del' => self::IS_DEL_FALSE])->first();
}
}