public function postPublish() { $states = Input::get('notify'); if ($states[0] == 'All') { $temp_states = Cities::distinct()->select('city_state')->get(); unset($states); foreach ($temp_states as $state) { $states[] = $state->city_state; } } $users = DB::table('users')->OrwhereIn('state', $states)->select('uid', 'email', 'fname', 'username'); $organizations = DB::table('other_users')->OrwhereIn('state', $states)->select('uid', 'email', 'fname', 'username'); $combined = $users->union($organizations)->get(); $msg = 'Report Published Successfully'; $inputs = Input::except('notify'); foreach (Input::all() as $key => $single_input) { if (empty($single_input) && (stristr($key, 'state') || stristr($key, 'city'))) { unset($inputs[$key]); } } $inputs['dob'] = GlobalFunc::set_date_format(Input::get('dob')); $inputs['missing_since'] = GlobalFunc::set_date_format(Input::get('missing_since')); if (!Input::hasFile('kid_image')) { unset($inputs['kid_image']); } else { $file = Input::file('kid_image'); $destination_path = 'admin/images/upload/'; $filename = str_random(15) . '.' . $file->getClientOriginalExtension(); $file->move($destination_path, $filename); $inputs['kid_image'] = $destination_path . $filename; } if (Input::get('clicked') == 'Success') { $inputs['status'] = 9; $msg = 'Report Successfully Marked As Success'; } else { $inputs['status'] = 1; } unset($inputs['clicked']); Missing::where('id', '=', Input::get('id'))->update($inputs); $title = 'New Report Published'; $message = 'Hello'; foreach ($combined as $email_chunk) { $insert = array('user_id' => $email_chunk->uid, 'message' => $message, 'title' => $title); Notifications::create($insert); } return Redirect::to('admin/missing/published')->with('success', $msg); }
public function getLoadstates() { $data = Cities::distinct()->select('city_state')->get(); echo json_encode($data); }