- Timestamp:
- 10/17/21 18:39:50 (3 years ago)
- Branches:
- develop, master
- Children:
- bd9e8e3
- Parents:
- 120759b
- Location:
- app
- Files:
-
- 1 added
- 1 deleted
- 14 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")) { -
app/Http/Requests/Dashboard/DocumentRequest.php
r120759b rd795fa6 4 4 5 5 use App\Models\Document; 6 use App\Models\FileType; 6 7 use Illuminate\Foundation\Http\FormRequest; 7 8 … … 30 31 public function rules() 31 32 { 33 32 34 $rules = [ 33 35 "arch_id" => "required|min:10|max:255", … … 40 42 $fileRules = [ 41 43 "file_item.*" => "mimes:jpg,jpeg,png|max:4096" 42 ];44 ]; 43 45 } else { 44 46 $fileRules = [ -
app/Http/Requests/Dashboard/EmailSettingsRequest.php
r120759b rd795fa6 25 25 { 26 26 return [ 27 "email" => "required|string|email|max: 255|unique:users,email,$this->id,id",27 "email" => "required|string|email|max:50|unique:users,email,$this->id,id", 28 28 ]; 29 29 } -
app/Http/Requests/Dashboard/NewDepartmentRequest.php
r120759b rd795fa6 25 25 { 26 26 return [ 27 "name" => "required|min:2|max: 25|unique:departments,name",27 "name" => "required|min:2|max:30|unique:departments,name", 28 28 "code" => "required|min:2|max:10|unique:departments,code" 29 29 ]; -
app/Http/Requests/Dashboard/NewUserRequest.php
r120759b rd795fa6 25 25 { 26 26 return [ 27 "name" => "required|alpha|min:2|max: 255",28 "surname" => "required|alpha|min:2|max: 255",29 " mobile_number" => "required|unique:users,mobile_number",30 "email" => "required|string|email|max: 255|unique:users,email",31 "username" => "required|min: 8|unique:users,username",27 "name" => "required|alpha|min:2|max:30", 28 "surname" => "required|alpha|min:2|max:30", 29 "phone_number" => "required|unique:users,phone_number", 30 "email" => "required|string|email|max:50|unique:users,email", 31 "username" => "required|min:5|max:30|unique:users,username", 32 32 "userRole" => "required|exists:roles,id", 33 33 "avatar" => "mimes:jpeg,png,gif|max:5000", -
app/Http/Requests/Dashboard/PasswordSettingsRequest.php
r120759b rd795fa6 34 34 } 35 35 ], 36 "password" => "required|string|confirmed|min: 8",36 "password" => "required|string|confirmed|min:6", 37 37 ]; 38 38 } -
app/Http/Requests/Dashboard/UpdateDepartmentRequest.php
r120759b rd795fa6 25 25 { 26 26 return [ 27 "name" => "required|min:2|max: 25|unique:departments,name,$this->id,id",28 "code" => "required|min:2|max: 10|unique:departments,code,$this->id,id"27 "name" => "required|min:2|max:30|unique:departments,name,$this->id,id", 28 "code" => "required|min:2|max:30|unique:departments,code,$this->id,id" 29 29 ]; 30 30 } -
app/Http/Requests/Dashboard/UpdateUserData.php
r120759b rd795fa6 25 25 { 26 26 return [ 27 "name" => "required|alpha|min:2|max: 255",28 "surname" => "required|alpha|min:2|max: 255",29 " mobile_number" => "required|unique:users,mobile_number,$this->id,id",27 "name" => "required|alpha|min:2|max:30", 28 "surname" => "required|alpha|min:2|max:30", 29 "phone_number" => "required|unique:users,phone_number,$this->id,id", 30 30 "avatar" => "mimes:jpeg,png,gif|max:5000", 31 31 ]; -
app/Http/Requests/Dashboard/UpdateUserRequest.php
r120759b rd795fa6 25 25 { 26 26 return [ 27 "name" => "required|alpha|min:2|max: 255",28 "surname" => "required|alpha|min:2|max: 255",29 " mobile_number" => "required|unique:users,mobile_number,$this->id,id",30 "email" => "required|string|email|max: 255|unique:users,email,$this->id,id",31 "username" => "required|min: 8|unique:users,username,$this->id,id",27 "name" => "required|alpha|min:2|max:30", 28 "surname" => "required|alpha|min:2|max:30", 29 "phone_number" => "required|unique:users,phone_number,$this->id,id", 30 "email" => "required|string|email|max:50|unique:users,email,$this->id,id", 31 "username" => "required|min:5|unique:users,username,$this->id,id", 32 32 "userRole" => "required|exists:roles,id", 33 33 "avatar" => "mimes:jpeg,png,gif|max:5000", -
app/Http/Requests/Dashboard/UsernameSettingsRequest.php
r120759b rd795fa6 25 25 { 26 26 return [ 27 "username" => "required|alpha_dash|min: 8|unique:users,username,$this->id,id"27 "username" => "required|alpha_dash|min:5|unique:users,username,$this->id,id" 28 28 ]; 29 29 } -
app/Models/User.php
r120759b rd795fa6 26 26 "password", 27 27 "email", 28 " mobile_number",28 "phone_number", 29 29 "avatar", 30 30 "role_id" … … 129 129 return Str::random($length); 130 130 } 131 132 public function getCreatedByName() 133 { 134 return User::where('id', $this->created_by)->pluck('username')->first(); 135 } 131 136 }
Note:
See TracChangeset
for help on using the changeset viewer.