- Timestamp:
- 10/17/21 18:39:50 (3 years ago)
- Branches:
- develop, master
- Children:
- bd9e8e3
- Parents:
- 120759b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Dashboard/DocumentsController.php
r120759b rd795fa6 8 8 use App\Models\Document; 9 9 use App\Models\File; 10 use App\Models\Files;11 use App\Models\User;12 use App\Notifications\NewDocumentCreated;13 10 use App\Services\UploadService; 14 11 use Illuminate\Http\Request; 15 12 use Illuminate\Support\Facades\Storage; 16 use Mews\Purifier\Facades\Purifier;17 13 use App\Http\Controllers\Controller; 18 use Illuminate\Support\Facades\Notification;19 14 20 15 class DocumentsController extends Controller 21 16 { 22 public function index( )17 public function index(Request $request) 23 18 { 24 if (auth()->user()->hasPermission("manage_all_documents")) 19 if($request->department) { 20 $documents = Document::with('department')->where('department', function ($query) { 21 $query->where('id', $request->department)->get(); 22 }); 23 } 24 else{ 25 25 $documents = Document::all(); 26 else 27 $documents = Document::where("user_id", auth()->user()->id)->get(); 26 } 27 28 $departments = Department::all(); 28 29 29 30 return view("dashboard.documents.index")->with([ 30 31 "documents" => $documents, 31 32 "currentUser" => auth()->user(), 32 "departments" => Department::all(),33 "departments" => $departments, 33 34 "docsCount" => Department::withCount('document')->get(), 34 35 'totalDocs' => Document::all()->count() 35 36 ]); 37 36 38 } 37 39 … … 66 68 $document->arch_id = $request->arch_id; 67 69 $document->description = $request->description; 70 $document->updated_at = $request->Carbon::now();; 68 71 69 72 $document->save(); … … 108 111 } 109 112 110 public function getDocumentsInDepartment($id)111 {112 $documents = Department::findOrFail($id)->document()->get();113 $department = Department::findOrFail($id);114 115 return view('dashboard.documents.department')116 ->with([117 'documents' => $documents,118 'departments' => Department::all(),119 'totalDocs' => Document::all()->count(),120 'department' => $department121 122 ]);123 }124 125 113 }
Note:
See TracChangeset
for help on using the changeset viewer.