初始化项目
This commit is contained in:
26
app/BaseApp/BaseModel.php
Executable file
26
app/BaseApp/BaseModel.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\BaseApp;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BaseModel extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
public $timestamps = false;
|
||||
public function getCreatedAtAttribute($value): string
|
||||
{
|
||||
if (empty($value)) {
|
||||
return '';
|
||||
}
|
||||
return date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
// 定义访问器,将 created_at 字段格式化为指定格式
|
||||
public function getUpdatedAtAttribute($value): string
|
||||
{
|
||||
if (empty($value)) {
|
||||
return '';
|
||||
}
|
||||
return date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user