本文整理汇总了PHP中app\Notification类的典型用法代码示例。如果您正苦于以下问题:PHP Notification类的具体用法?PHP Notification怎么用?PHP Notification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Notification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$notify_report = false;
for ($i = 0; $i < count($request->all()); $i++) {
if ($request->input($i . '.include')) {
$this->validate($request, [$i . '.id' => 'required', $i . '.member.id' => 'required|numeric', $i . '.position_id' => 'required|numeric', $i . '.project_id' => 'required|numeric', $i . '.target_id' => 'required|numeric', $i . '.output' => 'required|numeric', $i . '.date_start' => 'required|date', $i . '.date_end' => 'required|date', $i . '.hours_worked' => 'required|numeric', $i . '.daily_work_hours' => 'required|numeric', $i . '.output_error' => 'required|numeric']);
// check if a report is already created
if (!$notify_report) {
$admin = User::where('role', 'admin')->first();
$report = Report::where('id', $request->input($i . '.report_id'))->first();
// create a notification
$notification = new Notification();
$notification->message = 'updated a ';
$notification->sender_user_id = $request->user()->id;
$notification->receiver_user_id = $admin->id;
$notification->subscriber = 'admin';
$notification->state = 'main.weekly-report';
$notification->event_id = $report->id;
$notification->event_id_type = 'report_id';
$notification->seen = false;
$notification->save();
$notify = DB::table('reports')->join('users', 'users.id', '=', 'reports.user_id')->join('projects', 'projects.id', '=', 'reports.project_id')->join('notifications', 'notifications.event_id', '=', 'reports.id')->select('reports.*', 'users.*', DB::raw('LEFT(users.first_name, 1) as first_letter'), 'projects.*', 'notifications.*')->where('notifications.id', $notification->id)->first();
// foreach ($query as $key => $value) {
// $notify = $value;
// }
event(new ReportSubmittedBroadCast($notify));
$activity_type = ActivityType::where('action', 'update')->first();
$activity = new Activity();
$activity->report_id = $report->id;
$activity->user_id = $request->user()->id;
$activity->activity_type_id = $activity_type->id;
$activity->save();
// report
$create_report = true;
}
$old_performance = Performance::where('id', $request->input($i . '.id'))->first();
// record history of the performance
$performance_history = new PerformanceHistory();
$performance_history->activity_id = $activity->id;
$performance_history->performance_id = $old_performance->id;
$performance_history->report_id = $old_performance->report_id;
$performance_history->member_id = $old_performance->member_id;
$performance_history->position_id = $old_performance->position_id;
$performance_history->department_id = $old_performance->department_id;
$performance_history->project_id = $old_performance->project_id;
$performance_history->target_id = $old_performance->target_id;
$performance_history->date_start = $old_performance->date_start;
$performance_history->date_end = $old_performance->date_end;
$performance_history->daily_work_hours = $old_performance->daily_work_hours;
$performance_history->output = $old_performance->output;
$performance_history->hours_worked = $old_performance->hours_worked;
$performance_history->output_error = $old_performance->output_error;
$performance_history->average_output = $old_performance->average_output;
$performance_history->productivity = $old_performance->productivity;
$performance_history->quality = $old_performance->quality;
$performance_history->quadrant = $old_performance->quadrant;
$performance_history->save();
}
}
}
开发者ID:mcoyevans,项目名称:personiv-productivity-quality-report,代码行数:66,代码来源:PerformanceHistoryController.php
示例2: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$notification = $this->notification->where('slug', $this->argument('notification'))->first();
if (!$notification) {
$this->error('Invalid notification provided.');
return 1;
}
$users = $notification->subscribers;
if (!count($users)) {
$this->error('No subscribers to send to!');
return 1;
}
if (method_exists($this, $notification->slug)) {
$users = $this->{$notification->slug}($users);
}
if ($this->option('pretend')) {
$this->info('Notification ' . $notification->name . ' would be sent to the following subscribers:');
foreach ($users as $user) {
$this->line($user->name . ' <' . $user->email . '>');
}
return 0;
}
foreach ($users as $user) {
Mail::queue('emails.notifications.' . $notification->template, ['user' => $user], function ($message) use($user, $notification) {
$message->to($user->email, $user->name);
$message->subject($notification->subject);
});
$this->info('Queued notification for ' . $user->name . ' <' . $user->email . '>');
}
return 0;
}
示例3: __construct
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($topic_uuid, $topics_uid, TopicReply $data)
{
$notification = new Notification();
$this->count = $notification->countNotification($topics_uid);
$this->author = $topics_uid;
$this->topic = $topic_uuid;
$this->data = $data;
}
示例4: addNtf
public function addNtf()
{
$notification = new Notification();
$notification->message = 'test';
$notification->cron = '* * * * * *';
$notification->receiver_id = 1;
$notification->save();
return "added";
}
示例5: sentMessageNotification
public function sentMessageNotification($user)
{
$sender = User::findOrFail(Auth::user()->id);
$notification = new Notification();
$notification->user_id = $user->id;
$notification->title = 'You have a new message!!';
$notification->body = $sender->name . ' has sent you a private message! Go to your inbox to reply now!';
$notification->save();
}
示例6: handle
/**
* Handle the event.
*
* @param BadgeWasEarned $event
* @return void
*/
public function handle(BadgeWasEarned $event)
{
$user = $event->user;
$notification = new Notification();
$notification->type = "Badge";
$notification->is_read = false;
$notification->user_id = $user->id;
$notification->save();
}
示例7: addConnectionNotification
public function addConnectionNotification($friend)
{
$sender = User::findOrFail(Auth::user()->id);
$notification = new Notification();
$notification->user_id = $friend->id;
$notification->title = 'Someone has added you as their connection!';
$notification->body = $sender->name . ' added you to their connection list, add them back to interact with them if you have not done so already!';
$notification->save();
}
示例8: __construct
/**
* Create a new event instance.
*
* @return void
*
* $flg -> increment or decrement
*/
public function __construct($notify_user, $topics_uuid, $is_upvote)
{
$this->user = $notify_user;
$notification = new Notification();
$this->count = $notification->countNotification($notify_user);
$this->is_upvote = $is_upvote;
//Get the most upvote count*/
$tp = new Topic();
$this->upv_cnt = $tp->upvoteTopic($topics_uuid, $is_upvote);
$this->topic = $topics_uuid;
}
示例9: testNotificationDelete
public function testNotificationDelete()
{
$admin = User::find(1);
$notification = new Notification();
$notification->title = "Test title 123";
$notification->type = "Alarm test";
$notification->notes = "Test property ";
$notification->data = "Test data ";
$notification->save();
$savedNotification = Notification::where('title', '=', 'Test title 123')->first();
$this->actingAs($admin)->withSession(['foo' => 'bar'])->visit($this->modelUrl . (string) $savedNotification->id)->press('Delete')->seePageIs($this->modelUrl);
}
示例10: 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');
}
示例11: handle
/**
* Handle the event.
*
* @param ShameWasUpdated $event
* @return void
*/
public function handle(ShameWasUpdated $event)
{
$shame = $event->shame;
$users = $shame->follows;
foreach ($users as $user) {
$notification = new Notification();
$notification->type = "Shame";
$notification->is_read = false;
$notification->user_id = $user->id;
$notification->shame_id = $shame->id;
$notification->save();
}
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
$notification = new Notification();
if (Request::has('text') && Request::input('text') != "") {
$notification->text = Request::input('text');
$notification->save();
return Response::make("Success", 201);
} else {
// Bad request, missing parameters
return Response::make("Please provide a notification.", 400);
}
}
示例13: handle
/**
* Handle the event.
*
* @param CommentWasAdded $event
* @return void
*/
public function handle(CommentWasAdded $event)
{
$comment = $event->comment;
$shame = $comment->shame;
$users = $shame->follows;
foreach ($users as $user) {
$notification = new Notification();
$notification->type = "Comment";
$notification->is_read = false;
$notification->user_id = $user->id;
$notification->shame_id = $shame->id;
$notification->comment_id = $comment->id;
$notification->save();
}
}
示例14: 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');
}
示例15: saveNotification
public function saveNotification($data)
{
$notify = new Notification();
$notification_responce_time = '30';
$time = date('Y-m-d H:i:s');
$newtime = strtotime("{$time} + {$notification_responce_time} seconds");
$expire = date('Y-m-d H:i:s', $newtime);
$notify->sender_id = $data['sender_id'];
$notify->reciver_id = $data['reciver_id'];
$notify->message = $data['message'];
$notify->type = $data['type'];
$notify->expired_at = $expire;
$notify->save();
return $notify;
}