Skip to content

Commit

Permalink
Add feed helper method and feed facade
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljennings committed Mar 3, 2016
1 parent 019d6c4 commit 56f309f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "michaeljennings/feed",
"description": "A simple activity feed for laravel",
"description": "A simple activity feed for laravel 5+",
"version": "0.1",
"keywords": ["laravel", "feed", "activity"],
"license": "MIT",
Expand All @@ -16,7 +16,10 @@
"autoload": {
"psr-4": {
"Michaeljennings\\Feed\\": "src/"
}
},
"files": [
"src/helpers.php"
]
},
"require-dev": {
"phpunit/phpunit": "4.8.*",
Expand Down
18 changes: 18 additions & 0 deletions src/Facades/Feed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Michaeljennings\Feed\Facades;

use Illuminate\Support\Facades\Facade;

class Feed extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'michaeljennings.feed';
}
}
2 changes: 2 additions & 0 deletions src/FeedServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public function boot()
*/
public function register()
{


$this->app->bind('michaeljennings.feed.repository', 'Michaeljennings\Feed\Notifications\Repository');

$this->app->bind('michaeljennings.feed', function($app) {
Expand Down
24 changes: 24 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

if ( ! function_exists('feed')) {

/**
* Get the notifications for the notifiable members.
*
* If no notifiable members are passed then return the feed instance.
*
* @param null $notifiable
* @return \Illuminate\Foundation\Application|mixed
*/
function feed($notifiable = null)
{
$feed = app('michaeljennings.feed');

if ($notifiable) {
return $feed->pull($notifiable);
}

return $feed;
}

}

0 comments on commit 56f309f

Please sign in to comment.