id; $task_id = $req->task_id; $del = Comment::find($id); if (File::exists('assets/document/task/'.$del->url) && !empty($del->url)) { File::delete('assets/document/task/'.$del->url); } //activity log $task_info = Task::find($task_id); $task_name = $task_info->name; $proj_id = $task_info->proj_id; $comment = $del->comment; $msg = "$comment -removed from $task_name."; $this->task_log($msg,$task_id,$proj_id); //call function $del->delete(); $str = $this->fetch_comments($task_id); // call function return $str; } public function edit_comment_form(Request $req){ $id = $req->id; $fet = Comment::find($id); $data['comment'] = $fet->comment; $data['id'] = $id; return $data; } public function save_update_comment(Request $req){ $comment = $req->comment; $id = $req->id; $task_id = $req->task_id; $sav = Comment::find($id); $sav->comment = $comment; //activity log $task_info = Task::find($task_id); $task_name = $task_info->name; $proj_id = $task_info->proj_id; $msg = "$comment -edited from $task_name."; $this->task_log($msg,$task_id,$proj_id); //call function $sav->save(); $data = $this->fetch_comments($task_id); // call function return $data; } public function fetch_comments($task_id){ $fetch = Comment::with('user')->where('task_id',$task_id)->orderBy('id','DESC')->get(); $str = ""; $login_user = Auth::user()->id; if(count($fetch) > 0){ foreach($fetch as $fet) { $immmgg = "assets/document/task/$fet->url"; $str .=""; $str .="* $fet->comment -by ".$fet->user->name; if(!empty($fet->url)){ $str .="
url")."> "; } $str .="
"; } } return $str; } public function add_task_doc(Request $req) { $file = $req->file('file'); $task_id = $req->task_id; date_default_timezone_set("Asia/Dhaka"); $assign_time = date('Y-m-d H:i:s'); if ($req->hasFile('file')){ $extension = $file->getClientOriginalExtension(); $os = array("jpg", "jpeg", "png", "gif"); if (in_array($extension, $os)){ $name = $file->getClientOriginalName(); $newFileName = "task_".date('d_m_y_h_m_s').".".$extension;; $fileee = $file->move('assets/document/task/', $newFileName); $sav = new Comment; $sav->comment = $name; $sav->url = $newFileName; $sav->task_id = $task_id; $sav->date_time = $assign_time; $sav->post_by = Auth::user()->id; $sav->save(); } } } public function task_log($msg,$task_id,$proj_id) { date_default_timezone_set("Asia/Dhaka"); $assign_time = date('Y-m-d H:i:s'); $sav = new ActivityLog; $sav->msg = $msg; $sav->proj_id = $proj_id; $sav->task_id = $task_id; $sav->logged_user_id = Auth::user()->id; $sav->created_at = $assign_time; $sav->save(); } }