public function destroy($id) { if (is_numeric($id)) { $projectComment = ProjectComment::findOrFail($id); $projectComment->delete(); return response()->json(['success' => 'Successfully deleted']); } else { abort('The required parameters are missing or invalid', 500); } }
function getCheckunsafecomment($id = '', $unsafe_id = '') { //dd($id); $startDate = date("Y-m-d H:i:s"); $endDate = date("Y-m-d H:i:s", strtotime('-24 hours')); if ($id == "") { $project_update = ProjectComment::where('updated_at', '>=', $endDate)->get(); } else { $project_update = ProjectComment::where('id', '>=', $id)->get(); } //dd("A"); //dd($project_update); $titles = NULL; $description = NULL; $new_search = NULL; $getUnsafewords = 0; for ($i = 0; $i < count($project_update); $i++) { $titles = $project_update[$i]['comment']; // change with your field $new_search = $titles; $getUnsafewords = $this->getUnsafewords($new_search); if ($getUnsafewords == 1) { if ($id == "") { //dd("A"); $unsafeDetails = ProjectComment::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 = "comments"; // 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'], 'comments'); if ($getCheckduplicate) { $unsafe->save(); } } else { //dd("D"); $update = ProjectComment::where('id', '=', $id)->update(array('status' => '2')); $updateUnsafe = Unsafe::where('id', '=', $unsafe_id)->update(array('notified' => '2')); } } } }