OwnerStoragePriceModelService.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Services;
  3. use App\OwnerStoragePriceModel;
  4. Class OwnerStoragePriceModelService
  5. {
  6. public function getSelection(array $columns = ["counting_type","using_type"], array $withs = [])
  7. {
  8. return OwnerStoragePriceModel::query()->select($columns)->with($withs)->get();
  9. }
  10. public function paginate(array $withs = [])
  11. {
  12. return OwnerStoragePriceModel::query()->orderByDesc('id')->with($withs)->paginate($params["paginate"] ?? 50);
  13. }
  14. public function create(array $params)
  15. {
  16. return OwnerStoragePriceModel::query()->create($params);
  17. }
  18. public function update(array $params, array $values)
  19. {
  20. $query = OwnerStoragePriceModel::query();
  21. foreach ($params as $column => $value){
  22. $query->where($column,$value);
  23. }
  24. return $query->update($values);
  25. }
  26. public function find($id)
  27. {
  28. return OwnerStoragePriceModel::query()->find($id);
  29. }
  30. public function destroy($id)
  31. {
  32. return OwnerStoragePriceModel::destroy($id);
  33. }
  34. }