protected function postComment(Request $request) { if ($request->exists('comment')) { if ($request->exists('approve')) { $user = Auth::user(); $user_id = $user->id; $document_id = $request->document_id; Document::where('id', $document_id)->update(['status' => 'approved']); Comment::create(['comment' => $request->comment, 'boss_id' => $user->id, 'document_id' => $document_id]); return Redirect::route('documents')->with('success', 'Document approved successful'); } else { if ($request->exists('decline')) { $user = Auth::user(); $user_id = $user->id; $document_id = $request->document_id; Document::where('id', $document_id)->update(['status' => 'declined']); Comment::create(['comment' => $request->comment, 'boss_id' => $user->id, 'document_id' => $document_id]); return Redirect::route('documents')->with('success', 'Document declined successful'); } } } else { return Redirect::route('documents')->with('fail', 'Something wrong!!'); } }
public function forCourse($id) { $documents = Document::where('course_id', $id)->with('author', 'course')->orderBy('created_at', 'desc')->paginate(15); $filter = 'cours'; return view('admin.documents.index', compact('documents', 'filter', 'id')); }
public function deleteDocument($id) { $document = Document::find($id); if (isset($document)) { Document::where('id', $id)->update(['status' => 'deleted']); } return Redirect::route('documents')->with('success', 'Document deleted successful.'); }
public static function downloadLink($file_name) { $link = url('/'); if (Laralum::isDocument($file_name)) { $document = Document::where('name', $file_name)->first(); $link = route('Laralum::document_downloader', ['slug' => $document->slug]); } return $link; }
public function documentsValidated($id, $value) { $course = Course::with(['users' => function ($query) { $query->where('level', 1); }, 'manager'])->find($id); if (empty($course)) { Flash::error('Ce cours n\'existe pas.'); return abort(404); } if (Auth::user()->level_id <= 3 && !$course->users->contains(Auth::user())) { Flash::error('Vous n\'avez pas les droits suffisants.'); return Redirect::back(); } if ($value != 0 && $value != 1) { Flash::error('Requête invalide.'); return Redirect::back(); } $documents = Document::where('course_id', $id)->where('validated', $value)->with('author')->paginate(15); $filter = $value == 0 ? 'invalidés' : 'validés'; return view('admin.courses.documents', compact('documents', 'filter', 'course')); }