| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- /**
- * Created by PhpStorm.
- * User: vien
- * Date: 2019/3/17
- * Time: 3:04 PM
- */
- namespace App\Models\Base;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use Illuminate\Foundation\Auth\User as Authenticatable;
- class AuthBaseModel extends Authenticatable
- {
- use SoftDeletes;
- protected $allowEmpty = [];
- /**
- * 需要转换成日期的属性
- *
- * @var array
- */
- protected $dates = ['deleted_at'];
- /**
- * 默认使用时间戳戳功能
- *
- * @var bool
- */
- public $timestamps = true;
- /**
- * 获取当前时间
- *
- * @return int
- */
- public function freshTimestamp() {
- return time();
- }
- /**
- * 避免转换时间戳为时间字符串
- *
- * @param DateTime|int $value
- * @return DateTime|int
- */
- public function fromDateTime($value) {
- return $value;
- }
- /**
- * select的时候避免转换时间为Carbon
- *
- * @param mixed $value
- * @return mixed
- */
- // protected function asDateTime($value) {
- // return $value;
- // }
- /**
- * 从数据库获取的为获取时间戳格式
- *
- * @return string
- */
- public function getDateFormat() {
- return 'U';
- }
- }
|