/** * Handle the event. * * @param PostWasCreatedEvent $event * @return void */ public function handle(PostWasCreatedEvent $event) { $post = Post::find($event->post->id); $title = $post->title; $link = App::getLocale() . '/blog/post/' . $post->id; $user = User::find($event->user->id); $username = $user->name; $this->mailer->compose($user->email, $username, $title, $link)->send(); }
/** * @param QuizWasCreated $event */ public function handle(QuizWasCreated $event) { $quiz = Quiz::find($event->quiz->id); $title = $quiz->name; $link = App::getLocale() . '/quiz/' . $quiz->id; $user = User::find($event->user->id); $username = $user->name; $this->mailer->compose($user->email, $username, $title, $link)->send(); }
public function chooser(Request $request) { $select = $request->input('locale'); $user = User::find(Auth::id()); if ($user) { $user->update(['locale' => $select]); } $url = $request->url; $replacedUrl = str_replace(\Lang::getLocale(), $select, $url); return redirect()->to($replacedUrl)->withCookie(cookie('locale', $select, 525600)); }
public function userPhoto(UserPhotoRequest $request) { $user = User::find($request->user()->id); if (\Input::hasFile('photo')) { // upload image $image = \Input::file('photo'); $imagesPath = 'images/users'; $this->uploader->upload($image, $imagesPath)->save($imagesPath); if ($user->picture()) { $picture = $user->picture()->get(); foreach ($picture as $pic) { User::deleteImage($pic->path); } $user->picture()->detach(); } $picture = Picture::create(['path' => $this->uploader->getFilename()]); $user->picture()->attach($picture); } Toastr::info(trans('messages.yourPhotoUpdated'), $title = $user->name, $options = []); return redirect()->back(); }
/** * Handle the event. * * @param UserWasCreatedEvent $event * @return void */ public function handle(UserWasCreatedEvent $event) { $user = User::find($event->user->id); $this->mailer->compose($user->email, $user->name)->send(); }
public function getMessage() { try { $thread = Thread::findOrFail(Input::get('conversation')); } catch (ModelNotFoundException $e) { Session::flash('error_message', 'The thread with ID: ' . Input::get('conversation') . ' was not found.'); return redirect(App::getLocale() . '/messages'); } $thread->activateAllParticipants(); $user = User::find(Input::get('user_id')); $message = Message::where('user_id', $user->id)->where('thread_id', $thread->id)->get()->last(); $thread->markAsRead(Auth::user()->id); return view('messages.message', compact('thread', 'message')); }
public function banORunBan($id) { try { $username = User::find($id)->name; if ('' . \Auth::user()->id === $id) { Toastr::error('Can\'t be banned!', $title = $username, $options = []); return redirect()->back(); } else { $this->userRepository->banORunBan($id); } return redirect()->back(); } catch (ModelNotFoundException $e) { return $this->redirectNotFound(); } }