当前位置: 首页>>代码示例>>PHP>>正文


PHP Notification::from方法代码示例

本文整理汇总了PHP中app\Notification::from方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::from方法的具体用法?PHP Notification::from怎么用?PHP Notification::from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Notification的用法示例。


在下文中一共展示了Notification::from方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['body' => 'required|min:5']);
     if ($request->user()->muted) {
         return \Redirect::back()->with('error', 'You are muted.');
     }
     $status = ['body' => $request->body];
     $st = $this->status->publish($status);
     // Create notification with Stream
     $not = new Notification();
     $not->from($request->user())->withType('UserStatusUpdate')->withSubject('A status is posted')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " published a post in his feedline " . link_to_route('show-status', "#" . $st->id, $st->id))->withStream(true)->regarding($st)->deliver();
     return \Redirect::back()->with('message', 'Status updated successfully');
 }
开发者ID:kinnngg,项目名称:knightofsorrow,代码行数:19,代码来源:StatusController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param NewsRequest $request
  * @return Response
  */
 public function store(NewsRequest $request)
 {
     $slug = str_limit(str_slug($request->title), 50) . "--author-{$request->user()->username}";
     /*$news  = News::where('summary',$slug)->first();
     
             if($news)
             {
                 $slug = str_limit(str_slug($request->title),50)."-".time()."--author-{$request->user()->username}";
             }*/
     $news = $request->user()->news()->create(['title' => $request->title, 'text' => $request->text, 'summary' => $slug, 'is_published' => true, 'news_type' => $request->news_type]);
     // Create notification
     $not = new Notification();
     $not->from($request->user())->withType('NewsCreated')->withSubject('A news is created')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " has created a news " . link_to_route('news.show', str_limit($news->title, 100), $news->summary))->withStream(true)->regarding($news)->deliver();
     return redirect()->route('news.show', $news->summary)->with('message', 'News Created');
 }
开发者ID:kinnngg,项目名称:knightofsorrow,代码行数:21,代码来源:NewsController.php

示例3: storeForTournament

 public function storeForTournament($id, Request $request)
 {
     $t = KTournament::findOrFail($id);
     $comment = \Input::get('body');
     if ($comment == '') {
         return \Redirect::back();
     }
     if ($request->user()->muted) {
         return \Redirect::back()->with('error', 'You are muted.');
     }
     $t->comments()->create(['body' => $comment, 'user_id' => Auth::user()->id]);
     // Create notification
     $not = new Notification();
     $not->from($request->user())->withType('UserCommentOnTournament')->withSubject('A comment is done on tournament')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " has commented on " . link_to_route('tournament.show', $t->name, $t->slug) . " tournament")->withStream(true)->regarding($t)->deliver();
     return \Redirect::back()->with('success', 'Success!');
 }
开发者ID:kinnngg,项目名称:knightofsorrow,代码行数:16,代码来源:CommentController.php

示例4: changeRole

 /**
  * Change role of user
  *
  * @param Request $request
  * @param $username
  * @return \Illuminate\Http\RedirectResponse
  */
 public function changeRole(Request $request, $username)
 {
     if (!$request->user()->isAdmin()) {
         return \Redirect::back()->with('error', "Aw! You are not any Admin ;)");
     }
     if ($request->username != $username) {
         return \Redirect::back()->with('error', "Aw! Please don't try to mess up the code ;)");
     }
     $user = User::findOrFail($request->user_id);
     if ($request->username != $user->username) {
         return \Redirect::back()->with('error', "Aw! Please don't try to mess up the code ;)");
     }
     if ($request->job == 'promote') {
         // If User role is equal to the one other person role - 1
         // If user admin 3 other also admin 3
         // 3 >= 4 -> True
         if ($request->user()->roles()->first()->id >= $user->roles()->first()->id - 1) {
             return \Redirect::back()->with('error', "Sorry! Not enough permissions");
         }
         // Cannot promote if already a SA
         if ($user->roles()->first()->id <= 2) {
             return \Redirect::back()->with('error', "Sorry! No more higher rank.");
         }
         $role = $user->roles()->first();
         $prevRoleID = $role->id;
         $nextRoleID = $prevRoleID - 1;
         $user->detachRole($role);
         $user->attachRole($nextRoleID);
         $nextrank = Role::find($nextRoleID);
         // Create notification
         $not = new Notification();
         $not->from($request->user())->withType('UserRolePromote')->withSubject('A User has promoted.')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " has <span class='text-green notify-bold'>promoted</span> " . link_to_route('user.show', $user->displayName(), $user->username) . " to " . $nextrank->display_name)->withStream(true)->regarding($user)->deliver();
         return \Redirect::back()->with('message', "User promoted!");
     } elseif ($request->job == 'demote') {
         if ($request->user()->roles()->first()->id >= $user->roles()->first()->id) {
             return \Redirect::back()->with('error', "Sorry! Not enough permissions");
         }
         // Cannot demote if already a member
         if ($user->roles()->first()->id >= 5) {
             return \Redirect::back()->with('error', "Sorry! No more lower rank.");
         }
         $role = $user->roles()->first();
         $prevRoleID = $role->id;
         $nextRoleID = $prevRoleID + 1;
         $user->detachRole($role);
         $user->attachRole($nextRoleID);
         $nextrank = Role::find($nextRoleID);
         // Create notification
         $not = new Notification();
         $not->from($request->user())->withType('UserRoleDemote')->withSubject('A User has demoted.')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " has <span class='text-danger notify-bold'>demoted</span> " . link_to_route('user.show', $user->displayName(), $user->username) . " to " . $nextrank->display_name)->withStream(true)->regarding($user)->deliver();
         return \Redirect::back()->with('message', "User demoted!");
     } else {
         return \Redirect::back()->with('error', "Whoops! Unknown error");
     }
 }
