Changeset f457265 for app/Http/Controllers
- Timestamp:
- 02/24/21 21:58:42 (4 years ago)
- Branches:
- master
- Children:
- ff9da8b
- Parents:
- 0c07a90
- Location:
- app/Http/Controllers
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Blog/BlogController.php
r0c07a90 rf457265 4 4 5 5 use App\Http\Requests\Blog\CommentRequest; 6 use App\Http\Requests\Blog\CompanyRequest; 6 7 use App\Http\Requests\Blog\PostLikeRequest; 7 8 use App\Http\Requests\Blog\PostUnlikeRequest; 9 use App\Models\Company; 8 10 use App\Models\Tag; 9 11 use App\Models\Like; … … 15 17 use App\Http\Controllers\Controller; 16 18 use App\Notifications\NewCommentAdded; 19 use Illuminate\Support\Facades\DB; 17 20 18 21 class BlogController extends Controller … … 226 229 ]); 227 230 } 231 232 public function storeCompany(CompanyRequest $request) 233 { 234 DB::transaction(function () use ($request) { 235 236 $company = new Company(); 237 $company->name = $request->name; 238 $company->website = $request->website; 239 $company->email = $request->email; 240 241 $company->save(); 242 243 if ($company->wasRecentlyCreated) { 244 $this->disableOfferModal(); 245 } 246 }); 247 248 return redirect()->route("blog.index"); 249 } 250 251 public function disableOffer() 252 { 253 $this->disableOfferModal(); 254 return redirect()->route("blog.index"); 255 } 256 257 private function disableOfferModal() 258 { 259 if (!session()->has("offer_disabled")) { 260 session()->push("offer_disabled", true); 261 } 262 } 228 263 } -
app/Http/Controllers/Dashboard/IndexController.php
r0c07a90 rf457265 36 36 "allPosts" => Post::count(), 37 37 "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(), 39 39 "total_comments" => Comment::count(), 40 40 "comments" => auth()->user()->comments->count() -
app/Http/Controllers/Dashboard/UsersController.php
r0c07a90 rf457265 5 5 use App\Helpers\Alert; 6 6 use App\Http\Requests\Dashboard\NewUserRequest; 7 use App\Models\Company; 7 8 use App\Models\Role; 8 9 use App\Models\User; … … 47 48 $user->verify_token = $user->generateVerifyToken(); 48 49 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 } 50 56 51 57 $user->save(); 52 58 53 $user ->userProfile()->create([59 $userProfile = [ 54 60 "profile_link" => $user->generateProfileLink($request->name, $request->surname), 55 61 "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); 57 69 58 70 $user->notify(new WelcomeUser($user)); 59 71 60 72 Alert::flash("New user added successfully"); 61 62 73 }); 63 74
Note:
See TracChangeset
for help on using the changeset viewer.