Changeset d795fa6 for app/Http/Controllers/Dashboard
- Timestamp:
- 10/17/21 18:39:50 (3 years ago)
- Branches:
- develop, master
- Children:
- bd9e8e3
- Parents:
- 120759b
- Location:
- app/Http/Controllers/Dashboard
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Dashboard/DepartmentsController.php
r120759b rd795fa6 7 7 use App\Http\Requests\Dashboard\UpdateDepartmentRequest; 8 8 use App\Models\Department; 9 use App\Models\Document; 9 10 use App\Models\User; 11 use Carbon\Carbon; 10 12 use Illuminate\Http\Request; 11 13 use App\Http\Controllers\Controller; … … 25 27 { 26 28 return view("dashboard.departments.create"); 27 }28 29 public function editShow($id)30 {31 return view("dashboard.departments.edit")->with([32 "department" => Department::findOrFail($id)33 ]);34 29 } 35 30 … … 55 50 } 56 51 52 public function editShow($id) 53 { 54 return view("dashboard.departments.edit")->with([ 55 "department" => Department::findOrFail($id) 56 ]); 57 } 58 57 59 public function edit(UpdateDepartmentRequest $request, $id) 58 60 { … … 63 65 $department->name = $request->name; 64 66 $department->code = $request->code; 67 $department->updated_at = Carbon::now();; 65 68 66 69 $path = '/Departments/' . $request->code; … … 83 86 } 84 87 85 public function destroy( Request $request,$id)88 public function destroy($id) 86 89 { 87 90 $department = Department::find($id); 91 //$department->delete(); 92 $documents = $department->document()->count(); 88 93 89 $department->delete(); 94 if($documents > 0){ 95 Alert::flash($department->name . " has " . $documents . " document/s associated", "error"); 96 } 97 else { 98 $department->delete(); 90 99 91 Alert::flash($department->name . " deleted successfully"); 100 Alert::flash($department->name . " deleted successfully"); 101 } 92 102 93 103 return redirect()->route("dashboard.departments.index"); -
app/Http/Controllers/Dashboard/DocumentsController.php
r120759b rd795fa6 8 8 use App\Models\Document; 9 9 use App\Models\File; 10 use App\Models\Files;11 use App\Models\User;12 use App\Notifications\NewDocumentCreated;13 10 use App\Services\UploadService; 14 11 use Illuminate\Http\Request; 15 12 use Illuminate\Support\Facades\Storage; 16 use Mews\Purifier\Facades\Purifier;17 13 use App\Http\Controllers\Controller; 18 use Illuminate\Support\Facades\Notification;19 14 20 15 class DocumentsController extends Controller 21 16 { 22 public function index( )17 public function index(Request $request) 23 18 { 24 if (auth()->user()->hasPermission("manage_all_documents")) 19 if($request->department) { 20 $documents = Document::with('department')->where('department', function ($query) { 21 $query->where('id', $request->department)->get(); 22 }); 23 } 24 else{ 25 25 $documents = Document::all(); 26 else 27 $documents = Document::where("user_id", auth()->user()->id)->get(); 26 } 27 28 $departments = Department::all(); 28 29 29 30 return view("dashboard.documents.index")->with([ 30 31 "documents" => $documents, 31 32 "currentUser" => auth()->user(), 32 "departments" => Department::all(),33 "departments" => $departments, 33 34 "docsCount" => Department::withCount('document')->get(), 34 35 'totalDocs' => Document::all()->count() 35 36 ]); 37 36 38 } 37 39 … … 66 68 $document->arch_id = $request->arch_id; 67 69 $document->description = $request->description; 70 $document->updated_at = $request->Carbon::now();; 68 71 69 72 $document->save(); … … 108 111 } 109 112 110 public function getDocumentsInDepartment($id)111 {112 $documents = Department::findOrFail($id)->document()->get();113 $department = Department::findOrFail($id);114 115 return view('dashboard.documents.department')116 ->with([117 'documents' => $documents,118 'departments' => Department::all(),119 'totalDocs' => Document::all()->count(),120 'department' => $department121 122 ]);123 }124 125 113 } -
app/Http/Controllers/Dashboard/SettingsController.php
r120759b rd795fa6 3 3 namespace App\Http\Controllers\Dashboard; 4 4 5 use App\Helpers\Alert;6 5 use App\Http\Requests\Dashboard\EmailSettingsRequest; 7 use App\Http\Requests\Dashboard\NewUserRequest;8 6 use App\Http\Requests\Dashboard\PasswordSettingsRequest; 9 use App\Http\Requests\Dashboard\PhotosSettingsRequest;10 use App\Http\Requests\Dashboard\SocialLinksSettingsRequest;11 use App\Http\Requests\Dashboard\UpdateUserData;12 use App\Http\Requests\Dashboard\UpdateUserRequest;13 7 use App\Http\Requests\Dashboard\UsernameSettingsRequest; 14 use App\Http\Requests\Dashboard\UserProfileSettingsRequest;15 use App\Models\Post;16 use App\Models\Role;17 8 use App\Models\User; 18 use App\Models\UserProfile;19 use Illuminate\Support\Str;20 use Illuminate\Http\Request;21 9 use App\Http\Controllers\Controller; 22 use Illuminate\Support\Facades\File;23 use Illuminate\Support\Facades\Hash;24 10 use App\Notifications\VerifyNewEmail; 25 use Illuminate\Support\Facades\Storage; 26 use Propaganistas\LaravelPhone\PhoneNumber; 27 use Propaganistas\LaravelIntl\Facades\Country; 11 use Carbon\Carbon; 28 12 29 13 class SettingsController extends Controller … … 33 17 return view("dashboard.settings.index")->with([ 34 18 "user" => auth()->user(), 35 "adminAndEditors" => User::where("role_id", 1)->orWhere("role_id", 2)->get() 19 "adminAndEditors" => User::where("role_id", 1)->orWhere("role_id", 2)->get(), 36 20 ]); 37 21 } … … 39 23 public function updateUsername(UsernameSettingsRequest $request) 40 24 { 41 $user = auth()->user(); 42 $user->username = $request->username; 43 $user->save(); 44 45 auth()->logout(); 46 session()->flush(); 47 48 return redirect()->route("auth.loginShow"); 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 // } 49 38 } 50 39 -
app/Http/Controllers/Dashboard/UsersController.php
r120759b rd795fa6 8 8 use App\Http\Requests\Dashboard\UpdateUserRequest; 9 9 use App\Models\Avatar; 10 use Carbon\Carbon; 10 11 use Illuminate\Support\Facades\File; 11 12 use App\Models\Role; … … 41 42 $user->surname = $request->surname; 42 43 $user->email = $request->email; 43 $user-> mobile_number = $request->mobile_number;44 $user->phone_number = $request->phone_number; 44 45 $user->username = $request->username; 45 46 $user->password = $user->generateTemporaryPassword(); … … 85 86 $user->username = $request->username; 86 87 $user->email = $request->email; 87 $user-> mobile_number = $request->mobile_number;88 $user->phone_number = $request->phone_number; 88 89 $user->role_id = $request->userRole; 90 $user->updated_at = $request->Carbon::now();; 89 91 90 92 if ($request->hasFile("avatar")) { … … 152 154 $user->name = $request->name; 153 155 $user->surname = $request->surname; 154 $user-> mobile_number = $request->mobile_number;156 $user->phone_number = $request->phone_number; 155 157 156 158 if ($request->hasFile("avatar")) {
Note:
See TracChangeset
for help on using the changeset viewer.