Changeset d25ba66 for app/Http/Controllers/Dashboard/SettingsController.php
- Timestamp:
- 02/24/21 17:04:35 (4 years ago)
- Branches:
- master
- Children:
- 0c07a90
- Parents:
- 1f059b0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Dashboard/SettingsController.php
r1f059b0 rd25ba66 6 6 use App\Http\Requests\Dashboard\EmailSettingsRequest; 7 7 use App\Http\Requests\Dashboard\PasswordSettingsRequest; 8 use App\Http\Requests\Dashboard\PhaseRequest; 8 9 use App\Http\Requests\Dashboard\PhotosSettingsRequest; 10 use App\Http\Requests\Dashboard\PostSecurityRequest; 9 11 use App\Http\Requests\Dashboard\SocialLinksSettingsRequest; 10 12 use App\Http\Requests\Dashboard\UsernameSettingsRequest; 11 13 use App\Http\Requests\Dashboard\UserProfileSettingsRequest; 14 use App\Models\Phase; 12 15 use App\Models\Post; 16 use App\Models\PostSecurity; 17 use App\Models\Role; 13 18 use App\Models\User; 14 19 use App\Models\UserProfile; … … 30 35 "userProfile" => auth()->user()->userProfile, 31 36 "countries" => Country::all(), 32 "adminAndEditors" => User::where("role_id", 1)->orWhere("role_id", 2)->get() 37 "adminAndEditors" => User::where("role_id", 1)->orWhere("role_id", 2)->get(), 38 "userRoles" => Role::all(), 39 "phases" => Phase::all(), 40 "postSecurities" => PostSecurity::all() 33 41 ]); 34 42 } … … 179 187 } 180 188 189 public function phaseStore(PhaseRequest $request) 190 { 191 if ($request->has("phase_id") && !is_null($request->phase_id)) { 192 $phase = Phase::findOrFail($request->phase_id); 193 } else { 194 $phase = new Phase(); 195 } 196 197 $phase->name = $request->name; 198 $phase->reviewer()->associate(Role::find($request->reviewer_role_id)); 199 $phase->user()->associate(auth()->user()); 200 $phase->save(); 201 202 if ($request->has("phase_id") && !is_null($request->phase_id)) { 203 Alert::flash($phase->name . " updated successfully"); 204 } else { 205 Alert::flash($phase->name . " created successfully"); 206 } 207 208 return redirect()->route("dashboard.settings.index"); 209 } 210 211 public function phaseDestroy($id) 212 { 213 $phase = Phase::findOrFail($id); 214 $phaseName = $phase->name; 215 $phase->delete(); 216 217 Alert::flash($phaseName . " deleted successfully"); 218 219 return redirect()->route("dashboard.settings.index"); 220 } 221 222 public function postSecurityStore(PostSecurityRequest $request) 223 { 224 if ($request->has("post_security_id") && !is_null($request->post_security_id)) { 225 $postSecurity = PostSecurity::findOrFail($request->post_security_id); 226 } else { 227 $postSecurity = new PostSecurity(); 228 } 229 230 $postSecurity->role()->associate(Role::find($request->role_id_to_be_reviewed)); 231 $postSecurity->phase_ids = $request->phase_ids; 232 233 $postSecurity->save(); 234 235 if ($request->has("post_security_id") && !is_null($request->post_security_id)) { 236 Alert::flash("Post security updated successfully"); 237 } else { 238 Alert::flash("Post security created successfully"); 239 } 240 241 return redirect()->route("dashboard.settings.index"); 242 } 243 244 public function postSecurityDestroy($id) 245 { 246 PostSecurity::findOrFail($id)->delete(); 247 Alert::flash("Post security deleted successfully"); 248 return redirect()->route("dashboard.settings.index"); 249 } 250 181 251 private function updatePhotosHelper(Request $request, UserProfile $userProfile) 182 252 {
Note:
See TracChangeset
for help on using the changeset viewer.