public function localityAutocomplete($term) { $terms = []; foreach (Locality::where('name', 'like', "%" . $term . "%")->get() as $locality) { $terms[] = ['id' => $locality->id, 'name' => $locality->name, 'pretty_name' => $locality->completeName()]; } return Response::json($terms); }
/** * Deletes the speified style * @param $id * @return mixed */ public function deleteLocality($id) { if (!count(Locality::where('locality_id', $id))) { Locality::find($id)->delete(); return Redirect::back()->withMessage('Locality deleted correctly'); } else { return Redirect::back()->withMessage("Locality can't be deleted. Delete the child localities first"); } }