开发者ID:kinnngg,项目名称:knightofsorrow,代码行数:62,代码来源:UserController.php

示例5: postCalculateMatchFinal


//.........这里部分代码省略.........
     $team2->total_score += $team2_total_score;
     //If winner is team 1
     if ($request->overall_winner_id == $team1->id) {
         $team1->total_wins += 1;
         $team2->total_lost += 1;
         $team1->points += 2;
         $team2->points -= 2;
     } elseif ($request->overall_winner_id == $team2->id) {
         $team2->total_wins += 1;
         $team1->total_lost += 1;
         $team2->points += 2;
         $team1->points -= 2;
     } elseif ($request->overall_winner_id == "0") {
         $team2->total_tie += 1;
         $team1->total_tie += 1;
         $team1->points += 1;
         $team2->points += 1;
     } else {
     }
     //SAVE TEAMS
     $team1->save();
     $team2->save();
     //SAVE INDI PLAYER STATS
     if ($tournament->tournament_type == 0) {
         $team1_p1 = $match->team1->playerselected->first();
         $team1_p2 = $match->team1->playerselected->last();
         $team2_p1 = $match->team2->playerselected->first();
         $team2_p2 = $match->team2->playerselected->last();
         $match->team1->givescoretouser($team1_p1, $team1_p1_score_sum);
         $match->team1->givescoretouser($team1_p2, $team1_p2_score_sum);
         $match->team2->givescoretouser($team2_p1, $team2_p1_score_sum);
         $match->team2->givescoretouser($team2_p2, $team2_p2_score_sum);
     } else {
         if ($tournament->tournament_type == 2) {
             $i = 1;
             foreach ($match->team1->playerselected as $player) {
                 //${'team1_p'.$i} = $player;
                 $match->team1->givescoretouser($player, ${'team1_p' . $i . '_score_sum'});
                 $i++;
             }
             $y = 1;
             foreach ($match->team2->playerselected as $player) {
                 //${'team2_p'.$i} = $player;
                 $match->team2->givescoretouser($player, ${'team2_p' . $y . '_score_sum'});
                 $y++;
             }
         }
     }
     //@TODO: Add else here for 1v1
     //FOR DE/SE ONLY
     //Check all match id (TBA) and change to team id as per match schedule
     if ($tournament->bracket_type > 0) {
         // Check for all matches with has this match index for team 1...
         $team1_from_match_indexes = KMatch::where('team1_from_match_index', $match->match_index)->get();
         foreach ($team1_from_match_indexes as $team1_from_match_index) {
             if ($team1_from_match_index->team1_from_match_rank == 1) {
                 $team1_from_match_index->k_team1_id = $match->winner_team_id;
                 $team1_from_match_index->save();
             } elseif ($team1_from_match_index->team1_from_match_rank == 2) {
                 $team1_from_match_index->k_team1_id = $team1->id == $match->winner_team_id ? $team2->id : $team1->id;
                 $team1_from_match_index->save();
             }
         }
         // Check for all matches with has this match index for team 2...
         $team2_from_match_indexes = KMatch::where('team2_from_match_index', $match->match_index)->get();
         foreach ($team2_from_match_indexes as $team2_from_match_index) {
             if ($team2_from_match_index->team2_from_match_rank == 1) {
                 $team2_from_match_index->k_team2_id = $match->winner_team_id;
                 $team2_from_match_index->save();
             } elseif ($team2_from_match_index->team2_from_match_rank == 2) {
                 $team2_from_match_index->k_team2_id = $team1->id == $match->winner_team_id ? $team2->id : $team1->id;
                 $team2_from_match_index->save();
             }
         }
     }
     //Dispatch Notifications
     //If match is cancelled
     if ($request->winner_team_id == "-1") {
         // Create notification with Stream
         $not = new Notification();
         $not->from($request->user())->withType('TournamentMatchCancelled')->withSubject('Match is cancelled in a tournament')->withBody(link_to_route('tournament.show', $tournament->name, $tournament->slug) . " : Match between " . link_to_route('tournament.team.show', $match->team1->name, [$tournament->slug, $match->team1->id]) . " and " . link_to_route('tournament.team.show', $match->team2->name, [$tournament->slug, $match->team2->id]) . " was <span class='text-danger notify-bold'>cancelled</span>")->withStream(true)->regarding($tournament)->deliver();
     } else {
         if ($request->winner_team_id == "0") {
             $not = new Notification();
             $not->from($request->user())->withType('TournamentMatchTie')->withSubject('Match is tie in a tournament')->withBody(link_to_route('tournament.show', $tournament->name, $tournament->slug) . " : Match between " . link_to_route('tournament.team.show', $match->team1->name, [$tournament->slug, $match->team1->id]) . " and " . link_to_route('tournament.team.show', $match->team2->name, [$tournament->slug, $match->team2->id]) . " <span class='text-danger notify-bold'>tied</span> by " . $request->winner_team_won_by)->withStream(true)->regarding($tournament)->deliver();
         } else {
             $not = new Notification();
             $not->from($request->user())->withType('TournamentMatchPlayed')->withSubject('Match is played in a tournament')->withBody(link_to_route('tournament.show', $tournament->name, $tournament->slug) . " : " . $match->getWinningTextForNotifications())->withStream(true)->regarding($tournament)->deliver();
         }
     }
     //RANK THE TEAMS
     //@TODO: Its TEMP CHANGE IT
     $teams = KTeam::where('team_status', 1)->orderBy('points', 'desc')->orderBy('total_wins', 'desc')->orderBy('total_lost', 'asc')->orderBy('total_tie', 'desc')->orderBy('total_score', 'desc')->get();
     $i = 0;
     foreach ($teams as $team) {
         $team->team_position = ++$i;
         $team->save();
     }
     return redirect()->route('tournament.show', [$tournament->slug])->with('message', "Success! Match data has been recorded.");
 }
