2017 © Pedro Peláez
 

library notification

Simple Notification System for Laravel 4.2

image

tashkar18/notification

Simple Notification System for Laravel 4.2

  • Sunday, April 3, 2016
  • by tashkar18
  • Repository
  • 1 Watchers
  • 0 Stars
  • 106 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Notification (Laravel 4)

Quick Start

Required Setup

Require tashkar18\notification with the composer command, (*1)

$ composer require tashkar18/notification ~0.2

In your config/app.php file,, (*2)

add Tashkar18\Notification\NotificationServiceProvider to the end of the providers array, (*3)

  'providers' => array(
    'Illuminate\Foundation\Providers\ArtisanServiceProvider',
    'Illuminate\Auth\AuthServiceProvider',
    ...
    'Tashkar18\Notification\NotificationServiceProvider',
  ),

Now generate the configuration file, (*4)

$ php artisan config:publish tashkar18/notification

Then migrate the notifications table, (*5)

$ php artisan migrate --package="tashkar18/notification"

Setup

In any of your Eloquent models, implement the NotificationInterface and use the NotificationTrait., (*6)

use Tashkar18\Notification\NotificationInterface;
use Tashkar18\Notification\NotificationTrait;

class Comment extends Eloquent implements NotificationInterface
{
    use NotificationTrait;

Then implement these methods in your model., (*7)

/**
 * This determines the recipient id of the event.
 * For example, if a user comments on a post, the recipient of the
 * notification would be the post's author.
 * @return {int}
 */
public function getNotificationRecipient()
{
    return $this->post->user_id;
}

/**
 * This determines the sender id of the event.
 * For example, if a user comments on a post, the sender of the
 * notification would be the comment's author. (This will typically
 * be user_id, but you might also use a different attribute for the user_id like author_id);
 * @return {int}
 */
public function getNotificationSender()
{
    return $this->user_id;
}

You can add the NoterTrait to the your User model to setup the user hasMany relationship, (*8)

use Tashkar18\Notification\NoterTrait;

class User extends Eloquent implements UserInterface, RemindableInterface {

    use UserTrait, RemindableTrait, NoterTrait;

You will then be able to access user notifications, (*9)

return $user->notifications;

Configuration

Create your Notification-specific views folder, and adjust the packages/tashkar18/notification/config.php to match, (*10)

  return array(
      'view' => 'notifications'
  );

Create your ViewPresenter for your Eloquent model.

Your view presenter file is simply a view file that will present your notification in human readable text., (*11)

For example, a Comment model would have a view file in views\notifications\comment.blade.php The comment object will automatically be passed into that view and can be access with the variable $comment., (*12)

// views/notifications/comment.blade.php
{{{ ucfirst($comment->user->username) }}} commented on your post.

Testing (coming soon)

The Versions

03/04 2016

dev-master

9999999-dev

Simple Notification System for Laravel 4.2

  Sources   Download

The Requires

 

The Development Requires

by Tamer Ashkar

03/04 2016

0.3

0.3.0.0

Simple Notification System for Laravel 4.2

  Sources   Download

The Requires

 

The Development Requires

by Tamer Ashkar

20/11 2015

0.2.1

0.2.1.0

Simple Notification System for Laravel 4.2

  Sources   Download

The Requires

 

The Development Requires

by Tamer Ashkar

20/11 2015

0.2

0.2.0.0

Simple Notification System for Laravel 4.2

  Sources   Download

The Requires

 

The Development Requires

by Tamer Ashkar

19/11 2015

0.1

0.1.0.0

  Sources   Download

The Requires

 

The Development Requires

by Tamer Ashkar