Ignore:
Timestamp:
02/24/21 21:58:42 (4 years ago)
Author:
Berat Kjufliju <kufliju@…>
Branches:
master
Children:
ff9da8b
Parents:
0c07a90
Message:

ADD technoweek offer, companies

Location:
app/Http/Controllers/Dashboard
Files:
1 added
2 edited

Legend:

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

    r0c07a90 rf457265  
    3636            "allPosts" => Post::count(),
    3737            "currentUserPosts" => Post::where("user_id", auth()->user()->id)->count(),
    38             "users" => User::count(),
     38            "users" => !is_null(auth()->user()->company) ? auth()->user()->company->users->count() : User::count(),
    3939            "total_comments" => Comment::count(),
    4040            "comments" => auth()->user()->comments->count()
  • app/Http/Controllers/Dashboard/UsersController.php

    r0c07a90 rf457265  
    55use App\Helpers\Alert;
    66use App\Http\Requests\Dashboard\NewUserRequest;
     7use App\Models\Company;
    78use App\Models\Role;
    89use App\Models\User;
     
    4748            $user->verify_token = $user->generateVerifyToken();
    4849
    49             $user->role_id = $request->userRole;
     50            if ($request->has("company_id") || !is_null(auth()->user()->company_id)) {
     51                $user->company_id = $request->has("company_id") || auth()->user()->company_id;
     52                $user->role_id = 1;
     53            } else {
     54                $user->role_id = $request->userRole;
     55            }
    5056
    5157            $user->save();
    5258
    53             $user->userProfile()->create([
     59            $userProfile = [
    5460                "profile_link" => $user->generateProfileLink($request->name, $request->surname),
    5561                "technoblog_email" => $user->generateTechnoblogEmail($request->name, $request->surname)
    56             ]);
     62            ];
     63
     64            if ($request->has("company_owner")) {
     65                $userProfile["is_company_profile"] = true;
     66            }
     67
     68            $user->userProfile()->create($userProfile);
    5769
    5870            $user->notify(new WelcomeUser($user));
    5971
    6072            Alert::flash("New user added successfully");
    61 
    6273        });
    6374
Note: See TracChangeset for help on using the changeset viewer.