<?php

namespace App\Http\Services\V1;

use App\Generated\V1\Messages\School\GetListMessage;
use App\Models\SchoolModel;

class SchoolService
{


    /**
     * 查看学校列表
     * @param  GetListMessage  $message
     */
    public function getList(GetListMessage $message)
    {
        $keyword = $message->getKeyword();

        $schools = SchoolModel::when($keyword, function ($query) use ($keyword) {
            return $query->where('school', 'like', "%{$keyword}%");
        })->get();
        $message->setResponse($schools);
    }
}
