Example #1
0
 public function showDocument()
 {
     $user = Auth::user();
     $query = Input::get('search');
     if ($user->is_boss == 0) {
         $documents = Document::where('users.id', $user->id);
         $documents = $documents->join('users', 'users.id', '=', 'officer_id');
     } else {
         $documents = Document::join('users', 'users.id', '=', 'officer_id');
     }
     if (isset($query)) {
         $documents = $documents->where('documents.name', 'LIKE', '%' . $query . '%');
     }
     $documents = $documents->select('documents.*', 'users.name as username');
     $documents = $documents->orderBy('updated_at', 'desc');
     $documents = $documents->paginate(10);
     return view('index', ['documents' => $documents, 'user' => $user]);
 }