/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(CasePriorityRequest $request) { $case = CasePriority::where('id', $request['casePriorityId'])->first(); $case->name = $request['name']; $case->updated_by = \Auth::user()->id; $case->save(); \Session::flash('success', 'well done! case priority ' . $request['name'] . ' has been successfully updated!'); return redirect()->back(); }
/** * Bootstrap any application services. * * @return void */ public function boot() { if (\Schema::hasTable('positions')) { $positions = Position::all(); $selectPositions = array(); $selectPositions[0] = "Select / All"; foreach ($positions as $position) { $selectPositions[$position->slug] = $position->name; } \View::share('selectPositions', $selectPositions); } if (\Schema::hasTable('cases_priorities')) { $priorities = CasePriority::all(); $selectPriorities = array(); $selectPriorities[0] = "Select / All"; foreach ($priorities as $priority) { $selectPriorities[$priority->slug] = $priority->name; } \View::share('selectPriorities', $selectPriorities); } if (\Schema::hasTable('titles')) { $titles = Title::all(); $selectTitles = array(); $selectTitles[0] = "Select / All"; foreach ($titles as $title) { $selectTitles[$title->slug] = $title->name; } \View::share('selectTitles', $selectTitles); } if (\Schema::hasTable('languages')) { $languages = Language::all(); $selectLanguages = array(); $selectLanguages[0] = "Select / All"; foreach ($languages as $language) { $selectLanguages[$language->slug] = $language->name; } \View::share('selectLanguages', $selectLanguages); } if (\Schema::hasTable('departments')) { $departments = Department::all(); $selectDepartments = array(); $selectDepartments[0] = "Select / All"; foreach ($departments as $department) { $selectDepartments[$department->slug] = $department->name; } \View::share('selectDepartments', $selectDepartments); } if (\Schema::hasTable('users_roles')) { $roles = UserRole::all(); $selectRoles = array(); $selectRoles[0] = "Select / All"; foreach ($roles as $role) { $selectRoles[$role->slug] = $role->name; } \View::share('selectRoles', $selectRoles); } if (\Schema::hasTable('provinces')) { $provinces = Province::all(); $selectProvinces = array(); $selectProvinces[0] = "Select / All"; foreach ($provinces as $Province) { $selectProvinces[$Province->slug] = $Province->name; } \View::share('selectProvinces', $selectProvinces); } if (\Schema::hasTable('districts')) { $districts = District::all(); $selectDistrict = array(); $selectDistricts[0] = "Select / All"; foreach ($districts as $district) { $selectDistricts[$district->slug] = $district->name; } \View::share('selectDistricts', $selectDistricts); } if (\Schema::hasTable('municipalities')) { $municipalities = Municipality::all(); $selectMunicipalities = array(); $selectMunicipalities[0] = "Select / All"; foreach ($municipalities as $municipality) { $selectMunicipalities[$municipality->slug] = $municipality->name; } \View::share('selectMunicipalities', $selectMunicipalities); } if (\Schema::hasTable('wards')) { $wards = Ward::all(); $selectWards = array(); $selectWards[0] = "Select / All"; foreach ($wards as $ward) { $selectWards[$ward->slug] = $ward->name; } \View::share('selectWards', $selectWards); } if (\Schema::hasTable('categories')) { $categories = Category::all(); $selectCategories = array(); $selectCategories[0] = "Select / All"; foreach ($categories as $category) { $selectCategories[$category->slug] = $category->name; } \View::share('selectCategories', $selectCategories); } if (\Schema::hasTable('sub_categories')) { $subCategories = SubCategory::all(); $selectSubCategories = array(); $selectSubCategories[0] = "Select / All"; foreach ($subCategories as $subCategory) { $selectSubCategories[$subCategory->slug] = $subCategory->name; } \View::share('selectSubCategories', $selectSubCategories); } if (\Schema::hasTable('sub_sub_categories')) { $subSubCategories = SubSubCategory::all(); $selectSubSubCategories = array(); $selectSubSubCategories[0] = "Select / All"; foreach ($subSubCategories as $subSubCategory) { $selectSubSubCategories[$subSubCategory->slug] = $subSubCategory->name; } \View::share('selectSubSubCategories', $selectSubSubCategories); } if (\Schema::hasTable('relationships')) { $relationships = Relationship::all(); $selectRelationships = array(); $selectRelationships[0] = "Select / All"; foreach ($relationships as $relationship) { $selectRelationships[$relationship->id] = $relationship->name; } \View::share('selectRelationships', $selectRelationships); } if (\Schema::hasTable('cases')) { $cases = \DB::table('cases')->join('users', 'cases.reporter', '=', 'users.id')->select(\DB::raw("\n IF(`cases`.`addressbook` = 1,(SELECT CONCAT(`first_name`, ' ', `surname`) FROM `addressbook` WHERE `addressbook`.`id`= `cases`.`reporter`), (SELECT CONCAT(users.`name`, ' ', users.`surname`) FROM `users` WHERE `users`.`id`= `cases`.`reporter`)) as reporterName\n\n "))->get(); $reporters = array(); $reporters[0] = "Select / All"; foreach ($cases as $case) { $reporters[$case->reporterName] = $case->reporterName; } \View::share('selectReporters', $reporters); } View()->composer('master', function ($view) { $view->with('addressBookNumber', addressbook::all()); if (\Auth::check()) { $number = addressbook::where('user', '=', \Auth::user()->id)->get(); $view->with('addressBookNumber', $number); $allUsers = User::where('id', '<>', \Auth::user()->id)->get(); $view->with('loggedInUsers', $allUsers); $noPrivateMessages = Message::where('to', '=', \Auth::user()->id)->where('read', '=', 0)->where('message_type', '=', 0)->get(); $view->with('noPrivateMessages', $noPrivateMessages); $noInboxMessages = Message::where('to', '=', \Auth::user()->id)->where('message_type', '=', 0)->get(); $view->with('noInboxMessages', $noInboxMessages); $noDepartments = Department::all(); $view->with('noDepartments', $noDepartments); $noUsers = User::all(); $view->with('noUsers', $noUsers); $noRoles = UserRole::all(); $view->with('noRoles', $noRoles); $noPositions = Position::all(); $view->with('noPositions', $noPositions); $noRelationships = Relationship::all(); $view->with('noRelationships', $noRelationships); $noProvinces = Province::all(); $view->with('noProvinces', $noProvinces); $noCaseStatuses = CaseStatus::all(); $view->with('noCaseStatuses', $noCaseStatuses); $userRole = UserRole::where('id', '=', \Auth::user()->role)->first(); $view->with('systemRole', $userRole); $noCasesPriorities = CasePriority::all(); $view->with('noCasesPriorities', $noCasesPriorities); } }); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function captureCaseUpdate(CaseRequest $request) { $houseHolderId = $request['hseHolderId']; $userRole = UserRole::where('name', '=', 'House Holder')->first(); if ($houseHolderId < 1) { $user = new User(); $user->role = $userRole->id; $user->name = $request['name']; $user->surname = $request['surname']; $user->cellphone = $request['cellphone']; $user->id_number = $request['id_number']; $user->position = $request['position']; $user->title = $request['title']; $user->house_number = $request['house_number']; $user->email = $request['cellphone'] . "@siyaleader.net"; $user->created_by = \Auth::user()->id; $language = Language::where('slug', '=', $request['language'])->first(); $user->language = $language->id; $province = Province::where('slug', '=', $request['province'])->first(); $user->province = $province->id; $district = District::where('slug', '=', $request['district'])->first(); $user->district = $district->id; $municipality = Municipality::where('slug', '=', $request['municipality'])->first(); $user->municipality = $municipality->id; $ward = Ward::where('slug', '=', $request['ward'])->first(); $user->ward = $ward->id; $user->save(); } $casePriority = CasePriority::where('slug', '=', $request['priority'])->first(); $case = CaseReport::find($request['caseID']); $case->description = $request['description']; $case->priority = $casePriority->id; $case->updated_by = \Auth::user()->id; $case->updated_at = \Carbon\Carbon::now('Africa/Johannesburg')->toDateTimeString(); $case->save(); return 'ok'; }