예제 #1
0
 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);
 }
예제 #2
0
 /**
  * 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");
     }
 }