Changeset e6c1f87
- Timestamp:
- 10/18/21 19:54:18 (3 years ago)
- Branches:
- develop, master
- Children:
- b9c4a92
- Parents:
- bd9e8e3
- Files:
-
- 4 added
- 1 deleted
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Dashboard/DepartmentsController.php
rbd9e8e3 re6c1f87 36 36 $department->code = $request->code; 37 37 38 $len = Storage::disk('local')->path(''); 39 38 40 if(!Storage::disk('local')->has('Departments/' . $request->code)){ 39 41 Storage::disk('local')->makeDirectory('Departments/' . $request->code); … … 41 43 42 44 $department->user_id = auth()->id(); 43 $department->location = '/Departments/' . $request->code;45 $department->location = Storage::disk('local')->path('') . 'Departments/' . $request->code; 44 46 45 47 $department->save(); … … 65 67 $department->name = $request->name; 66 68 $department->code = $request->code; 67 $department->updated_at = Carbon::now();;68 69 69 $path = '/Departments/' . $request->code; 70 $department->location = $path; 70 $department->location = Storage::disk('local')->path('') . 'Departments/' . $request->code; 71 71 72 72 $files = Storage::allFiles($oldDepartmentCode); -
app/Http/Controllers/Dashboard/DocumentsController.php
rbd9e8e3 re6c1f87 17 17 public function index(Request $request) 18 18 { 19 $queries = explode(" ", $request->search); 20 $result = collect(); 21 22 foreach ($queries as $query) { 23 $result->push(Document::where("arch_id", "like", "%{$query}%")->orWhere("name", "like", "%{$query}%")->get()); 24 } 25 26 $result = $result->flatten(); 27 28 19 29 if ($request->query('id')) { 20 $documents = Document::where('department_id', $request->query('id'))->get(); 21 } else { 22 $documents = Document::all(); 30 31 $documentsInDeptSort = Document::with('department')->when($request->has('id'), function($query) use ($request) { 32 $query->where('department_id', $request->query('id')); 33 }); 34 35 if($request->query('sort') == 'newest') { 36 $documents = $documentsInDeptSort->orderBy('created_at', 'desc')->paginate(20); 37 } 38 else if($request->query('sort') == 'name') { 39 $documents = $documentsInDeptSort->orderBy('name', 'asc')->paginate(20); 40 } 41 else{ 42 $documents = Document::where('department_id', $request->query('id'))->paginate(20); 43 } 44 } 45 else { 46 if($request->query('sort') == 'newest') { 47 $documents = Document::orderBy('created_at', 'desc')->paginate(20); 48 } 49 else if($request->query('sort') == 'name') { 50 $documents = Document::orderBy('name', 'asc')->paginate(20); 51 } 52 else if($request->query('sort') == 'important'){ 53 $documents = Document::where('is_important', true)->paginate(20); 54 } 55 else if($request->query('sort') == 'recent') { 56 $documents = Document::orderBy('created_at', 'desc')->paginate(20); 57 } 58 else if($request->query('search')){ 59 $result = collect(); 60 61 foreach ($queries as $query) { 62 $result->push(Document::where("arch_id", "like", "%{$query}%")->orWhere("name", "like", "%{$query}%")->get()); 63 } 64 $result = $result->flatten(); 65 $documents = $result; 66 } 67 else 68 { 69 $documents = Document::paginate(20); 70 } 23 71 } 24 72 25 73 $departments = Department::all(); 74 75 $diskTotal = disk_total_space('/'); 76 $diskTotalSize = $diskTotal / 1073741824; 77 78 $diskFree = disk_free_space('/'); 79 $used = $diskTotal - $diskFree; 80 81 $diskUsedSize = $used / 1073741824; 82 $diskUse1 = round(100 - (($diskUsedSize / $diskTotalSize) * 100)); 83 $diskUse = round(100 - ($diskUse1)) . '%'; 26 84 27 85 return view("dashboard.documents.index")->with([ … … 30 88 "departments" => $departments, 31 89 "docsCount" => Department::withCount('document')->get(), 32 'totalDocs' => Document::all()->count() 90 "totalDocs" => Document::all()->count(), 91 "countImportant" => Document::where('is_important', true)->get()->count(), 92 "diskTotal" => $diskTotal, 93 "diskTotalSize" => $diskTotalSize, 94 "diskUse" => $diskUse, 95 "diskUsedSize" => $diskUsedSize 96 33 97 ]); 34 98 … … 40 104 "departments" => Department::all() 41 105 ]); 106 } 107 108 public function store(DocumentRequest $request, UploadService $uploadService) 109 { 110 $document = new Document(); 111 $user = auth()->user(); 112 $department = Department::find($request->department); 113 114 $document->user()->associate($user); 115 $document->department()->associate($department); 116 117 $document->arch_id = $request->arch_id; 118 $document->name = $request->name; 119 $document->description = $request->description; 120 121 if (!Storage::disk('local')->has($document->department()->pluck('location')->join("") . '/' . $request->arch_id)) { 122 Storage::disk('local')->makeDirectory($document->department()->pluck('location')->join("") . '/' . $request->arch_id); 123 } 124 125 $documentFile = $uploadService->upload(File::class, [ 126 "file_item" => $request->file_item, 127 ], "link", true); 128 129 $document->save(); 130 131 foreach ($documentFile as $df) { 132 $file = File::find($df); 133 $file->document()->associate($document); 134 $file->save(); 135 } 136 137 Alert::flash("New document created successfully"); 138 139 return redirect()->route("dashboard.documents.index"); 42 140 } 43 141 … … 73 171 } 74 172 75 public function store(DocumentRequest $request, UploadService $uploadService) 76 { 77 $document = new Document(); 78 $user = auth()->user(); 79 $department = Department::find($request->department); 80 81 $document->user()->associate($user); 82 $document->department()->associate($department); 83 84 $document->arch_id = $request->arch_id; 85 $document->name = $request->name; 86 $document->description = $request->description; 87 88 if (!Storage::disk('local')->has($document->department()->pluck('location')->join("") . '/' . $request->arch_id)) { 89 Storage::disk('local')->makeDirectory($document->department()->pluck('location')->join("") . '/' . $request->arch_id); 90 } 91 92 $documentFile = $uploadService->upload(File::class, [ 93 "file_item" => $request->file_item, 94 ], "link", true); 95 173 public function toggleImportant($id) 174 { 175 $document = Document::find($id); 176 $document->is_important = !$document->is_important; 96 177 $document->save(); 97 178 98 foreach ($documentFile as $df) { 99 $file = File::find($df); 100 $file->document()->associate($document); 101 $file->save(); 102 } 103 104 Alert::flash("New document created successfully"); 105 179 if($document->is_important==true) 180 Alert::flash("Document marked as important successfully"); 181 else 182 Alert::flash("Document marked as not important successfully"); 183 184 return redirect()->back(); 185 } 186 187 public function search(Request $request) 188 { 189 $queries = explode(" ", $request->q); 190 $result = collect(); 191 192 foreach ($queries as $query) { 193 $result->push(Document::where("arch_id", "like", "%{$query}%")->orWhere("name", "like", "%{$query}%")->get()); 194 } 195 196 $result = $result->flatten(); 197 198 $departments = Department::all(); 199 200 return view("dashboard.documents.search") 201 ->with("searchQuery", $request->q) 202 ->with("results", $result) 203 ->with("departments", $departments) 204 ->with("countImportant", Document::where('is_important', true)->get()->count()); 205 } 206 207 public function destroy($id) 208 { 209 $document = Document::find($id); 210 if (auth()->user()->hasPermission("delete_all_posts")) { 211 $document->delete(); 212 Alert::flash($document->name . " deleted successfully"); 213 } 106 214 return redirect()->route("dashboard.documents.index"); 107 215 } 108 109 216 } -
app/Http/Controllers/Dashboard/SettingsController.php
rbd9e8e3 re6c1f87 3 3 namespace App\Http\Controllers\Dashboard; 4 4 5 use App\Helpers\Alert; 5 6 use App\Http\Requests\Dashboard\EmailSettingsRequest; 6 7 use App\Http\Requests\Dashboard\PasswordSettingsRequest; … … 10 11 use App\Notifications\VerifyNewEmail; 11 12 use Carbon\Carbon; 13 use Illuminate\Contracts\Validation\Validator; 14 use Illuminate\Http\Request; 15 use Illuminate\Validation\ValidationException; 12 16 13 17 class SettingsController extends Controller … … 17 21 return view("dashboard.settings.index")->with([ 18 22 "user" => auth()->user(), 19 "adminAnd Editors" => User::where("role_id", 1)->orWhere("role_id", 2)->get(),23 "adminAndReferents" => User::where("role_id", 1)->orWhere("role_id", 2)->get(), 20 24 "active_tab" => "account" 21 25 ]); … … 24 28 public function updateUsername(UsernameSettingsRequest $request) 25 29 { 26 if ($request->validated()) {27 30 $user = auth()->user(); 28 31 $user->username = $request->username; … … 33 36 34 37 return redirect()->route("auth.loginShow"); 35 } else {36 return back()->with(['active_tab' => 'security']);37 }38 39 dd('no');40 38 } 41 39 42 public function updatePassword( PasswordSettingsRequest $request)40 public function updatePassword(UsernameSettingsRequest $request) 43 41 { 44 $user = auth()->user();45 $user->password = bcrypt($request->password);46 $user->save();42 $user = auth()->user(); 43 $user->password = bcrypt($request->password); 44 $user->save(); 47 45 48 auth()->logout();49 session()->flush();46 auth()->logout(); 47 session()->flush(); 50 48 51 return redirect()->route("auth.loginShow");49 return redirect()->route("auth.loginShow"); 52 50 } 53 51 -
app/Http/Requests/Dashboard/DocumentRequest.php
rbd9e8e3 re6c1f87 3 3 namespace App\Http\Requests\Dashboard; 4 4 5 use App\Models\Department; 5 6 use App\Models\Document; 6 7 use App\Models\FileType; … … 38 39 $arch_id = $this->request->get('arch_id'); 39 40 $deptId = explode('/', $arch_id)[0]; 40 if ($deptId !== $this->request->get('department')) {41 $fail("D ept id error");41 if ($deptId !== Department::find($this->request->get('department'))->code) { 42 $fail("Document Archive ID field format is invalid"); 42 43 } 43 44 } -
app/Http/Requests/Dashboard/UsernameSettingsRequest.php
rbd9e8e3 re6c1f87 35 35 $response = redirect() 36 36 ->route('dashboard.settings.index') 37 ->with (['active_tab' => 'security'])37 ->withInput(['active_tab' => 'security']) 38 38 ->withErrors($validator); 39 39 40 throw (new ValidationException($validator , $response))40 throw (new ValidationException($validator)) 41 41 ->errorBag($this->errorBag) 42 42 ->redirectTo($this->getRedirectUrl()); -
app/Models/Document.php
rbd9e8e3 re6c1f87 8 8 class Document extends Model 9 9 { 10 use HasFactory; 10 11 protected $table = "documents"; 11 12 12 protected $fillable = ["arch_id", "name", "description", "user_id", "department_id"]; 13 protected $fillable = ["arch_id", "name", "description", "user_id", "department_id", "is_important"]; 14 13 15 14 16 public function user() { -
database/factories/DepartmentFactory.php
rbd9e8e3 re6c1f87 24 24 public function definition() 25 25 { 26 $location = $this->faker->unique()->numberBetween(1, 99);26 $location = $this->faker->unique()->numberBetween(1, 25); 27 27 Storage::disk('local')->makeDirectory('Departments/' . $location); 28 28 return [ 29 'id' => $this->faker->unique()->randomNumber(), 30 'name' => $this->faker->name(), 29 'name' => $this->faker->firstName() . " department", 31 30 'code' => $location, 32 'location' => 'Departments/' . $location,31 'location' => Storage::disk('local')->path('') . 'Departments/' . $location, 33 32 'user_id' => $this->faker->numberBetween('1', '2'), 34 33 'created_at' => Carbon::now() -
database/migrations/2021_10_06_103305_create_documents_table.php
rbd9e8e3 re6c1f87 19 19 $table->string("name"); 20 20 $table->text("description"); 21 $table->boolean("is_active")->default(false);22 21 $table->integer("user_id")->unsigned(); 23 22 $table->integer("department_id")->unsigned(); 23 $table->boolean("is_important")->default(true); 24 24 $table->timestamps(); 25 25 -
database/seeders/DatabaseSeeder.php
rbd9e8e3 re6c1f87 19 19 $this->call(UsersTableSeeder::class); 20 20 $this->call(DepartmentsTableSeeder::class); 21 //$this->call(DocumentsTableSeeder::class);21 $this->call(DocumentsTableSeeder::class); 22 22 } 23 23 } -
database/seeders/DepartmentsTableSeeder.php
rbd9e8e3 re6c1f87 16 16 public function run() 17 17 { 18 Department::factory()->count( 99)->create();18 Department::factory()->count(25)->create(); 19 19 } 20 20 } -
database/seeders/DocumentsTableSeeder.php
rbd9e8e3 re6c1f87 3 3 namespace Database\Seeders; 4 4 5 use App\Models\Document; 5 6 use Carbon\Carbon; 6 7 use Illuminate\Database\Seeder; … … 15 16 public function run() 16 17 { 17 \DB::table('documents')->insert([ 18 [ 19 "name" => "Document test", 20 "arch_id" => "HR150", 21 "description" => "hahahah ah aha hshdash dhawud hwa", 22 "user_id" => "1", 23 "department_id" => "1", 24 "is_active" => "1", 25 "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 26 ], 27 [ 28 "name" => "Document tests", 29 "arch_id" => "HR1505", 30 "description" => "hahahah ah aha hshdash dhawud hwa", 31 "user_id" => "1", 32 "department_id" => "2", 33 "is_active" => "1", 34 "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 35 ], 36 [ 37 "name" => "Document test", 38 "arch_id" => "HR15033", 39 "description" => "hahahah ah aha hshdash dhawud hwa", 40 "user_id" => "1", 41 "department_id" => "1", 42 "is_active" => "1", 43 "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 44 ], 45 [ 46 "name" => "Document testasd", 47 "arch_id" => "HR150124", 48 "description" => "hahahah ah aha hshdash dhawud hwa", 49 "user_id" => "1", 50 "department_id" => "3", 51 "is_active" => "1", 52 "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 53 ], 54 [ 55 "name" => "Document test", 56 "arch_id" => "HR1501421", 57 "description" => "hahahah ah aha hshdash dhawud hwa", 58 "user_id" => "1", 59 "department_id" => "1", 60 "is_active" => "1", 61 "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 62 ], 63 [ 64 "name" => "Document test", 65 "arch_id" => "HR150213", 66 "description" => "hahahah ah aha hshdash dhawud hwa", 67 "user_id" => "1", 68 "department_id" => "1", 69 "is_active" => "1", 70 "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 71 ], 72 [ 73 "name" => "Document test", 74 "arch_id" => "HR150ad", 75 "description" => "hahahah ah aha hshdash dhawud hwa", 76 "user_id" => "1", 77 "department_id" => "2", 78 "is_active" => "1", 79 "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 80 ], 81 [ 82 "name" => "Document test", 83 "arch_id" => "HR150234", 84 "description" => "hahahah ah aha hshdash dhawud hwa", 85 "user_id" => "1", 86 "department_id" => "3", 87 "is_active" => "1", 88 "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 89 ], 90 [ 91 "name" => "Document test", 92 "arch_id" => "HR15012321", 93 "description" => "hahahah ah aha hshdash dhawud hwa", 94 "user_id" => "1", 95 "department_id" => "1", 96 "is_active" => "1", 97 "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 98 ], 99 [ 100 "name" => "Document test", 101 "arch_id" => "HR15021312", 102 "description" => "hahahah ah aha hshdash dhawud hwa", 103 "user_id" => "1", 104 "department_id" => "1", 105 "is_active" => "1", 106 "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 107 ], 108 [ 109 "name" => "Document test", 110 "arch_id" => "HR15312430", 111 "description" => "hahahah ah aha hshdash dhawud hwa", 112 "user_id" => "1", 113 "department_id" => "1", 114 "is_active" => "1", 115 "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 116 ], 117 ]); 18 // \DB::table('documents')->insert([ 19 // [ 20 // "name" => "Document test", 21 // "arch_id" => "HR150", 22 // "description" => "hahahah ah aha hshdash dhawud hwa", 23 // "user_id" => "1", 24 // "department_id" => "1", 25 // "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 26 // ], 27 // [ 28 // "name" => "Document tests", 29 // "arch_id" => "HR1505", 30 // "description" => "hahahah ah aha hshdash dhawud hwa", 31 // "user_id" => "1", 32 // "department_id" => "2", 33 // "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 34 // ], 35 // [ 36 // "name" => "Document test", 37 // "arch_id" => "HR15033", 38 // "description" => "hahahah ah aha hshdash dhawud hwa", 39 // "user_id" => "1", 40 // "department_id" => "1", 41 // "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 42 // ], 43 // [ 44 // "name" => "Document testasd", 45 // "arch_id" => "HR150124", 46 // "description" => "hahahah ah aha hshdash dhawud hwa", 47 // "user_id" => "1", 48 // "department_id" => "3", 49 // "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 50 // ], 51 // [ 52 // "name" => "Document test", 53 // "arch_id" => "HR1501421", 54 // "description" => "hahahah ah aha hshdash dhawud hwa", 55 // "user_id" => "1", 56 // "department_id" => "1", 57 // "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 58 // ], 59 // [ 60 // "name" => "Document test", 61 // "arch_id" => "HR150213", 62 // "description" => "hahahah ah aha hshdash dhawud hwa", 63 // "user_id" => "1", 64 // "department_id" => "1", 65 // "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 66 // ], 67 // [ 68 // "name" => "Document test", 69 // "arch_id" => "HR150ad", 70 // "description" => "hahahah ah aha hshdash dhawud hwa", 71 // "user_id" => "1", 72 // "department_id" => "2", 73 // "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 74 // ], 75 // [ 76 // "name" => "Document test", 77 // "arch_id" => "HR150234", 78 // "description" => "hahahah ah aha hshdash dhawud hwa", 79 // "user_id" => "1", 80 // "department_id" => "3", 81 // "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 82 // ], 83 // [ 84 // "name" => "Document test", 85 // "arch_id" => "HR15012321", 86 // "description" => "hahahah ah aha hshdash dhawud hwa", 87 // "user_id" => "1", 88 // "department_id" => "1", 89 // "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 90 // ], 91 // [ 92 // "name" => "Document test", 93 // "arch_id" => "HR15021312", 94 // "description" => "hahahah ah aha hshdash dhawud hwa", 95 // "user_id" => "1", 96 // "department_id" => "1", 97 // "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 98 // ], 99 // [ 100 // "name" => "Document test", 101 // "arch_id" => "HR15312430", 102 // "description" => "hahahah ah aha hshdash dhawud hwa", 103 // "user_id" => "1", 104 // "department_id" => "1", 105 // "created_at" => Carbon::now()->format('Y-m-d H:i:s'), 106 // ], 107 // ]); 108 Document::factory()->count(300)->create(); 118 109 } 119 110 } -
public/assets/js/app.js
rbd9e8e3 re6c1f87 916 916 $(".edit_document_deparment").change(function() { 917 917 var archId = $("input[name='arch_id']"); 918 var currentArchId = archId.val(); 919 var currentText = currentArchId.split("/")[1]; 920 var selectedId = $(this).find('option:selected').val(); 921 922 if(currentText.length) { 918 var currentText = archId.val().split("/")[1]; 919 var selectedId = $(this).find('option:selected').data('dept-code'); 920 if(currentText) 923 921 archId.val(selectedId + "/" + currentText); 924 } else {922 else 925 923 archId.val(selectedId + "/"); 926 }927 924 }); 928 925 -
resources/assets/js/custom.js
rbd9e8e3 re6c1f87 9 9 $(".edit_document_deparment").change(function() { 10 10 var archId = $("input[name='arch_id']"); 11 var currentArchId = archId.val(); 12 var currentText = currentArchId.split("/")[1]; 13 var selectedId = $(this).find('option:selected').val(); 14 15 if(currentText.length) { 11 var currentText = archId.val().split("/")[1]; 12 var selectedId = $(this).find('option:selected').data('dept-code'); 13 if(currentText) 16 14 archId.val(selectedId + "/" + currentText); 17 } else {15 else 18 16 archId.val(selectedId + "/"); 19 }20 17 }); 21 18 -
resources/views/dashboard/departments/index.blade.php
rbd9e8e3 re6c1f87 67 67 @endif 68 68 <!-- Trigger --> 69 <td id="copy_{{ $department->id }}" value="{{$department->location}}">{{$department->location}}69 <td>{!! Str::substr($department->location , strlen(Storage::disk('local')->path(''))) !!} 70 70 <button class="btn btn-sm btn-primary text-white" data-clipboard-target="#copy_{{ $department->id }}"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clipboard" viewBox="0 0 16 16"> 71 71 <path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"/> 72 72 <path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3z"/> 73 73 </svg></button> 74 <span type="hidden" id="copy_{{$department->id}}"></span> 74 75 </td> 75 76 <td> -
resources/views/dashboard/documents/create.blade.php
rbd9e8e3 re6c1f87 35 35 <label for="exampleFormControlSelect1">Department</label> 36 36 @if($departments->count()) 37 <select class="form-control" name="department" required> 38 <option></option> 37 <select class="form-control edit_document_deparment" name="department" required> 39 38 @foreach ($departments as $department) 40 <option value="{{ $department->id }}" {{ (old("department") == $department->id ? "selected" : "") }}>{{ $department->name }}</option>39 <option value="{{ $department->id }}" data-dept-code="{{ $department->code }}" {{ (old("department") == $department->id ? "selected" : "") }}>{{ $department->name }}</option> 41 40 @endforeach 42 41 @else … … 49 48 <div class="form-group"> 50 49 <label>Archive ID</label> 51 <input type="text" name="arch_id" value="{{ old( 'arch_id') }}" class="form-control" placeholder="Archive ID" required>50 <input type="text" name="arch_id" value="{{ old("arch_id") }}" class="form-control" placeholder="Archive ID" required> 52 51 </div> 53 52 </div> -
resources/views/dashboard/documents/edit.blade.php
rbd9e8e3 re6c1f87 37 37 <select class="form-control edit_document_deparment" name="department" required> 38 38 @foreach ($departments as $department) 39 <option value="{{ $department->id }}" {{ old("department", $document->department->id) == $department->id ? "selected" : "" }}>{{ $department->name }}</option>39 <option value="{{ $department->id }}" data-dept-code="{{ $department->code }}" {{ old("department", $document->department->id) == $department->id ? "selected" : "" }}>{{ $department->name }}</option> 40 40 @endforeach 41 41 </select> -
resources/views/dashboard/documents/index.blade.php
rbd9e8e3 re6c1f87 32 32 </a> 33 33 @endforeach 34 <a href=" " class="list-group-item">34 <a href="{{ URL::current()."?sort=recent" }}" class="list-group-item"> 35 35 <i data-feather="upload-cloud" class="width-15 height-15 mr-2"></i> 36 36 Recents 37 37 </a> 38 <a href=" " class="list-group-item d-flex align-items-center">38 <a href="{{ URL::current()."?sort=important" }}" class="list-group-item d-flex align-items-center"> 39 39 <i data-feather="star" class="width-15 height-15 mr-2"></i> 40 40 Important 41 <span class="small ml-auto">10</span> 42 </a> 43 <a href="" class="list-group-item"> 44 <i data-feather="trash" class="width-15 height-15 mr-2"></i> 45 Deleted Files 41 <span class="small ml-auto">{{ $countImportant }}</span> 46 42 </a> 47 43 </div> … … 55 51 <div class="progress" style="height: 10px"> 56 52 <div class="progress-bar progress-bar-striped" role="progressbar" 57 style="width: 40%" aria-valuenow="10" aria-valuemin="0"53 style="width: {{$diskUse}}" aria-valuenow="10" aria-valuemin="0" 58 54 aria-valuemax="100"></div> 59 </div> 60 <div class="line-height-12 small text-muted mt-2">19.5GB used of 25GB</div> 55 <span class="sr-only">{{$diskUse}}</span> 56 </div> 57 <div class="line-height-12 small text-muted mt-2">{{round($diskUsedSize,2)}} GB / 58 {{round($diskTotalSize,2)}} GB ({{$diskUse}})</div> 61 59 </div> 62 60 </div> … … 98 96 </a> 99 97 <div class="dropdown-menu"> 100 <a class="dropdown-item" href="#">Date</a> 101 <a class="dropdown-item" href="#">Name</a> 102 <a class="dropdown-item" href="#">Size</a> 98 @if(Request::get('id')) 99 <a class="dropdown-item" href="{{ URL::current()."?id=".Request::get('id')."&sort=newest" }}">Date</a> 100 <a class="dropdown-item" href="{{ URL::current()."?id=".Request::get('id')."&sort=name" }}">Name</a> 101 <a class="dropdown-item" href="#">Size</a> 102 @else 103 <a class="dropdown-item" href="{{ URL::current()."?sort=newest" }}">Date</a> 104 <a class="dropdown-item" href="{{ URL::current()."?sort=name" }}">Name</a> 105 <a class="dropdown-item" href="#">Size - not done</a> 106 @endif 103 107 </div> 104 108 </li> … … 106 110 </div> 107 111 <div class="action-right"> 108 <form class="d-flex mr-3"> 109 <a href="#" class="app-sidebar-menu-button btn btn-outline-light"> 110 <i data-feather="menu"></i> 111 </a> 112 <form action="{{ route("dashboard.documents.index") }}" method="get" class="d-flex mr-3"> 112 113 <div class="input-group"> 113 <input type="text" class="form-control" placeholder="Search file"114 aria-describedby="button-addon1" >114 <input type="text" name="search" class="form-control" placeholder="Search file" 115 aria-describedby="button-addon1" required> 115 116 <div class="input-group-append"> 116 <button class="btn btn-outline-light " type="button" id="button-addon1">117 <button class="btn btn-outline-light searchSubmitBtn" type="submit" value="Search"> 117 118 <i data-feather="search"></i> 118 119 </button> … … 122 123 </div> 123 124 </div> 124 125 126 125 <p>Documents</p> 127 126 <div class="row"> … … 139 138 <a href="#" class="dropdown-item">Share</a> 140 139 <a href="#" class="dropdown-item">Download</a> 141 <a href="#" class="dropdown-item">Move to</a> 142 <a href="#" class="dropdown-item">Delete</a> 140 <button class="dropdown-item action-dropdown-item" 141 href="javascript:void(0)" onclick="toggleImportant({{$document->id}})"> 142 @if($document->is_important) 143 Mark as not important 144 @else 145 Mark as important 146 @endif 147 </button> 148 <a href="javascript:void(0)" class="dropdown-item" data-toggle="modal" data-target="#deleteModal_{{$document->id}}">Delete</a> 143 149 </div> 144 150 </div> 145 151 </div> 146 152 <div class="p-2 small"> 147 <div>{{$document->name}} - {{$document->arch_id}}</div> 153 @if($document->is_important) 154 <div>{{$document->name}} - {{$document->arch_id}} <i class="fa fa-star" style="color:orange"></i></div> 155 @else 156 <div>{{$document->name}} - {{$document->arch_id}} </div> 157 @endif 158 <div>{{$document->created_at}}</div> 148 159 <div class="text-muted">{{$document->description}}</div> 149 160 <div class="text-muted">1.2MB</div> … … 151 162 </div> 152 163 </div> 164 <form id="toggleImportant_{{ $document->id }}" 165 action="{{ route("dashboard.documents.toggleImportant", ["id" => $document->id]) }}" 166 method="post"> 167 @csrf 168 @method("patch") 169 </form> 170 <div class="modal fade" id="deleteModal_{{$document->id}}" tabindex="-1" role="dialog" aria-hidden="true"> 171 <div class="modal-dialog modal-dialog-centered" role="document"> 172 <div class="modal-content"> 173 <div class="modal-header"> 174 <h5 class="modal-title" id="exampleModalCenterTitle">Delete confirmation</h5> 175 <button type="button" class="close" data-dismiss="modal" aria-label="Close"> 176 <i class="ti-close"></i> 177 </button> 178 </div> 179 <div class="modal-body"> 180 <form action="{{ route("dashboard.documents.destroy", $document->id) }}" method="POST"> 181 @csrf 182 @method('DELETE') 183 <p>Are you sure you want to delete document {{$document->name}} with Archive ID: {{ $document->arch_id }}?</p> 184 <div class="modal-footer"> 185 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close 186 </button> 187 <button type="submit" class="btn btn-primary">Save changes</button> 188 </div> 189 </form> 190 </div> 191 192 </div> 193 </div> 194 </div> 153 195 @empty 154 <div >No items found</div>196 <div class="col-xl-3 col-lg-4 col-md-6 col-sm-12">No items found</div> 155 197 @endforelse 156 198 157 199 </div> 200 @if(!Request::query('search')) 201 {{$documents->appends($_GET)->links('layouts.pagination') }} 202 @endif 158 203 </div> 159 204 … … 162 207 @section('script') 163 208 164 209 <script> 210 function toggleImportant(id) { 211 document.getElementById('toggleImportant_' + id).submit(); 212 } 213 </script> 165 214 166 215 @endsection -
resources/views/dashboard/settings/index.blade.php
rbd9e8e3 re6c1f87 23 23 <div class="row"> 24 24 <div class="col-lg-3 col-md-12 mb-3"> 25 <div class="nav flex-lg-column flex-sm-row nav-pills" id=" v-pills-tab" role="tablist" aria-orientation="vertical">26 <a class="nav-link {{ $active_tab == 'account' ? 'active' : ''}}" id="account-tab" data-toggle="pill" href="#account" role="tab" aria-controls="account" aria-selected="true">Account</a>27 <a class="nav-link {{ $active_tab == 'security' ? 'active' : ''}}" id="security-tab" data-toggle="pill" href="#security" role="tab" aria-controls="security" aria-selected="false">Security</a>28 <a class="nav-link 25 <div class="nav flex-lg-column flex-sm-row nav-pills" id="#tabMenu" role="tablist" aria-orientation="vertical"> 26 <a class="nav-link {{$active_tab == 'account' ? 'active' : ""}}" id="account-tab" data-toggle="pill" href="#account" role="tab" aria-controls="account" aria-selected="true">Account</a> 27 <a class="nav-link {{$active_tab == 'security' ? 'active' : ""}}" id="security-tab" data-toggle="pill" href="#security" role="tab" aria-controls="security" aria-selected="false">Security</a> 28 <a class="nav-link" id="v-pills-settings-tab" data-toggle="pill" href="#v-pills-settings" role="tab" aria-controls="v-pills-settings" aria-selected="false">Social</a> 29 29 </div> 30 30 </div> 31 31 <div class="col-lg-9 col-md-12"> 32 32 <div class="tab-content" id="v-pills-tabContent"> 33 <div class="tab-pane fade show {{ $active_tab == 'account' ? 'active' : ''}}" id="account" role="tabpanel" aria-labelledby="account-tab">33 <div class="tab-pane {{$active_tab == 'account' ? 'active' : ""}}" id="account" role="tabpanel" aria-labelledby="account-tab"> 34 34 <div class="card"> 35 35 <div class="card-body"> … … 80 80 </div> 81 81 </div> 82 <div class="tab-pane {{ $active_tab == 'security' ? 'active' : ''}}" id="security" role="tabpanel" aria-labelledby="security-tab">82 <div class="tab-pane {{$active_tab == 'security' ? 'active' : ""}}" id="security" role="tabpanel" aria-labelledby="security-tab"> 83 83 <div class="card"> 84 84 <div class="card-body"> … … 239 239 240 240 @endsection 241 242 @section('script') 243 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> 244 <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js" integrity="sha512-uto9mlQzrs59VwILcLiRYeLKPPbS/bT71da/OEBYEwcdNUk8jYIy+D176RYoop1Da+f9mvkYrmj5MCLZWEtQuA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> 245 <script> 246 //redirect to specific tab 247 $(document).ready(function () { 248 $('#tabMenu a[href="#{{ old('tab') }}"]').tabs('show') 249 }); 250 </script> 251 @endsection -
routes/web.php
rbd9e8e3 re6c1f87 93 93 Route::patch("/documents/{id}/confirm", "Dashboard\DocumentsController@confirm")->name("dashboard.documents.confirm"); 94 94 Route::delete("/documents/{id}/destroy", "Dashboard\DocumentsController@destroy")->name("dashboard.documents.destroy"); 95 Route::patch('/documents/toggle-important/{id}', "Dashboard\DocumentsController@toggleImportant")->name("dashboard.documents.toggleImportant"); 95 96 96 97 });
Note:
See TracChangeset
for help on using the changeset viewer.