|
|
|
@ -11,6 +11,19 @@ class SchoolsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def for_option
|
|
|
|
|
render_ok(schools: School.select(:id, :name).as_json)
|
|
|
|
|
schools = School.all
|
|
|
|
|
keyword = params[:keyword].to_s.strip
|
|
|
|
|
schools = schools.where('name LIKE ?', "%#{keyword}%") if keyword
|
|
|
|
|
|
|
|
|
|
render_ok(schools: schools.select(:id, :name).as_json)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def search
|
|
|
|
|
schools = School.all
|
|
|
|
|
keyword = params[:keyword].to_s.strip
|
|
|
|
|
schools = schools.where('name LIKE ?', "%#{keyword}%") if keyword
|
|
|
|
|
|
|
|
|
|
schools = paginate(schools)
|
|
|
|
|
render_ok(schools: schools.as_json(only: %i[id name province]))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|