| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace App\Module\UrsPromotion\Repositories;
- use App\Module\UrsPromotion\Models\UrsPartnerDividendDetail;
- use Dcat\Admin\Repositories\EloquentRepository;
- /**
- * URS合伙人分红详情仓库类
- *
- * 仅供后台管理数据访问使用
- */
- class UrsPartnerDividendDetailRepository extends EloquentRepository
- {
- /**
- * 模型类
- */
- protected $eloquentClass = UrsPartnerDividendDetail::class;
- /**
- * 预加载关联关系
- */
- protected $with = [];
- /**
- * 构造函数
- *
- * @param array $with 预加载关联关系
- */
- public function __construct(array $with = [])
- {
- $this->with = $with;
- parent::__construct();
- }
- /**
- * 获取查询构建器
- */
- public function getQueryBuilder()
- {
- $query = parent::getQueryBuilder();
- if (!empty($this->with)) {
- $query->with($this->with);
- }
- return $query;
- }
- /**
- * 查询详情页面数据
- */
- public function detail(\Dcat\Admin\Show $show): array
- {
- $result = $this->eloquentClass::with($this->with ?? [])
- ->where($this->getKeyName(), $show->getKey())
- ->first();
- if (!$result) {
- abort(404);
- }
- return $result->toArray();
- }
- }
|