阶段更新
This commit is contained in:
43
modules/User/Models/SmsConfig.php
Normal file
43
modules/User/Models/SmsConfig.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\User\Models;
|
||||
|
||||
use App\Models\Model;
|
||||
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
|
||||
|
||||
class SmsConfig extends Model
|
||||
{
|
||||
|
||||
use Cachable;
|
||||
|
||||
protected $table = 'user_sms_configs';
|
||||
|
||||
protected $casts = [
|
||||
'template' => 'json',
|
||||
];
|
||||
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
self::saved(function ($model) {
|
||||
if ($model->in_use && $model->id) {
|
||||
self::where('id', '<>', $model->id)
|
||||
->where('in_use', 1)
|
||||
->update(['in_use' => 0]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes : 默认网关配置
|
||||
* @Date : 2021/5/27 5:18 下午
|
||||
* @Author : < Jason.C >
|
||||
* @return array
|
||||
*/
|
||||
public function getGateway(): array
|
||||
{
|
||||
return SmsGateway::where('slug', $this->default_gateway)->value('configs');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user