SchoolService.php 549 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace App\Http\Services\V1;
  3. use App\Generated\V1\Messages\School\GetListMessage;
  4. use App\Models\SchoolModel;
  5. class SchoolService
  6. {
  7. /**
  8. * 查看学校列表
  9. * @param GetListMessage $message
  10. */
  11. public function getList(GetListMessage $message)
  12. {
  13. $keyword = $message->getKeyword();
  14. $schools = SchoolModel::when($keyword, function ($query) use ($keyword) {
  15. return $query->where('school', 'like', "%{$keyword}%");
  16. })->get();
  17. $message->setResponse($schools);
  18. }
  19. }