* @license GPL https://xxx.com * @link https://xxx.com * @ctime: 2020/3/24 14:38 */ namespace App\Repositories; use App\Models\RechargeConfiguration; use Illuminate\Cache\Repository; use Illuminate\Contracts\Cache\Store; class RechargeConfigurationRepository extends BaseRepository { public function __construct(RechargeConfiguration $rechargeConfiguration) { $this->model = $rechargeConfiguration; } public function getAllByAreaId($area_id) { return $this->model->where('area_id', $area_id)->where('status', RechargeConfiguration::STATUS_OK)->get(); } /** * * @param $area_id */ public function byAreaIdGetActiveConfig($area_id) { $now = now(); return $this->model->where('area_id', $area_id)->where('start_at', '<=', $now)->where('end_at', '>=', $now)->where('status', RechargeConfiguration::STATUS_OK)->orderBy('id', 'desc')->limit(6)->get(); } public function byIdGetActiveModel($id) { $now = now(); return $this->model->where('id', $id)->where('start_at', '<=', $now)->where('end_at', '>=', $now)->where('status', RechargeConfiguration::STATUS_OK)->orderBy('id', 'desc')->first(); } public function byMoneyGetActiveModel($money,$area_id) { $now = now(); return $this->model->where('recharge_money', $money)->where('start_at', '<=', $now)->where('end_at', '>=', $now)->where('status', RechargeConfiguration::STATUS_OK)->where('area_id',$area_id)->orderBy('id', 'desc')->first(); } public function getOneById($id) { return $this->model->where('id', $id)->where('status', RechargeConfiguration::STATUS_OK)->first(); } }