12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Repositories;
- use App\Models\CardRiding;
- use Illuminate\Database\Eloquent\Builder;
- class CardRidingRepository extends BaseRepository
- {
- public function __construct(CardRiding $model)
- {
- $this->model = $model;
- }
- /**
- * 根据区域id获取可用骑行卡列表
- *
- * @param $area_id integer
- *
- * @return collection
- * */
- public function byAreaIdGetCardRidings($area_id)
- {
- return $this->model->query()
- ->with(['areaRidingCard'])
- ->whereHas('areaRidingCard', function (Builder $query) use ($area_id) {
- $query->where('area_id', $area_id);
- }, '>', 0)
- ->where('status', CardRiding::STATUS_OK)
- ->orderBy('price')
- ->get();
- }
- /**
- * 判断骑行卡是否启用
- *
- * @param $id integer
- *
- * @return bool true表示可用 false不可用
- *
- * */
- public function isStatusOK($id)
- {
- $cardRiding = $this->model->query()->where('id', $id)->where('status', CardRiding::STATUS_OK)->first();
- if (empty($cardRiding)) return false;
- return true;
- }
- }
|