- Timestamp:
- 10/23/21 04:03:46 (3 years ago)
- Branches:
- develop, master
- Children:
- b39afb5
- Parents:
- c6b84df
- Location:
- app/Http/Controllers/Dashboard
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Dashboard/DepartmentsController.php
rc6b84df r4b7e2d3 147 147 if(!$flag) { 148 148 $zip->close(); 149 $headers = array('Content-Type' => 'application/octet-stream' ,);149 $headers = array('Content-Type' => 'application/octet-stream'); 150 150 $zip_new_name = Carbon::now()->format('d.m.Y - H:i') . '- Departments.zip'; 151 151 return response()->download($zip_file, $zip_new_name, $headers); … … 153 153 else { 154 154 Alert::flash("All departments are empty", "warning"); 155 return redirect()-> route("dashboard.departments.index");155 return redirect()->back(); 156 156 } 157 157 } … … 186 186 else{ 187 187 Alert::flash("This department has no files", "warning"); 188 return redirect()-> route("dashboard.departments.index");188 return redirect()->back(); 189 189 } 190 190 -
app/Http/Controllers/Dashboard/ExportExcelController.php
rc6b84df r4b7e2d3 3 3 namespace App\Http\Controllers\Dashboard; 4 4 5 use App\Exports\DepartmentsExport; 5 6 use App\Exports\FilesExport; 6 7 use App\Exports\FoldersExport; … … 32 33 33 34 } 35 36 public function ExportDepartments() 37 { 38 return Excel::download(new DepartmentsExport(), Carbon::now()->format('d.m.Y - H:i') . ' - departments.xlsx'); 39 40 } 41 34 42 } -
app/Http/Controllers/Dashboard/FilesController.php
rc6b84df r4b7e2d3 26 26 "textExt" => array("txt", "doc", "docx"), 27 27 "imageExt" => array("png", "jpg", "jpeg"), 28 "fileTypes" => '.' . implode(',.', explode(',', explode(':', FileType::find('1')->mimes)[1]))28 "fileTypes" => '.' . implode(',.', explode(',', FileType::find('1')->mimes)) 29 29 ]); 30 30 } … … 35 35 $file->delete(); 36 36 Storage::disk('uploads')->delete($file->location); 37 $file->folder()->decrement('no_of_files'); 37 38 38 39 Alert::flash($file->name . " deleted successfully"); … … 59 60 $newFile->location = $location . DIRECTORY_SEPARATOR . $fileName; 60 61 $newFile->folder()->associate($folder); 62 $newFile->folder()->increment('no_of_files'); 61 63 $newFile->save(); 62 64 } … … 65 67 Alert::flash("New files added successfully"); 66 68 67 return redirect()-> route("dashboard.files.index");69 return redirect()->back(); 68 70 } 69 71 else { 70 72 Alert::flash("No files were uploaded", "error"); 71 73 72 return redirect()-> route("dashboard.files.index");74 return redirect()->back(); 73 75 } 74 76 } -
app/Http/Controllers/Dashboard/FoldersController.php
rc6b84df r4b7e2d3 39 39 $folders = $foldersInDeptSort->orderBy('name', 'asc')->paginate(12); 40 40 } 41 else if ($request->query('sort') == 'no_of_files') { 42 $folders = $foldersInDeptSort->orderBy('no_of_files', 'desc')->paginate(12); 43 } 41 44 else if($request->query('sort') == 'count'){ 42 45 $total = $foldersInDeptSort->folder->files->count(); … … 52 55 else if ($request->query('sort') == 'name') { 53 56 $folders = Folder::orderBy('name', 'asc')->paginate(12); 57 } 58 else if ($request->query('sort') == 'no_of_files') { 59 $folders = Folder::orderBy('no_of_files', 'desc')->paginate(12); 54 60 } 55 61 else if ($request->query('sort') == 'important') { … … 97 103 "deptName" => $deptName, 98 104 "deptCode" => $deptCode, 99 "fileTypes" => '.' . implode(',.', explode(',', explode(':', FileType::find('1')->mimes)[1]))105 "fileTypes" => '.' . implode(',.', explode(',', FileType::find('1')->mimes)) 100 106 ]); 101 107 … … 117 123 $folder->user()->associate($user); 118 124 $folder->department()->associate($department); 125 $folder->department()->increment('no_of_folders'); 119 126 120 127 $folder->arch_id = $request->arch_id; … … 149 156 $newFile->location = $location . DIRECTORY_SEPARATOR . $fileName; 150 157 $newFile->folder()->associate($folder); 158 $newFile->folder()->increment('no_of_files'); 151 159 $newFile->save(); 152 160 } … … 155 163 Alert::flash("New folder created successfully"); 156 164 157 return redirect()-> route("dashboard.folders.index");165 return redirect()->back(); 158 166 } 159 167 … … 177 185 $department = Department::find($request->department); 178 186 179 $folder->department()-> associate($department);180 181 $oldLocation = $folder-> department->location . DIRECTORY_SEPARATOR . $folder->name;187 $folder->department()->increment('no_of_folders'); 188 189 $oldLocation = $folder->location; 182 190 183 191 $folder->name = $request->name; … … 186 194 $folder->updated_at = Carbon::now(); 187 195 188 $location = $folder->department->location . DIRECTORY_SEPARATOR . $request->name; 189 190 if ($folder->isDirty('name')) { 191 if (!Storage::disk('uploads')->has($location)) { 192 Storage::disk('uploads')->move($oldLocation, $location); 193 foreach($files as $file){ 194 $file->location = $location . DIRECTORY_SEPARATOR . $file->name; 196 $newLocation = Department::find($request->department)->location . DIRECTORY_SEPARATOR . $request->name; 197 198 if($folder->department_id != $request->department){ 199 $folder->department()->decrement('no_of_folders'); 200 if (!Storage::disk('uploads')->has($newLocation)) { 201 Storage::disk('uploads')->move($oldLocation, $newLocation); 202 foreach($files as $file) { 203 $file->location = $newLocation . DIRECTORY_SEPARATOR . $file->name; 195 204 $file->save(); 196 205 } 197 206 } 198 207 } 208 if($folder->isDirty('name')) { 209 if (!Storage::disk('uploads')->has($newLocation)) { 210 Storage::disk('uploads')->move($oldLocation, $newLocation); 211 foreach($files as $file) { 212 $file->location = $newLocation . DIRECTORY_SEPARATOR . $file->name; 213 $file->save(); 214 } 215 } 216 } 217 218 $folder->department()->associate($department); 219 220 $folder->location = $newLocation; 199 221 200 222 if ($request->has('file_item')) { 201 223 foreach ($request->file_item as $file) { 202 224 $fileName = $folder->name . '-' . uniqid() . '.' . $file->getClientOriginalExtension(); 203 $file->storeAs($ location . DIRECTORY_SEPARATOR, $fileName);225 $file->storeAs($newLocation . DIRECTORY_SEPARATOR, $fileName); 204 226 $newFile = new File(); 205 227 $newFile->name = $fileName; 206 $newFile->location = $ location . DIRECTORY_SEPARATOR . $fileName;228 $newFile->location = $newLocation . DIRECTORY_SEPARATOR . $fileName; 207 229 $newFile->folder()->associate($folder); 230 $newFile->folder()->increment('no_of_files'); 208 231 $newFile->save(); 209 232 } 210 233 } 211 234 212 $folder->location = $location;213 214 235 $folder->save(); 215 216 236 217 237 Alert::flash("Folder edited successfully"); … … 246 266 $location = $folder->department->location . DIRECTORY_SEPARATOR . $folder->name; 247 267 Storage::disk('uploads')->deleteDirectory($location); 268 $folder->department()->decrement('no_of_folders'); 248 269 Alert::flash($folder->name . " deleted successfully"); 270 return redirect()->back(); 249 271 } 250 272 Alert::flash($folder->name . " is important", "error"); 251 return redirect()-> route("dashboard.folders.index");273 return redirect()->back(); 252 274 } 253 275 … … 306 328 } 307 329 else { 308 $files = File::where('folder_id', $id)->paginate(1 0);330 $files = File::where('folder_id', $id)->paginate(12); 309 331 } 310 332 … … 317 339 "imageExt" => array("png", "jpg", "jpeg"), 318 340 "folders" => $folders, 319 "fileTypes" => '.' . implode(',.', explode(',', explode(':', FileType::find('1')->mimes)[1]))341 "fileTypes" => '.' . implode(',.', explode(',', FileType::find('1')->mimes)) 320 342 ]); 321 343 } -
app/Http/Controllers/Dashboard/IndexController.php
rc6b84df r4b7e2d3 9 9 use App\Models\User; 10 10 use App\Http\Controllers\Controller; 11 use Carbon\Carbon; 12 use Illuminate\Support\Facades\DB; 11 13 12 14 class IndexController extends Controller … … 18 20 ); 19 21 22 $date = Carbon::today()->subDays(5); 23 $recentFiles = File::where('created_at', '>=', $date)->get(); 24 25 $year = ['2021','2022','2023','2024', '2025']; 26 27 $file = []; 28 foreach ($year as $key => $value) { 29 $file[] = File::where(DB::raw("DATE_FORMAT(created_at, '%Y')"),$value)->count(); 30 } 31 20 32 return view("dashboard.index")->with([ 21 33 "counters" => $counters, 34 "largestDepartments" => Department::orderBy('no_of_folders', 'desc')->limit(10)->get(), 35 "folders" => Folder::all(), 36 "files" => File::all(), 37 "recentFiles" => $recentFiles, 38 "year" => json_encode($year,JSON_NUMERIC_CHECK), 39 "file" => json_encode($file,JSON_NUMERIC_CHECK), 22 40 "departments" => Department::all(), 23 "folders" => Folder::all(), 24 "files" => File::all() 25 ]); 41 "excelExt" => array("xls", "xlsx", "xls", "csv"), 42 "textExt" => array("txt", "doc", "docx"), 43 "imageExt" => array("png", "jpg", "jpeg"), 44 45 ]); 26 46 } 27 47 } -
app/Http/Controllers/Dashboard/SettingsController.php
rc6b84df r4b7e2d3 77 77 } 78 78 79 80 81 79 public function fileTypes(FileTypeRequest $request) 82 80 {
Note:
See TracChangeset
for help on using the changeset viewer.