Ignore:
Timestamp:
02/24/21 17:04:35 (4 years ago)
Author:
Özkan İliyaz <iliyaz_96@…>
Branches:
master
Children:
0c07a90
Parents:
1f059b0
Message:

ADD post confirmation with multiple phases, notification after succesfully password creation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • app/Http/Controllers/Dashboard/SettingsController.php

    r1f059b0 rd25ba66  
    66use App\Http\Requests\Dashboard\EmailSettingsRequest;
    77use App\Http\Requests\Dashboard\PasswordSettingsRequest;
     8use App\Http\Requests\Dashboard\PhaseRequest;
    89use App\Http\Requests\Dashboard\PhotosSettingsRequest;
     10use App\Http\Requests\Dashboard\PostSecurityRequest;
    911use App\Http\Requests\Dashboard\SocialLinksSettingsRequest;
    1012use App\Http\Requests\Dashboard\UsernameSettingsRequest;
    1113use App\Http\Requests\Dashboard\UserProfileSettingsRequest;
     14use App\Models\Phase;
    1215use App\Models\Post;
     16use App\Models\PostSecurity;
     17use App\Models\Role;
    1318use App\Models\User;
    1419use App\Models\UserProfile;
     
    3035            "userProfile" => auth()->user()->userProfile,
    3136            "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()
    3341        ]);
    3442    }
     
    179187    }
    180188
     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
    181251    private function updatePhotosHelper(Request $request, UserProfile $userProfile)
    182252    {
Note: See TracChangeset for help on using the changeset viewer.