You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
631 B
28 lines
631 B
<?php
|
|
|
|
namespace App\Models;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class BaseModel extends Model
|
|
{
|
|
protected $dateFormat = 'U';
|
|
protected $host = '';
|
|
|
|
public function __construct(array $attributes = [])
|
|
{
|
|
parent::__construct($attributes);
|
|
$this->host = env('APP_URL');
|
|
}
|
|
|
|
# 不转换时间戳,若使用getUpdatedAtColumn,则不能自动写入时间戳
|
|
public function getUpdatedAtAttribute($value)
|
|
{
|
|
return strtotime($value);
|
|
}
|
|
|
|
# 不转换时间戳,若使用getUpdatedAtColumn,则不能自动写入时间戳
|
|
public function getCreatedAtAttribute($value)
|
|
{
|
|
return strtotime($value);
|
|
}
|
|
}
|