diff --git a/app/Http/Controllers/Api/TestController.php b/app/Http/Controllers/Api/TestController.php index 5eeeada..9626a91 100644 --- a/app/Http/Controllers/Api/TestController.php +++ b/app/Http/Controllers/Api/TestController.php @@ -3,6 +3,8 @@ namespace App\Http\Controllers\Api; use App\Models\Agent; +use App\Models\AgentSetting; +use Illuminate\Support\Facades\DB; /** * 仅用于测试 @@ -14,6 +16,6 @@ class TestController public function index() { //test - return Agent::query()->where(['appid' => 'wxb35ef055a4dd8ad4', 'status' => 1])->value('id'); + return AgentSetting::val(1, 'earnest') ?? 198.88; } } diff --git a/app/Models/AgentSetting.php b/app/Models/AgentSetting.php index 0e9ed1e..83cded3 100644 --- a/app/Models/AgentSetting.php +++ b/app/Models/AgentSetting.php @@ -15,4 +15,10 @@ class AgentSetting extends BaseModel parent::__construct($attributes); $this->timestamps = false; } + + public function scopeVal($query, $agent_id, $key) + { + $setting = json_decode($query->where('agent_id', $agent_id)->value('setting'), true); + return $setting[$key] ?? null; + } }