Changeset 94f05dc for app/Http


Ignore:
Timestamp:
10/24/21 23:23:54 (3 years ago)
Author:
beratkjufliju <kufliju@…>
Branches:
develop, master
Children:
df6e9ec
Parents:
fa80fbe
Message:

bug fixes

Location:
app/Http
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • app/Http/Controllers/Dashboard/DepartmentsController.php

    rfa80fbe r94f05dc  
    4747
    4848        $users = User::all();
    49         Notification::send($users, new NewDepartmentCreated("New department created"));
    5049
    5150        $department->save();
     
    127126        try {
    128127            $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
    129             $flag = false;
    130 
    131128            foreach ($files as $file) {
    132129
     
    154151        $department = Department::find($id);
    155152
    156         $FileSystem = new Filesystem();
    157         $zip_file = Storage::disk('uploads')->path('Department.zip');
     153        $zip_file=Storage::disk('uploads')->path('Department.zip');
    158154        $zip = new \ZipArchive();
    159155        $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);
    161157
    162         try{
     158        try {
    163159            $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
    164160            foreach ($files as $file) {
     161
     162                // We're skipping all subfolders
    165163                if (!$file->isDir()) {
    166164                    $filePath = $file->getRealPath();
     
    169167                    $zip->addFile($filePath, $relativePath);
    170168                }
     169            }
    171170            $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';
    174173            return response()->download($zip_file, $zip_new_name, $headers);
    175174        }
    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");
    179177            return redirect()->back();
    180     }
     178        }
    181179    }
    182180}
  • app/Http/Controllers/Dashboard/FoldersController.php

    rfa80fbe r94f05dc  
    163163        Alert::flash("New folder created successfully");
    164164
    165         return redirect()->back();
     165        return redirect()->route("dashboard.folders.index");
    166166    }
    167167
  • app/Http/Requests/Dashboard/FolderRequest.php

    rfa80fbe r94f05dc  
    4141                        $arch_id = $this->request->get('arch_id');
    4242
    43                         $deptId = explode('/', $arch_id)[0];
     43                        $deptCode = explode('/', $arch_id)[0];
    4444                        $archNum = explode('/', $arch_id)[1];
    4545
     
    4848                        }
    4949
    50                         if ($deptId !== Department::find($this->request->get('department'))->code) {
     50                        if ($deptCode != Department::find($this->request->get('department'))->code) {
    5151                            $fail("Folder Archive ID field format is invalid");
    5252                        }
    53                     } catch (\Exception $e) {
     53                    }
     54                    catch (\Exception $e) {
    5455                        $fail("Please enter folders Archive ID");
    5556                    }
Note: See TracChangeset for help on using the changeset viewer.