News.php 680 字节
<?php

namespace App\Models\News;

use App\Helper\Arr;
use App\Models\Base;

class News extends Base
{
    const STATUS_ONE = 1;

    protected $table = 'gl_news';
    //连接数据库
    protected $connection = 'custom_mysql';

    public static function getNumByProjectId($project_id){
        return self::where('project_id', $project_id)->where('status', 1)->count();
    }

    public function getReleaseAtAttribute($value){
        if(!$value){
            return date('Y-m-d H:i:s', strtotime($this->getAttribute('created_at')));
        }
        return $value;
    }

    public function getRelatedNewsIdAttribute($value){
        return Arr::setToArr($value);
    }
}