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.
33 lines
753 B
33 lines
753 B
<?php
|
|
|
|
namespace App\Models;
|
|
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class BaseModel extends Model
|
|
{
|
|
use HasDateTimeFormatter;
|
|
|
|
protected $host = '';
|
|
|
|
public function __construct(array $attributes = [])
|
|
{
|
|
parent::__construct($attributes);
|
|
$this->host = env('APP_URL');
|
|
}
|
|
|
|
//默认按id desc排序
|
|
protected static function booted()
|
|
{
|
|
static::addGlobalScope('orderById', function (Builder $builder) {
|
|
$builder->orderBy((new static())->getTable().'.id', 'desc');
|
|
});
|
|
}
|
|
|
|
//供应商、代理商、地接、后台管理员等密码加密
|
|
protected function passMd5($value): string
|
|
{
|
|
return md5('9e97ae0d950a4b10182c99d484b204c8' . $value);
|
|
}
|
|
}
|