OwnerOutStorageRuleService.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Services;
  3. use App\OwnerOutStorageRule;
  4. use App\Traits\ServiceAppAop;
  5. Class OwnerOutStorageRuleService
  6. {
  7. use ServiceAppAop;
  8. public function get(array $params, array $withs = [], $isTranslateFeature = false, array $translateColumn = [])
  9. {
  10. if ($isTranslateFeature){
  11. $features = app("FeatureService")->getMapArray();
  12. OwnerOutStorageRule::$features = $features;
  13. OwnerOutStorageRule::$columnMapping = $translateColumn;
  14. }
  15. $rule = OwnerOutStorageRule::query();
  16. if ($withs)$rule->with($withs);
  17. foreach ($params as $column=>$param){
  18. $rule->where($column,$param);
  19. }
  20. return $rule->get();
  21. }
  22. public function update(array $params, array $values)
  23. {
  24. $query = OwnerOutStorageRule::query();
  25. foreach ($params as $column=>$param){
  26. $query->where($column,$param);
  27. }
  28. return $query->update($values);
  29. }
  30. public function create(array $params)
  31. {
  32. return OwnerOutStorageRule::query()->create($params);
  33. }
  34. public function findUpdate(OwnerOutStorageRule $rule, array $values)
  35. {
  36. return $rule->update($values);
  37. }
  38. public function find($id)
  39. {
  40. return OwnerOutStorageRule::query()->find($id);
  41. }
  42. public function isExist(array $params)
  43. {
  44. $query = OwnerOutStorageRule::query();
  45. foreach ($params as $column=>$param){
  46. $query->where($column,$param);
  47. }
  48. return $query->count();
  49. }
  50. }