ProjectService.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\common\service;
  3. use app\common\model\Project;
  4. use app\common\service\Service;
  5. use app\common\util\WhereBuilder;
  6. class ProjectService extends Service
  7. {
  8. public function page($param = [])
  9. {
  10. $this->autoParams($param);
  11. $status = $this->pg('status');
  12. $keyword = $this->pg('keyword');
  13. $where = WhereBuilder::builder()
  14. ->like('keyword', $keyword)
  15. ->in('status', $status)
  16. ->build();
  17. return (new Project)
  18. ->with(['contracts', 'schedules'])
  19. ->where($where)
  20. ->paginate($this->tp6Page());
  21. }
  22. public function create($param = [])
  23. {
  24. $param = $this->autoParams($param);
  25. return Project::create($param);
  26. }
  27. public function info($param = [])
  28. {
  29. $this->autoParams($param);
  30. $project = $this->one(Project::class);
  31. $project->append(['contracts', 'schedules']);
  32. return $project;
  33. }
  34. public function update($param = [])
  35. {
  36. $param = $this->autoParams($param);
  37. return Project::update($param);
  38. }
  39. public function delete($param = [])
  40. {
  41. $this->autoParams($param);
  42. $project = $this->one(Project::class);
  43. return $project->delete();
  44. }
  45. }