In this post I wanted to discuss the README, the idea is simple, you have a notification based system that allows for easy manipulation of a user’s notifications.

Laravel offers this, to some degree, but I wanted to strip away some of the layers and get right down to it. A user can have many notifications and a notification can have a few states but always belongs to a user.

A notification is either read, unread, dismissed, soft deleted or hard deleted.

All notifications have an expiry date, one is for notifications that are either unread or dismissed and one is for read notifications. Both have an option of being soft or hard deleted when they expire.

Creating notifications is easy:

class User extends Model {
  use Notifications;
}

// Now you can do:

$user = User::find(1);

$user->createNotification(
    'Some title',
    'Short Description',
    'link'                  // Type: configurable, link is an example. You can put whatever here. See below with migrations.
    [
      'url' => 'http://google.ca',          // Optional
      // See below for more information ...
      'expiration_unread' => Carbon::now(), // Optional
      'expiration_read' => Carbon::now(),   // Optional
      'soft_expiration_delete' => true      // Optional
    ]
);

The reason I am unsure if I want to build this is because A) there is a hundred notification packages for laravel/php out there and B) there is this concept of don’t re-invent the wheel, which I sort of talked about in my “Discouraged to build anything new” post.

The PHP community is an interesting one. It’s about innovation and building new ideas but there is this heavy concept of “don’t reinvent the wheel” which is why I backed away from the language for a few months to gather perspective.

Unfortunately, that mind set hasn’t changed in the community and it never will.

If I did decide to build this concept out, weather it’s the one you have seen or one that is changed by ideas and community feedback, it would probably just be some experiment.

Regardless of the community’s thoughts on the concept that people tell you not to re-invent the wheel, I would still love for you all to head over to the gist to get a more in depth look at the concept.