- Timestamp:
- 10/17/21 20:28:35 (3 years ago)
- Branches:
- develop, master
- Children:
- e6c1f87
- Parents:
- d795fa6
- Location:
- app/Http
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Dashboard/DocumentsController.php
rd795fa6 rbd9e8e3 17 17 public function index(Request $request) 18 18 { 19 if($request->department) { 20 $documents = Document::with('department')->where('department', function ($query) { 21 $query->where('id', $request->department)->get(); 22 }); 23 } 24 else{ 19 if ($request->query('id')) { 20 $documents = Document::where('department_id', $request->query('id'))->get(); 21 } else { 25 22 $documents = Document::all(); 26 23 } … … 68 65 $document->arch_id = $request->arch_id; 69 66 $document->description = $request->description; 70 $document->updated_at = $request->Carbon::now();;71 67 72 68 $document->save(); … … 90 86 $document->description = $request->description; 91 87 92 if (!Storage::disk('local')->has($document->department()->pluck('location')->join("") . '/' . $request->arch_id)){88 if (!Storage::disk('local')->has($document->department()->pluck('location')->join("") . '/' . $request->arch_id)) { 93 89 Storage::disk('local')->makeDirectory($document->department()->pluck('location')->join("") . '/' . $request->arch_id); 94 90 } … … 106 102 } 107 103 108 104 Alert::flash("New document created successfully"); 109 105 110 106 return redirect()->route("dashboard.documents.index"); -
app/Http/Controllers/Dashboard/SettingsController.php
rd795fa6 rbd9e8e3 18 18 "user" => auth()->user(), 19 19 "adminAndEditors" => User::where("role_id", 1)->orWhere("role_id", 2)->get(), 20 "active_tab" => "account" 20 21 ]); 21 22 } … … 23 24 public function updateUsername(UsernameSettingsRequest $request) 24 25 { 25 // if($request->validated()){ 26 // $user = auth()->user(); 27 // $user->username = $request->username; 28 // $user->save(); 29 // 30 // auth()->logout(); 31 // session()->flush(); 32 // 33 // return redirect()->route("auth.loginShow"); 34 // } 35 // else { 36 return back()->withInput(['tab'=>'security']); 37 // } 26 if ($request->validated()) { 27 $user = auth()->user(); 28 $user->username = $request->username; 29 $user->save(); 30 31 auth()->logout(); 32 session()->flush(); 33 34 return redirect()->route("auth.loginShow"); 35 } else { 36 return back()->with(['active_tab' => 'security']); 37 } 38 39 dd('no'); 38 40 } 39 41 -
app/Http/Requests/Dashboard/DocumentRequest.php
rd795fa6 rbd9e8e3 16 16 public function authorize() 17 17 { 18 if ($this->isMethod("patch")) {18 if ($this->isMethod("patch")) { 19 19 $document = Document::find($this->route("id")); 20 20 return auth()->user()->hasPermission("edit_all_documents") || ($document->user->id == auth()->user()->id); … … 33 33 34 34 $rules = [ 35 "arch_id" => "required|min:10|max:255", 35 "arch_id" => [ 36 "required", 37 function($attribute, $value, $fail) { 38 $arch_id = $this->request->get('arch_id'); 39 $deptId = explode('/', $arch_id)[0]; 40 if ($deptId !== $this->request->get('department')) { 41 $fail("Dept id error"); 42 } 43 } 44 ], 36 45 "name" => "required|min:10|max:255", 37 46 "department" => "required|integer|exists:departments,id", … … 39 48 ]; 40 49 41 if ($this->isMethod("patch")) {50 if ($this->isMethod("patch")) { 42 51 $fileRules = [ 43 52 "file_item.*" => "mimes:jpg,jpeg,png|max:4096" 44 53 ]; 45 54 } else { 46 55 $fileRules = [ -
app/Http/Requests/Dashboard/UsernameSettingsRequest.php
rd795fa6 rbd9e8e3 4 4 5 5 use Illuminate\Foundation\Http\FormRequest; 6 use Illuminate\Contracts\Validation\Validator; 7 use Illuminate\Validation\ValidationException; 6 8 7 9 class UsernameSettingsRequest extends FormRequest … … 28 30 ]; 29 31 } 32 33 protected function failedValidation(Validator $validator) 34 { 35 $response = redirect() 36 ->route('dashboard.settings.index') 37 ->with(['active_tab' => 'security']) 38 ->withErrors($validator); 39 40 throw (new ValidationException($validator, $response)) 41 ->errorBag($this->errorBag) 42 ->redirectTo($this->getRedirectUrl()); 43 } 30 44 }
Note:
See TracChangeset
for help on using the changeset viewer.