ActivityModel.php 884 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\common\model;
  3. class ActivityModel extends BaseModel
  4. {
  5. protected $table = 'erp_activity';
  6. protected function genSchema(array $schema)
  7. {
  8. // TODO: Implement genSchema() method.
  9. }
  10. protected function relation() {
  11. return $this->hasMany(ActivityProductModel::class,'activity_id', 'id')->where('is_delete',0);
  12. }
  13. public function findByPaginate(array $params) {
  14. $where = [
  15. ['is_delete', '=', 0]
  16. ];
  17. return $this->where($where)
  18. ->with(['relation','relation.product'])
  19. ->order('update_time','desc')
  20. ->paginate(['list_rows'=>10, "query" => $params]);
  21. }
  22. public function findById($id) {
  23. return $this->where([
  24. ['id','=',$id],
  25. ['is_delete','=', 0]
  26. ])->with(['relation','relation.product'])->find();
  27. }
  28. }