123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Mead
- * Date: 2019/8/6
- * Time: 9:16 PM
- */
- namespace App\Repositories;
- use App\Models\Bike;
- class BaseRepository
- {
- protected $model;
- /**
- * 根据id获取model
- * @param $id
- * @return mixed
- * User: Mead
- */
- public function byIdGetModel($id)
- {
- return $this->model->where('id', $id)->first();
- }
- /**
- * 获取全部数据
- * User: Mead
- */
- public function all()
- {
- return $this->model->get();
- }
- public function byIdGetBoxNo($id)
- {
- return $this->model->where('id', $id)->value('box_no');
- }
- public function byIdGetNoRidingBoxNo($id)
- {
- return $this->model->where('id', $id)->where('is_riding', Bike::RIDING_NO)->value('box_no');
- }
- }
|