jingcai-php/app/Model/Zq/BjdcSfggOdds.php

50 lines
1.0 KiB
PHP
Executable File

<?php
/**
* @createtime 2023/4/26
* @author wild
* @copyright PhpStorm
*/
namespace App\Model\Zq;
use App\Enums\SaleState;
use App\Model\BaseModel;
class BjdcSfggOdds extends BaseModel
{
protected $casts = [
'sfgg_odds' => 'array',
'sfgg_odds_last' => 'array',
];
protected $appends = [
'close_datetime'
];
public function scopeSelling($query)
{
return $query->where('sale_state', SaleState::Selling);
}
public function getCloseTime($earlySecond)
{
$time = strtotime($this->close_time);
return date('Y-m-d H:i:s', $time - $earlySecond);
}
public function getCloseDatetimeAttribute()
{
if (!$this->close_time) {
return '';
}
$hour = date('H', strtotime($this->close_time));
if ($hour >= 10) {
return date('Y-m-d 10:00:00', strtotime($this->close_time));
}
return date('Y-m-d 10:00:00', strtotime('-1 day', strtotime($this->close_time)));
}
}