Changeset 4521f25
- Timestamp:
- 10/31/21 22:09:08 (3 years ago)
- Branches:
- master
- Children:
- 8fdb18e
- Parents:
- e78295c
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Dashboard/FoldersController.php
re78295c r4521f25 4 4 5 5 use App\Helpers\Alert; 6 use App\Http\Requests\Dashboard\FileRequest; 6 7 use App\Http\Requests\Dashboard\FolderRequest; 7 8 use App\Http\Requests\Dashboard\FileNameRequest; … … 186 187 } 187 188 189 public function uploadFiles(FileRequest $request, $id) 190 { 191 $file = new File(); 192 193 $folder = Folder::findOrFail($id); 194 195 $location = $folder->location; 196 197 $users = User::all(); 198 199 if ($request->has('file_item')) { 200 foreach ($request->file_item as $file) { 201 $fileName = $file->getClientOriginalName(); 202 203 if(File::where(['folder_id' => $folder->id, 'name' => $fileName])->count() > 0) { 204 Alert::flash("The uploaded file already exists", "error"); 205 206 return redirect()->back(); 207 } 208 209 $file->storeAs($location . DIRECTORY_SEPARATOR, $fileName); 210 $newFile = new File(); 211 $newFile->name = $fileName; 212 $newFile->location = $location . DIRECTORY_SEPARATOR . $fileName; 213 //$newFile->folder()->associate($folder); 214 $newFile->folder()->associate($folder); 215 $newFile->folder()->increment('no_of_files'); 216 $newFile->save(); 217 } 218 219 Alert::flash("New files added successfully"); 220 221 return redirect()->back(); 222 } 223 else { 224 Alert::flash("No files were uploaded", "error"); 225 226 return redirect()->back(); 227 } 228 } 229 188 230 public function destroy($id) 189 231 { -
resources/views/dashboard/files/index.blade.php
re78295c r4521f25 76 76 {{-- </a>--}} 77 77 {{-- </div>--}} 78 <div class="col-xl-1 col-lg-1 col-md-1 col-sm-2"> 79 <i class="fa fa-file-image-o text-danger fa-2x"></i> 80 </div> 78 <i class="fa fa-file-image-o text-danger"></i> 81 79 @else 82 <div class="col-xl-1 col-lg-1 col-md-1 col-sm-2"> 83 <i class="fa fa-file-text-o text-warning fa-2x"></i> 84 </div> 80 <i class="fa fa-file-text-o text-warning"></i> 85 81 @endif 86 82 @endif … … 107 103 @if(auth()->user()->hasPermission('manage_all_files')) 108 104 <td> 105 <a href="javascript:void(0)" class="text-secondary" data-toggle="modal" data-target="#editModal_{{$file->id}}" title="Edit"> 106 <i class="ti-pencil"></i> 107 </a> 109 108 <a href="{{ route("dashboard.files.downloadFile", ['id' => $file->id]) }}" class="text-danger ml-2"title="Download"> 110 109 <i class="ti-download"></i> … … 145 144 </div> 146 145 146 <div class="modal fade" id="editModal_{{$file->id}}" tabindex="-1" role="dialog" aria-hidden="true"> 147 <div class="modal-dialog modal-dialog-centered" role="document"> 148 <div class="modal-content"> 149 <div class="modal-header"> 150 <h5 class="modal-title" id="exampleModalCenterTitle">Rename file</h5> 151 <button type="button" class="close" data-dismiss="modal" aria-label="Close"> 152 <i class="ti-close"></i> 153 </button> 154 </div> 155 <div class="modal-body"> 156 <form action="{{ route("dashboard.files.renameFile", ["id" =>$file->id]) }}" method="post" accept-charset="utf-8"> 157 @method("patch") 158 @csrf 159 <div class="row"> 160 <div class="col-md-12"> 161 <div class="form-group"> 162 <label class="form-label">Current name: {{$file->name}}</label> 163 <input type="text" name="name" value="{{ explode('.', $file->name)[0] }}" maxlength="255" title="Don't include: '\/.|'" pattern="^[^.\/|]+$" class="form-control" required> 164 </div> 165 </div> 166 </div> 167 <br/> 168 <div class="modal-footer"> 169 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close 170 </button> 171 <button type="submit" class="btn btn-primary">Save changes</button> 172 </div> 173 </form> 174 </div> 175 176 </div> 177 </div> 178 </div> 147 179 @endforeach 148 180 -
resources/views/dashboard/folders/files.blade.php
re78295c r4521f25 8 8 <div class="col-md-3 app-sidebar"> 9 9 <div class="card"> 10 <div class="card-body"> 11 @if(auth()->user()->hasPermission('manage_all_files')) 12 <a href="javascript:void(0)" class="btn btn-secondary btn-block file-upload-btn text-white" data-toggle="modal" data-target="#uploadFiles_{{$folder->id}}"> 13 Upload files 14 </a> 15 @endif 16 </div> 10 17 <div class="app-sidebar-menu"> 11 18 <div class="list-group list-group-flush"> … … 15 22 </a> 16 23 @foreach($folders as $obj) 17 <a href="{{ route("dashboard.folders.files", ["id" => $obj->id]) }}" class="list-group-item d-flex align-items-center"> 24 @if($obj == $folder) 25 <a href="{{ route("dashboard.folders.files", ["id" => $folder->id]) }}" class="list-group-item d-flex align-items-center" style="font-weight: bold;"> 18 26 <i data-feather="folder" class="width-15 height-15 mr-2"></i> 19 {{$ obj->name}}20 <span class="small ml-auto">{{$ obj->files->count()}}</span>27 {{$folder->name}} 28 <span class="small ml-auto">{{$folder->files->count()}}</span> 21 29 </a> 30 @else 31 <a href="{{ route("dashboard.folders.files", ["id" => $obj->id]) }}" class="list-group-item d-flex align-items-center"> 32 <i data-feather="folder" class="width-15 height-15 mr-2"></i> 33 {{$obj->name}} 34 <span class="small ml-auto">{{$obj->files->count()}}</span> 35 </a> 36 @endif 22 37 @endforeach 23 38 </div> … … 54 69 </div> 55 70 56 <p>Files </p>71 <p>Files in {{$folder->name}}</p> 57 72 58 73 <div class="row"> … … 75 90 {{-- </a>--}} 76 91 {{-- </div>--}} 77 <div class="col-xl-1 col-lg-1 col-md-1 col-sm-2"> 78 <i class="fa fa-file-image-o text-danger fa-2x"></i> 79 </div> 92 <i class="fa fa-file-image-o text-danger"></i> 80 93 @else 81 94 <i class="fa fa-file-text-o text-warning"></i> … … 145 158 146 159 </div> 147 160 <div class="modal fade" id="uploadFiles_{{$folder->id}}" tabindex="-1" role="dialog" aria-hidden="true"> 161 <div class="modal-dialog modal-dialog-centered" role="document"> 162 <div class="modal-content"> 163 <div class="modal-header"> 164 <h5 class="modal-title" id="exampleModalCenterTitle">Upload</h5> 165 <button type="button" class="close" data-dismiss="modal" aria-label="Close"> 166 <i class="ti-close"></i> 167 </button> 168 </div> 169 <div class="modal-body"> 170 <form action="{{ route("dashboard.files.store") }}" method="post" accept-charset="utf-8" enctype="multipart/form-data"> 171 @csrf 172 <div class="row"> 173 <div class="col-md-10"> 174 <div class="form-group"> 175 <select class="form-control" name="folder" hidden> 176 <option value="{{ $folder->id }}" {{ (old("folder") == $folder->id ? "selected" : "") }}>{{ $folder->name }}</option> 177 </select> 178 </div> 179 </div> 180 <div class="col-md-10"> 181 <div class="form-group"> 182 <label for="exampleFormControlSelect1">Files</label> 183 184 185 <input type="file" class="form-control" id="file-item" name="file_item[]" accept="{{ $fileTypes }}" multiple> 186 </div> 187 </div> 188 </div> 189 <br/> 190 <div class="modal-footer"> 191 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close 192 </button> 193 <button type="submit" class="btn btn-primary">Save changes</button> 194 </div> 195 </form> 196 </div> 197 198 </div> 199 </div> 200 </div> 148 201 </div> 149 202 -
resources/views/dashboard/folders/index.blade.php
re78295c r4521f25 22 22 </a> 23 23 @foreach($departments as $department) 24 <a href="{{ route("dashboard.folders.index", ["id" => $department->id]) }}" class="list-group-item d-flex align-items-center"> 24 @if(Request::query('id') == $department->id) 25 <a href="{{ route("dashboard.folders.index", ["id" => $department->id]) }}" class="list-group-item d-flex align-items-center" style="font-weight: bold;"> 25 26 <i data-feather="folder" class="width-15 height-15 mr-2"></i> 26 27 {{$department->name}} 27 28 <span class="small ml-auto">{{$department->folder->count()}}</span> 28 29 </a> 30 @else 31 <a href="{{ route("dashboard.folders.index", ["id" => $department->id]) }}" class="list-group-item d-flex align-items-center"> 32 <i data-feather="folder" class="width-15 height-15 mr-2"></i> 33 {{$department->name}} 34 <span class="small ml-auto">{{$department->folder->count()}}</span> 35 </a> 36 @endif 29 37 @endforeach 30 38 <a href="{{ URL::current()."?sort=recent" }}" class="list-group-item"> … … 138 146 <div class="dropdown-menu dropdown-menu-right"> 139 147 <a href="{{ route("dashboard.folders.files", ["id" => $folder->id]) }}" class="dropdown-item">View files</a> 148 @if(auth()->user()->hasPermission('manage_all_files')) 149 <a href="javascript:void(0)" data-toggle="modal" data-target="#uploadFiles_{{$folder->id}}" class="dropdown-item">Upload files</a> 150 @endif 140 151 @if(auth()->user()->hasPermission('download_data')) 141 152 <a href="{{ route("dashboard.folders.downloadFolder", ['id' => $folder->id]) }}" class="dropdown-item">Download</a> … … 186 197 </form> 187 198 </div> 199 </div> 200 </div> 201 </div> 202 203 <div class="modal fade" id="uploadFiles_{{$folder->id}}" tabindex="-1" role="dialog" aria-hidden="true"> 204 <div class="modal-dialog modal-dialog-centered" role="document"> 205 <div class="modal-content"> 206 <div class="modal-header"> 207 <h5 class="modal-title" id="exampleModalCenterTitle">Upload</h5> 208 <button type="button" class="close" data-dismiss="modal" aria-label="Close"> 209 <i class="ti-close"></i> 210 </button> 211 </div> 212 <div class="modal-body"> 213 <form action="{{ route("dashboard.files.store") }}" method="post" accept-charset="utf-8" enctype="multipart/form-data"> 214 @csrf 215 <div class="row"> 216 <div class="col-md-10"> 217 <div class="form-group"> 218 <select class="form-control" name="folder" hidden> 219 <option value="{{ $folder->id }}" {{ (old("folder") == $folder->id ? "selected" : "") }}>{{ $folder->name }}</option> 220 </select> 221 </div> 222 </div> 223 <div class="col-md-10"> 224 <div class="form-group"> 225 <label for="exampleFormControlSelect1">Files</label> 226 227 228 <input type="file" class="form-control" id="file-item" name="file_item[]" accept="{{ $fileTypes }}" multiple> 229 </div> 230 </div> 231 </div> 232 <br/> 233 <div class="modal-footer"> 234 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close 235 </button> 236 <button type="submit" class="btn btn-primary">Save changes</button> 237 </div> 238 </form> 239 </div> 240 188 241 </div> 189 242 </div> -
resources/views/dashboard/index.blade.php
re78295c r4521f25 151 151 {{-- </a>--}} 152 152 {{-- </div>--}} 153 <div class="col-xl-1 col-lg-1 col-md-1 col-sm-2"> 154 <i class="fa fa-file-image-o text-danger fa-2x"></i> 155 </div> 153 <i class="fa fa-file-image-o text-danger"></i> 156 154 @else 157 <div class="col-xl-1 col-lg-1 col-md-1 col-sm-2"> 158 <i class="fa fa-file-text-o text-warning fa-2x"></i> 159 </div> 155 <i class="fa fa-file-text-o text-warning"></i> 160 156 @endif 161 157 @endif -
routes/web.php
re78295c r4521f25 102 102 Route::post("/folders/store", "Dashboard\FoldersController@store")->name("dashboard.folders.store"); 103 103 Route::get("/folders/{id}/edit", "Dashboard\FoldersController@editShow")->name("dashboard.folders.editShow"); 104 Route::patch("/folders/{id}/edit", "Dashboard\FoldersController@edit")->name("dashboard.folders.edit");105 Route::patch("/folders/{id}/block", "Dashboard\FoldersController@block")->name("dashboard.folders.block");106 Route::patch("/folders/{id}/unblock", "Dashboard\FoldersController@unblock")->name("dashboard.folders.unblock");107 Route::patch("/folders/{id}/confirm", "Dashboard\FoldersController@confirm")->name("dashboard.folders.confirm");108 104 Route::delete("/folders/{id}/destroy", "Dashboard\FoldersController@destroy")->name("dashboard.folders.destroy"); 109 Route::patch('/folders/toggle-important/{id}', "Dashboard\FoldersController@toggleImportant")->name("dashboard.folders.toggleImportant"); 105 Route::post("/folders/{id}/upload", "Dashboard\FoldersController@uploadFiles")->name("dashboard.folders.uploadFiles"); 106 110 107 }); 111 108
Note:
See TracChangeset
for help on using the changeset viewer.