开发者ID:kinnngg,项目名称:knightofsorrow,代码行数:101,代码来源:TManagerController.php

示例6: notifyAll

 public function notifyAll($user)
 {
     $not = new Notification();
     $not->from($user)->withType('UserRegistered')->withSubject('A new user registration')->withBody("A new user registered : " . link_to_route('user.show', $user->displayName(), [$user->username]))->withStream(true)->regarding($user)->deliver();
 }
开发者ID:kinnngg,项目名称:knightofsorrow,代码行数:5,代码来源:UserRegisterListener.php

示例7: handleTeamsForManager

 /**
  * @param $slug
  * @param $id
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function handleTeamsForManager($slug, $id, Request $request)
 {
     if ($request->team_id != $id) {
         return redirect()->home();
     }
     if (!($request->action_id == 0 || $request->action_id == 1 || $request->action_id == 2 || $request->action_id == 3)) {
         return redirect()->back()->with('error', 'Error! Invalid action');
     }
     $tournament = KTournament::whereSlug($slug)->firstOrFail();
     $team = KTeam::findOrFail($request->team_id);
     // Only if team belongs to this tour
     if ($team->k_tournament_id != $tournament->id) {
         return redirect()->home();
     }
     // Tournament has not begun or has ended or disabled then return
     if ($tournament->isRegistrationOpen() == 6 || $tournament->isRegistrationOpen() == 5 || $tournament->isRegistrationOpen() == 4) {
         return redirect()->back()->with('error', 'Error! Cannot modify team now.');
     }
     // Only if user has enough power
     if (!$request->user()->canManageTournament($tournament)) {
         return redirect()->back()->with('error', 'Error! Not Authorised');
     }
     // If Tournament is full
     if ($request->action_id == 1 && $tournament->isFullParticipants()) {
         return redirect()->back()->with('error', 'Error! Tournament already have maximum qualified participants.');
     }
     $old_action_id = $team->team_status;
     $team->team_status = $request->action_id;
     $team->save();
     // Stream Notifications.
     // Approved
     if ($request->action_id == 1 && $request->action_id != $old_action_id) {
         $not = new Notification();
         $not->from($request->user())->withType('TeamRequestApproved')->withSubject('Team has approved to join tournament')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " has <span class='text-green notify-bold'>approved</span> team " . link_to_route('tournament.team.show', $team->name, [$tournament->slug, $team->id]) . " request to join " . link_to_route('tournament.show', $tournament->name, $tournament->slug))->withStream(true)->regarding($team)->deliver();
     } elseif ($request->action_id == 2 && $request->action_id != $old_action_id) {
         $not = new Notification();
         $not->from($request->user())->withType('TeamRequestDisqualified')->withSubject('Team has set to disqualified to join tournament')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " has <span class='text-danger notify-bold'>disqualified</span> team " . link_to_route('tournament.team.show', $team->name, [$tournament->slug, $team->id]) . " from " . link_to_route('tournament.show', $tournament->name, $tournament->slug))->withStream(true)->regarding($team)->deliver();
     } elseif ($request->action_id == 3 && $request->action_id != $old_action_id) {
         $not = new Notification();
         $not->from($request->user())->withType('TeamRequestNoteligible')->withSubject('Team has set not eligible to join tournament')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " has changed team " . link_to_route('tournament.team.show', $team->name, [$tournament->slug, $team->id]) . " status to <span class='text-danger notify-bold'>not eligible</span> in " . link_to_route('tournament.show', $tournament->name, $tournament->slug))->withStream(true)->regarding($team)->deliver();
     } elseif ($request->action_id == 0 && $request->action_id != $old_action_id) {
         $not = new Notification();
         $not->from($request->user())->withType('TeamRequestPending')->withSubject('Team has set pending to join tournament')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " has changed team " . link_to_route('tournament.team.show', $team->name, [$tournament->slug, $team->id]) . " status to <span class='text-warning notify-bold'>pending</span> in " . link_to_route('tournament.show', $tournament->name, $tournament->slug))->withStream(true)->regarding($team)->deliver();
     }
     return redirect()->back()->with('message', 'Success! Team status changed');
 }
开发者ID:kinnngg,项目名称:knightofsorrow,代码行数:52,代码来源:TournamentController.php

示例8: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @param InputRequest $request
  * @return Response
  */
 public function update($id, InputRequest $request)
 {
     if (!$request->user()->isAdmin()) {
         return redirect()->home()->with('error', "Not authorized");
     }
     $validator = \Validator::make($request->all(), ['status' => 'required|in:0,1']);
     if ($validator->fails()) {
         return \Redirect::back()->with('errors', $validator->errors())->withInput();
     }
     $ban = Ban::findOrFail($id);
     $prev_status = $ban->status;
     $status = $request->status;
     $reason = $request->reason == "" ? null : $request->reason;
     $banned_till = $request->banned_till;
     $banned_till = $banned_till == "" ? null : Carbon::parse($banned_till);
     // If its a unban work then banned till will be set to now.
     if ($status == 0 && $prev_status == 1) {
         $banned_till = Carbon::now();
     } else {
         if ($status == 1 && $prev_status == 0 && $banned_till != null && $banned_till <= Carbon::now()) {
             $banned_till = null;
         } else {
             if ($status == 0 && $prev_status == 0) {
                 if ($banned_till >= Carbon::now()) {
                     return redirect()->back()->with('error', 'Ban Till cannot me in future if status is "Unbanned".')->withInput();
                 } else {
                     if ($banned_till == "" || $banned_till == null) {
                         $banned_till = $ban->banned_till;
                     }
                 }
             }
         }
     }
     $ban->reason = $reason;
     $ban->status = $status;
     $ban->banned_till = $banned_till;
     $ban->updated_by = $request->user()->username;
     $ban->updated_by_site = true;
     $ban->save();
     // Create notification
     $not = new Notification();
     $not->from($request->user())->withType('BanUpdated')->withSubject('A ban is updated')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " has updated the ban " . link_to_route('bans.show', '#' . $ban->id, $ban->id) . " with IP <b>" . $ban->ipAddrWithMask() . "</b> <img src='" . $ban->countryImage() . "' class='tooltipster img' title='" . $ban->countryName() . "'>")->withStream(true)->regarding($ban)->deliver();
     if ($status == 0 && $prev_status == 1) {
         $ban->tellServerToRemove();
     } else {
         if ($status == 1 && $prev_status == 0) {
             $ban->tellServerToAdd();
         }
     }
     return redirect()->route('bans.show', $ban->id)->with('success', 'Ban has need updated!');
 }
开发者ID:kinnngg,项目名称:knightofsorrow,代码行数:58,代码来源:BanController.php


注:本文中的app\Notification::from方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。