12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- /**
- * Created by PhpStorm.
- * User: wuzhenke
- * Date: 2018/12/25
- * Time: 18:19
- */
- namespace App\Repositories;
- use App\Models\Invoice;
- use App\Models\InvoiceCategory;
- use Prettus\Repository\Criteria\RequestCriteria;
- use Prettus\Repository\Eloquent\BaseRepository;
- class InvoiceRepository extends BaseRepository
- {
- public $title_arr = [1=>'单位',2=>'个人'];
- public $cate = [1=>'咨询费',2=>'咨询服务费',3=>'服务费'];
- public function model()
- {
- return Invoice::class;
- }
- public function boot()
- {
- $this->pushCriteria(app(RequestCriteria::class));
- }
- public function getOne($order_id, $user)
- {
- $cate = $this->getCate();
- $cateaArr = array_column($cate, 'categoryname', 'id');
- $where['order_num'] = $order_id;
- $where['uid'] = $user->id;
- $info = $this->model->where($where)->first();
- if ($info) {
- $info->title = $this->title_arr[$info->title];
- $info->cate = $cateaArr[$info->cid];
- return $info;
- } else {
- return false;
- }
- }
- public function getOneInvoice($order_id, $user)
- {
- $where['order_num'] = $order_id;
- $where['uid'] = $user->id;
- return $this->model->where($where)->first();
- }
- public function getCate()
- {
- return InvoiceCategory::select(['id','categoryname'])->get()->toArray();
- }
- }
|