本文整理汇总了PHP中app\Notification::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::where方法的具体用法?PHP Notification::where怎么用?PHP Notification::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Notification
的用法示例。
在下文中一共展示了Notification::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: index
public function index()
{
$logged_user_id = Auth::user()->id;
$users = User::find($logged_user_id);
$notification = Notification::where('user_id', $logged_user_id)->orderBy('created_at', 'desc')->paginate(5);
return View::make('notification')->with('users', $users)->with('notification', $notification);
}
示例3: notifications
public function notifications(View $view)
{
//Fetch all notifications for this user alone
$notifications = Notification::where('user_id', auth()->user()->id)->paginate(3);
$data = ['notifications' => $notifications];
$view->with($data);
}
示例4: notification
/**
* @return \Illuminate\View\View
*/
public function notification()
{
//Fetch all notifications for this user alone
$notifications = Notification::where('user_id', auth()->user()->id)->paginate(10);
$data = ['notifications' => $notifications];
return view('frontend.user.notification', $data);
}
示例5: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$notifications = Notification::where('user_id', Auth::user()->id)->orderBy('id', 'desc')->paginate(10);
$toUpdate = Notification::where('user_id', Auth::user()->id)->where('new', 1)->get();
foreach ($toUpdate as $n) {
$n->new = 0;
$n->save();
}
return view('notifications.index', compact('notifications'));
}
示例6: 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);
}
示例7: read
public static function read($user_id, $unread = true, int $limit = 500, $paginate = false)
{
if ($unread === true) {
$notifications = Notification::where('user_id', $user_id)->where('is_read', 0)->orderBy('id', 'desc');
} else {
$notifications = Notification::where('user_id', $user_id)->orderBy('id', 'desc');
}
if (is_numeric($paginate) && $paginate > 0) {
$notifications = $notifications->paginate($paginate);
} else {
$notifications = $notifications->limit($limit)->get();
}
return $notifications;
}
示例8: compose
public function compose(View $view)
{
$array_task = [];
$array_alert = [];
$array_notification = [];
$tasks_count = 0;
$alerts_count = 0;
$notifications_count = 0;
//menus
$packages = Package::with('modules')->get();
//datas of the user logged
$userAuth = Sentinel::getUser();
$today = Carbon::now();
// tareas
$tasks = Task::where('user_id', '=', $userAuth->id)->orwhere('role_id', '=', $userAuth->roles[0]->id)->orderBy('created_at', 'DESC')->get();
foreach ($tasks as $task) {
if (is_null($task->read)) {
array_push($array_task, $task);
$tasks_count++;
} elseif (!in_array($userAuth->id, unserialize($task->read))) {
array_push($array_task, $task);
$tasks_count++;
}
}
// alertas
$alerts = Task::where('expire_time', '<', $today)->Where(function ($query) use($userAuth) {
$query->where('user_id', '=', $userAuth->id)->orwhere('role_id', '=', $userAuth->roles[0]->id);
})->with('hasAlert')->get();
foreach ($alerts as $alert) {
if (is_null($alert->hasAlert[0]->alert_display)) {
array_push($array_alert, $alert);
$alerts_count++;
} elseif (!in_array($userAuth->id, unserialize($alert->hasAlert[0]->alert_display))) {
array_push($array_alert, $alert);
$alerts_count++;
}
}
// notifications
$notifications = Notification::where('user_id', '=', $userAuth->id)->orwhere('role_id', '=', $userAuth->roles[0]->id)->get();
foreach ($notifications as $notification) {
if (is_null($notification->read)) {
array_push($array_notification, $notification);
$notifications_count++;
} elseif (!in_array($userAuth->id, unserialize($notification->read))) {
array_push($array_notification, $notification);
$notifications_count++;
}
}
$view->with(array('packages' => $packages, 'userAuth' => $userAuth, 'alerts' => $array_alert, 'alerts_count' => $alerts_count, 'notifications' => $array_notification, 'notifications_count' => $notifications_count, 'tasks' => $array_task, 'tasks_count' => $tasks_count));
}
示例9: getNotifications
/**
* @return $this|\Illuminate\View\View
*/
public function getNotifications()
{
//
$user = Sentinel::getUser();
$user_id = $user->id;
$array_notification = [];
// notifications
$notifications = Notification::where('user_id', '=', $user->id)->orwhere('role_id', '=', $user->roles[0]->id)->get();
foreach ($notifications as $notification) {
if (is_null($notification->status)) {
array_push($array_notification, $notification);
} elseif (!in_array($user->id, unserialize($notification->status))) {
array_push($array_notification, $notification);
}
}
return view('notifications.notifications.index', compact('array_notification', 'user_id'));
}
示例10: store
/**
* 更新消息
*
* @return void
*/
public function store()
{
// get params & validate
$id = Request::get('id');
$message = Request::get('message');
$durationAt = Request::get('duration_at');
$state = Request::get('state');
$redirectUrl = Request::get('_redirect_url');
$rules = ['message' => 'required|max:500', 'duration_at' => 'required|date', 'state' => 'required|in:0,1'];
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return Redirect::to($redirectUrl)->with('error', '保存失败~');
}
// save
$data = ['message' => $message, 'duration_at' => $durationAt, 'state' => $state];
if ($id) {
Notification::where('id', $id)->update($data);
} else {
Notification::create($data);
}
// redirect
return Redirect::to($redirectUrl)->with('success', '保存成功~');
}
示例11: boot
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
view()->composer('includes-update.header', function ($view) {
$thanksCount = 0;
$followCount = 0;
if (Auth::user()->identifier == 1 || Auth::user()->identifier == 3) {
$user = Induser::where('id', '=', Auth::user()->induser_id)->first();
$favourites = Postactivity::with('user')->where('fav_post', '=', 1)->where('user_id', '=', Auth::user()->id)->orderBy('id', 'desc')->get(['id', 'fav_post', 'fav_post_dtTime', 'user_id', 'post_id']);
$thanksCount = Postactivity::with('user', 'post')->join('postjobs', 'postjobs.id', '=', 'postactivities.post_id')->where('postjobs.individual_id', '=', Auth::user()->induser_id)->where('postactivities.thanks', '=', 1)->orderBy('postactivities.id', 'desc')->sum('postactivities.thanks');
$linksCount = Connections::where('user_id', '=', Auth::user()->induser_id)->where('status', '=', 1)->orWhere('connection_user_id', '=', Auth::user()->induser_id)->where('status', '=', 1)->count('id');
$linkrequestCount = Connections::where('connection_user_id', '=', Auth::user()->induser_id)->where('status', '=', 0)->count('id');
$groupCount = Groups_users::where('user_id', '=', Auth::user()->induser_id)->count('id');
$postCount = Postjob::where('individual_id', '=', Auth::user()->induser_id)->count('id');
$profilePer = 0;
if (Auth::user()->induser->fname != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->lname != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->email != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->mobile != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->dob != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->city != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->fb_page != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->in_page != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->gender != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->about_individual != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->education != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->experience != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->working_status != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->working_at != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->role != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->linked_skill != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->resume != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->prefered_location != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->prefered_jobtype != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->induser->profile_pic != null) {
$profilePer = $profilePer + 1;
}
$profilePer = round($profilePer / 20 * 100);
} else {
if (Auth::user()->identifier == 2 || Auth::user()->identifier == 3) {
$user = Corpuser::where('id', '=', Auth::user()->corpuser_id)->first();
$followCount = Follow::where('corporate_id', '=', 1)->orWhere('individual_id', '=', 1)->count('id');
$linksCount = "";
$linkrequestCount = "";
$groupCount = "";
$postCount = Postjob::where('corporate_id', '=', Auth::user()->corpuser_id)->count('id');
$favourites = Postactivity::with('user')->where('fav_post', '=', 1)->where('user_id', '=', Auth::user()->id)->orderBy('id', 'desc')->get(['id', 'fav_post', 'fav_post_dtTime', 'user_id', 'post_id']);
$profilePer = 0;
if (Auth::user()->corpuser->firm_name != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->corpuser->username != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->corpuser->firm_type != null) {
$profilePer = $profilePer + 1;
}
if (Auth::user()->corpuser->emp_count != null) {
//.........这里部分代码省略.........
示例12: notificationNumber
/**
* Function that gets number of notifications.
*
* @return Response
*/
public function notificationNumber()
{
// Check that user is part of authorized staff.
if (Auth::user()->Type != 1) {
// If they are unauthorized no point in returning anything.
return response()->json(array());
}
$notifications = Notification::where('UserId', '=', Auth::user()->Id)->orderBy('Created', 'DES')->take(30)->get();
$unloaded = 0;
foreach ($notifications as $notification) {
if (!$notification->Loaded) {
$unloaded++;
}
}
// Return response.
$response['state'] = 'Success';
$response['number'] = $unloaded;
return response()->json($response);
}
示例13: editMessage
/**
* Edit notification message.
*
* @param EditNotificationMessageRequest $request
* @param AjaxResponse $response
* @return mixed
*/
public function editMessage(EditNotificationMessageRequest $request, AjaxResponse $response)
{
Notification::where('id', $request->get('notification_id'))->update(['message' => $request->get('notification_message')]);
$response->setSuccessMessage(trans('notifications.notification_message_updated'));
return response($response->get())->header('Content-Type', 'application/json');
}
示例14: downvote
public function downvote($id)
{
if (Request::ajax()) {
$post = Post::find($id);
$_upvote_handle = Vote::where('object_id', '=', Auth::id())->where('type', '=', 'upvote')->where('post_id', '=', $id)->first();
if ($_upvote_handle) {
$_upvote_handle->delete();
$_notification_handle = Notification::where('type', '=', 'post')->where('object_id', '=', $id)->where('sender_id', '=', Auth::id())->where('user_id', '=', $post->author_id)->first();
$_notification_handle->delete();
}
$post->newVote()->withType('downvote')->regarding(Auth::user())->deliver();
$user = Auth::user();
$post_author = User::find($post->author_id);
$post_author->newNotification()->withType('post')->withSender($user->id)->withSubject($user->name . ' ' . $user->surname . ' downvoted your post.')->withBody('"' . $post->body . '"')->regarding($post)->deliver();
return array('data1' => $post->votes()->type('downvote')->get()->count(), 'data2' => $post->votes()->type('upvote')->get()->count());
}
}
示例15: seen
public function seen($id)
{
$notification = Notification::where('id', $id)->first();
$notification->seen = true;
$notification->save();
}