38 lines
753 B
PHP
38 lines
753 B
PHP
<?php
|
|
|
|
namespace App\Models\Config;
|
|
|
|
use App\Core\Model;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
/**
|
|
* 配置
|
|
*/
|
|
class Config extends Model
|
|
{
|
|
protected $table = 'configs';
|
|
|
|
protected $primaryKey = ['appid', 'name'];
|
|
|
|
public $incrementing = false;
|
|
|
|
protected $casts = [
|
|
'value' => 'array',
|
|
];
|
|
|
|
/**
|
|
* Set the keys for a save update query.
|
|
*
|
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
|
* @return \Illuminate\Database\Eloquent\Builder
|
|
*/
|
|
protected function setKeysForSaveQuery(Builder $query)
|
|
{
|
|
foreach ($this->getKeyName() as $key) {
|
|
$query->where($key, '=', $this->original[$key] ?? $this->getAttribute($key));
|
|
}
|
|
|
|
return $query;
|
|
}
|
|
}
|