예제 #1
0
 public function postPublish()
 {
     $msg = 'Report Successfully Published';
     $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['found_date'] = GlobalFunc::set_date_format(Input::get('found_date'));
     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') {
         // if the report is marked as a success
         $inputs['status'] = 9;
         $msg = 'Report Successfully Marked As Success';
     } else {
         //if the report is updated or published
         $inputs['status'] = 1;
     }
     unset($inputs['clicked']);
     Found::where('id', '=', Input::get('id'))->update($inputs);
     return Redirect::to('admin/found/published')->with('success', $msg);
 }
예제 #2
0
 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);
 }
예제 #3
0
 public function postFound()
 {
     $input = Input::all();
     $logged_in_data = Auth::org()->get();
     $rules = array('name' => 'required|alpha_spaces', 'dob' => 'date_format:m/d/Y', 'family_name' => 'alpha_spaces', 'phone_number' => 'numeric', 'police_station_number' => 'numeric', 'enquiry_office_number' => 'numeric', 'found_date' => 'date_format:m/d/Y', 'gender' => 'required');
     $v = Validator::make(Input::all(), $rules);
     if ($v->fails()) {
         return Redirect::back()->withInput(Input::all())->withErrors($v);
     }
     $input = $this->check_images_and_upload($input);
     $input['dob'] = GlobalFunc::set_date_format(Input::get('dob'));
     $input['found_date'] = GlobalFunc::set_date_format(Input::get('found_date'));
     $input['report_type'] = 'Found';
     $input['created_by'] = $logged_in_data->uid;
     $uid = strtoupper(Str::random(3)) . '_' . time();
     $input['uid'] = $uid;
     Found::create($input);
     return Redirect::back()->with('success', 'Record Successfully Inserted');
 }