ProjectService.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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->array('status');
  12. $keyword = $this->pg('keyword');
  13. $where = WhereBuilder::builder()
  14. ->like('p.name', $keyword)
  15. ->in('p.status', $status)
  16. ->build();
  17. return (new Project)->alias('p')
  18. ->with(['schedules'])
  19. ->field('p.*')
  20. ->field('a.real_name as responsibility_person')
  21. ->join('admin a', 'a.id = p.responsibility_person_id', 'LEFT')
  22. ->where($where)
  23. ->paginate($this->tp6Page());
  24. }
  25. public function create($param = [])
  26. {
  27. $param = $this->autoParams($param);
  28. return Project::create($param);
  29. }
  30. public function info($param = [])
  31. {
  32. $this->autoParams($param);
  33. $project = $this->one(Project::class);
  34. $project->append(['contracts', 'schedules']);
  35. return $project;
  36. }
  37. public function update($param = [])
  38. {
  39. $param = $this->autoParams($param);
  40. return Project::update($param);
  41. }
  42. public function delete($param = [])
  43. {
  44. $this->autoParams($param);
  45. $project = $this->one(Project::class);
  46. return $project->delete();
  47. }
  48. }