HospitalController.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace App\Http\Controllers\Mobile\Ic;
  3. use App\Http\Controllers\Mobile\MobileBaseController;
  4. use App\Models\Company;
  5. use App\Models\Jobs;
  6. use App\Repositories\CategoryRepository;
  7. use App\Services\Company\CompanyService;
  8. use App\Services\Company\JobsService;
  9. use Illuminate\Http\Request;
  10. class HospitalController extends MobileBaseController
  11. {
  12. protected $companyService;
  13. protected $jobsService;
  14. protected $categoryRepository;
  15. public function __construct(CompanyService $companyService, JobsService $jobsService, CategoryRepository $categoryRepository)
  16. {
  17. $this->companyService = $companyService;
  18. $this->jobsService = $jobsService;
  19. $this->categoryRepository = $categoryRepository;
  20. }
  21. public function index(Request $request)
  22. {
  23. $where = [
  24. ['is_ic', '=', 1],
  25. ];
  26. $list = Company::where($where)->get();
  27. $other_categories = $this->categoryRepository->getCategories();
  28. $tag_category = array_get($other_categories, 'AIX_jobtag');
  29. foreach ($list as $v) {
  30. $tag_arr = [];
  31. if (!empty($v->tag)) {
  32. foreach ($v->tag as $t) {
  33. $tag_arr[] = array_get($tag_category, $t);
  34. }
  35. }
  36. $v->tag_arr = $tag_arr;
  37. $v->job_count = Jobs::where([
  38. ['company_id', '=', $v->id],
  39. ['valid', '=', 1],
  40. ['display', '=', 1],
  41. ['audit', '=', '1'],
  42. ])->count();
  43. }
  44. return view('mobile.app.ic.hospital.index', ['list' => $list]);
  45. }
  46. public function show(Request $request)
  47. {
  48. //获取企业信息
  49. $company_id = $request->input('id');
  50. $company_info = $this->companyService->getCompanyInfo([['id', '=', $company_id]]);
  51. $this->putSeoData('company', $company_info);
  52. //在招职位
  53. $jobs_where = [
  54. ['company_id', '=', $company_info->id],
  55. ['valid', '=', 1],
  56. ['display', '=', 1],
  57. ];
  58. $jobs_display = config('aix.companyset.comset.show_set.jobs_display');
  59. if ($jobs_display == 1) {
  60. $jobs_where[] = ['audit', '=', '1'];
  61. } else {
  62. $jobs_where[] = ['audit', '<>', '3'];
  63. }
  64. $jobs = $this->jobsService->getOtherJobs($jobs_where);
  65. $return_data = [
  66. 'info' => $company_info,
  67. 'jobs' => $jobs,
  68. ];
  69. return view('mobile.app.ic.hospital.show', $return_data);
  70. }
  71. }