ServerInformation.php 2.0 KB
<?php

namespace App\Models\Devops;

use Illuminate\Database\Eloquent\Model;

class ServerInformation extends Model
{

    protected $table = 'gl_server_information';
    const CREATED_AT = 'create_at';
    const UPDATED_AT = 'update_at';

    // 软删除 0:正常 1:删除
    const DELETED_NORMAL = 0;
    const DELETED_DELETE = 1;


    /**
     * @param $num
     *
     * @return string
     */
    public function Service($num)
    {
        return $this->ServiceArray()[$num];
    }

    /**
     * @return array
     */
    public function ServiceArray()
    {
        return [
            1 => '阿里云',
            2 => '腾讯云',
            3 => 'linode',
            4 => '尊云',
            5 => '互联',
            6 => '其他',
            7 => 'Ramnode',
            8 => 'CN2-SSD美国',
            9 => '国内测试服务器',
        ];
    }

    /**
     * 字段信息
     * @return array
     */
    public function FieldsArray()
    {
        return [
            'type'      => '服务器类型',
            'ip'        => '服务器IP',
            'title'     => '服务器标题',
            'belong_to' => '服务器归属',
            'sshpass'   => 'SSH 密码',
            'ports'     => 'SSH 端口',
            'other'     => '其他信息 json格式',
        ];
    }

    /**
     * 服务器归属信息
     * @return array
     */
    public function BelongToArray()
    {
        return [
            1 => '公司',
            2 => '客户',
        ];
    }

    public function BelongTo($num)
    {
        return $this->BelongToArray()[$num];
    }

    /**
     * 返回服务器类型
     * @param $value
     *
     * @return string
     */
    public function getTypeAttribute($value)
    {
        return $this->Service($value);
    }

    /**
     * 返回服务器归属
     * @param $value
     *
     * @return string
     */
    public function getBelongToAttribute($value)
    {
        return $this->BelongTo($value);
    }
}