初始化本地仓库
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\model\plugin;
|
||||
|
||||
use app\model\system\Admin;
|
||||
use core\base\BaseModel;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ApplicationAuth extends BaseModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'plugin_application_auth';
|
||||
|
||||
protected $appends = ['expired_date', 'created_date', 'updated_date', 'created_name', 'updated_name'];
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'name',
|
||||
'access_key',
|
||||
'secret_key',
|
||||
'expired_at',
|
||||
'enabled',
|
||||
'description',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'expired_at' => 'integer',
|
||||
'enabled' => 'integer',
|
||||
'created_at' => 'integer',
|
||||
'updated_at' => 'integer',
|
||||
'deleted_at' => 'integer',
|
||||
];
|
||||
|
||||
public function createds(): \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
{
|
||||
return $this->hasOne(Admin::class, 'id', 'created_by')->select('id', 'real_name as created_name');
|
||||
}
|
||||
|
||||
public function updateds(): \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
{
|
||||
return $this->hasOne(Admin::class, 'id', 'updated_by')->select('id', 'real_name as updated_name');
|
||||
}
|
||||
|
||||
public function getExpiredDateAttribute(): ?string
|
||||
{
|
||||
$timestamp = $this->getRawOriginal('expired_at');
|
||||
if (empty($timestamp)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return \Carbon\Carbon::createFromTimestamp((int)$timestamp)
|
||||
->setTimezone(config('app.default_timezone'))
|
||||
->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function getCreatedNameAttribute(): string
|
||||
{
|
||||
return $this->createds?->created_name ?? '';
|
||||
}
|
||||
|
||||
public function getUpdatedNameAttribute(): string
|
||||
{
|
||||
return $this->updateds?->updated_name ?? '';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user