Changeset 94f05dc
- Timestamp:
- 10/24/21 23:23:54 (3 years ago)
- Branches:
- develop, master
- Children:
- df6e9ec
- Parents:
- fa80fbe
- Files:
-
- 4 added
- 2 deleted
- 10 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Dashboard/DepartmentsController.php
rfa80fbe r94f05dc 47 47 48 48 $users = User::all(); 49 Notification::send($users, new NewDepartmentCreated("New department created"));50 49 51 50 $department->save(); … … 127 126 try { 128 127 $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)); 129 $flag = false;130 131 128 foreach ($files as $file) { 132 129 … … 154 151 $department = Department::find($id); 155 152 156 $FileSystem = new Filesystem(); 157 $zip_file = Storage::disk('uploads')->path('Department.zip'); 153 $zip_file=Storage::disk('uploads')->path('Department.zip'); 158 154 $zip = new \ZipArchive(); 159 155 $zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE); 160 $path = Storage::disk('uploads')->path($department->location) . DIRECTORY_SEPARATOR;156 $path = Storage::disk('uploads')->path($department->location); 161 157 162 try {158 try { 163 159 $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)); 164 160 foreach ($files as $file) { 161 162 // We're skipping all subfolders 165 163 if (!$file->isDir()) { 166 164 $filePath = $file->getRealPath(); … … 169 167 $zip->addFile($filePath, $relativePath); 170 168 } 169 } 171 170 $zip->close(); 172 $headers = array('Content-Type' => 'application/octet-stream' ,);173 $zip_new_name = Carbon::now()->format('d.m.Y - H:i') . $department->name . '.zip';171 $headers = array('Content-Type' => 'application/octet-stream'); 172 $zip_new_name = Carbon::now()->format('d.m.Y - H:i') . '- Departments.zip'; 174 173 return response()->download($zip_file, $zip_new_name, $headers); 175 174 } 176 } 177 catch(\Exception $e) { 178 Alert::flash("This department has no files", "warning"); 175 catch(\Exception $e){ 176 Alert::flash("All departments are empty", "warning"); 179 177 return redirect()->back(); 180 }178 } 181 179 } 182 180 } -
app/Http/Controllers/Dashboard/FoldersController.php
rfa80fbe r94f05dc 163 163 Alert::flash("New folder created successfully"); 164 164 165 return redirect()-> back();165 return redirect()->route("dashboard.folders.index"); 166 166 } 167 167 -
app/Http/Requests/Dashboard/FolderRequest.php
rfa80fbe r94f05dc 41 41 $arch_id = $this->request->get('arch_id'); 42 42 43 $dept Id= explode('/', $arch_id)[0];43 $deptCode = explode('/', $arch_id)[0]; 44 44 $archNum = explode('/', $arch_id)[1]; 45 45 … … 48 48 } 49 49 50 if ($dept Id !== Department::find($this->request->get('department'))->code) {50 if ($deptCode != Department::find($this->request->get('department'))->code) { 51 51 $fail("Folder Archive ID field format is invalid"); 52 52 } 53 } catch (\Exception $e) { 53 } 54 catch (\Exception $e) { 54 55 $fail("Please enter folders Archive ID"); 55 56 } -
config/filesystems.php
rfa80fbe r94f05dc 33 33 'local' => [ 34 34 'driver' => 'local', 35 'root' => public_path() . DIRECTORY_SEPARATOR . 'uploads',35 'root' => storage_path() . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'public', 36 36 'permissions' => [ 37 37 'file' => [ … … 53 53 'public' => [ 54 54 'driver' => 'local', 55 'root' => storage_path( 'app/public'),55 'root' => storage_path() . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'public', 56 56 'url' => env('APP_URL').'/storage', 57 57 'visibility' => 'public', … … 60 60 'uploads' => [ 61 61 'driver' => 'local', 62 'root' => public_path() . '/uploads',62 'root' => storage_path() . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'public', 63 63 ], 64 64 -
database/factories/FolderFactory.php
rfa80fbe r94f05dc 27 27 public function definition() 28 28 { 29 $deptId = 15;30 29 31 $deptCode = Department::find( $deptId)->code;30 $deptCode = Department::find(1)->code; 32 31 33 32 $name = $this->faker->unique()->firstName(); … … 42 41 'location' => $location, 43 42 'user_id' => 1, 44 'department_id' => $deptId,43 'department_id' => 1, 45 44 'is_important' => $this->faker->boolean, 46 45 'created_at' => now() -
database/seeders/DatabaseSeeder.php
rfa80fbe r94f05dc 18 18 $this->call(RolesPermissionsTableSeeder::class); 19 19 $this->call(UsersTableSeeder::class); 20 //$this->call(DepartmentsTableSeeder::class);20 $this->call(DepartmentsTableSeeder::class); 21 21 $this->call(FileTypesTableSeeder::class); 22 //$this->call(FoldersTableSeeder::class);22 $this->call(FoldersTableSeeder::class); 23 23 //$this->call(FilesTableSeeder::class); 24 24 } -
database/seeders/FoldersTableSeeder.php
rfa80fbe r94f05dc 17 17 public function run() 18 18 { 19 Folder::factory()->count(5 00)->create();19 Folder::factory()->count(5)->create(); 20 20 $folders = Folder::all(); 21 21 -
resources/views/dashboard/files/index.blade.php
rfa80fbe r94f05dc 76 76 @else @if(in_array(explode('.', $file->name)[1], $imageExt)) 77 77 <div class="col-xl-1 col-lg-1 col-md-1 col-sm-2"> 78 <a href="{{ url('/ uploads/' . $file->location) }}" class="image-popup-gallery-item">78 <a href="{{ url('/storage/' . $file->location) }}" class="image-popup-gallery-item"> 79 79 <div class="image-hover"> 80 <img src="{{ url('/ uploads/' . $file->location) }}" class="rounded" width="30" alt="image">80 <img src="{{ url('/storage/' . $file->location) }}" class="rounded" width="30" alt="image"> 81 81 </div> 82 82 </a> -
resources/views/dashboard/folders/files.blade.php
rfa80fbe r94f05dc 10 10 <div class="card-body"> 11 11 @if(auth()->user()->hasPermission('manage_all_folders')) 12 <a class="btn btn-secondary btn-block text-white" href="javascript:void(0)" data-target="# editModal_{{$folder->id}}" data-toggle="modal">13 Upload12 <a class="btn btn-secondary btn-block text-white" href="javascript:void(0)" data-target="#createModal{{$folder->id}}" data-toggle="modal"> 13 Edit folder 14 14 </a> 15 15 @endif … … 44 44 <div class="dropdown-menu"> 45 45 <a class="dropdown-item" href="javascript:void(0)" data-toggle="modal" data-target="#editModal_{{$folder->id}}"> 46 Upload46 Edit folder 47 47 </a> 48 48 </div> … … 88 88 @else @if(in_array(explode('.', $file->name)[1], $imageExt)) 89 89 <div class="col-xl-1 col-lg-1 col-md-1 col-sm-2"> 90 <a href="{{ url('/ uploads/' . $file->location) }}" class="image-popup-gallery-item">90 <a href="{{ url('/storage/' . $file->location) }}" class="image-popup-gallery-item"> 91 91 <div class="image-hover"> 92 <img src="{{ url('/ uploads/' . $file->location) }}" class="rounded" width="100" alt="image">92 <img src="{{ url('/storage/' . $file->location) }}" class="rounded" width="100" alt="image"> 93 93 </div> 94 94 </a> -
resources/views/dashboard/index.blade.php
rfa80fbe r94f05dc 145 145 @else @if(in_array(explode('.', $file->name)[1], $imageExt)) 146 146 <div class="col-xl-1 col-lg-1 col-md-1 col-sm-2"> 147 <a href="{{ url('/ uploads/' . $file->location) }}" class="image-popup-gallery-item">147 <a href="{{ url('/storage/' . $file->location) }}" class="image-popup-gallery-item"> 148 148 <div class="image-hover"> 149 <img src="{{ url('/ uploads/' . $file->location) }}" class="rounded" width="30" alt="image">149 <img src="{{ url('/storage/' . $file->location) }}" class="rounded" width="30" alt="image"> 150 150 </div> 151 151 </a>
Note:
See TracChangeset
for help on using the changeset viewer.