Beispiel #1
0
 function getCheckunsafeupdate($id = '', $unsafe_id = '')
 {
     $startDate = date("Y-m-d H:i:s");
     $endDate = date("Y-m-d H:i:s", strtotime('-24 hours'));
     if ($id == "") {
         $project_update = ProjectUpdates::where('updated_at', '>=', $endDate)->get();
     } else {
         $project_update = ProjectUpdates::where('id', '>=', $id)->get();
     }
     //dd("C");
     $titles = NULL;
     $description = NULL;
     $new_search = NULL;
     $getUnsafewords = 0;
     for ($i = 0; $i < count($project_update); $i++) {
         $titles = $project_update[$i]['title'];
         // change with your field
         $description = $project_update[$i]['description'];
         // change with your field
         $new_search = $titles . " , " . $description;
         $getUnsafewords = $this->getUnsafewords($new_search);
         if ($getUnsafewords == 1) {
             if ($id == "") {
                 $unsafeDetails = ProjectUpdates::findOrFail($project_update[$i]['id']);
                 $unsafe = new Unsafe();
                 $unsafe->post_id = $project_update[$i]['id'];
                 $unsafe->user_id = $project_update[$i]['user_id'];
                 $unsafe->type = "updates";
                 // add table name
                 $unsafe->status = 1;
                 $unsafe->notified = 0;
                 //getCheckduplicate(unique id for update/comment,table name)
                 //return true or false
                 $getCheckduplicate = $this->getCheckduplicate($project_update[$i]['id'], 'updates');
                 if ($getCheckduplicate) {
                     $unsafe->save();
                 }
             } else {
                 $update = ProjectUpdates::where('id', '=', $id)->update(array('status' => '2'));
                 $updateUnsafe = Unsafe::where('id', '=', $unsafe_id)->update(array('notified' => '2'));
             }
         }
     }
 }
Beispiel #2
0
 public function postPedit($id, $update_title, $update_text)
 {
     $project_update = ProjectUpdates::findOrFail($id);
     $project_update->title = $update_title;
     $project_update->description = $update_text;
     $project_update->status = 1;
     $userProfile = Profile::where('user_id', Auth::id())->first();
     if ($id == '' || $update_text == '' || $update_title == '') {
         echo "An error occurred. Please try again later";
         die;
     }
     if ($project_update->save()) {
         echo $id;
         /*echo '<div class="update_listing">
         			<div class="update_image"><img src="'.url().'/images/avtar-image/'.$userProfile['user_avtar'].'" alt="Reminder icon" width="50" border="0" ></div>
         			<div class="update_text">
         				<p><span>'.$update_title.'</span> - just now</p>
         				'.$update_text.'
         			</div>
         		</div><div class="clear"></div>';*/
     }
 }