Browse Source

AgentSetting增加scopeVal

develop
李可松 4 years ago
parent
commit
771c3cf7ff
  1. 4
      app/Http/Controllers/Api/TestController.php
  2. 6
      app/Models/AgentSetting.php

4
app/Http/Controllers/Api/TestController.php

@ -3,6 +3,8 @@
namespace App\Http\Controllers\Api; namespace App\Http\Controllers\Api;
use App\Models\Agent; use App\Models\Agent;
use App\Models\AgentSetting;
use Illuminate\Support\Facades\DB;
/** /**
* 仅用于测试 * 仅用于测试
@ -14,6 +16,6 @@ class TestController
public function index() public function index()
{ {
//test //test
return Agent::query()->where(['appid' => 'wxb35ef055a4dd8ad4', 'status' => 1])->value('id');
return AgentSetting::val(1, 'earnest') ?? 198.88;
} }
} }

6
app/Models/AgentSetting.php

@ -15,4 +15,10 @@ class AgentSetting extends BaseModel
parent::__construct($attributes); parent::__construct($attributes);
$this->timestamps = false; $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;
}
} }
Loading…
Cancel
Save