DeployBuild.php 890 字节
<?php

namespace App\Models\Project;

use App\Helper\Arr;
use App\Models\Base;
use Hashids\Hashids;
use Illuminate\Support\Facades\Cache;

class DeployBuild extends Base
{
    //设置关联表名
    protected $table = 'gl_project_deploy_build';
    protected $appends = ['test_domain'];


    public function setPlanAttribute($value){
        $this->attributes['plan'] = Arr::arrToSet($value, 'trim');
    }

    public function getPlanAttribute($value){
        return Arr::setToArr($value, 'trim');
    }

    public function getTestDomainAttribute(){
        $hashids = new Hashids('test_domain', 4, 'abcdefghjkmnpqrstuvwxyz1234567890');
        $code = $hashids->encode($this->project_id);
        return $code . '.test.com';
    }

 	public static function clearCache($row){
        $cache_key = 'project_' . $row->original['test_domain'];
        Cache::forget($cache_key);
    }
}