@@ -11,7 +11,7 @@ |
||
| 11 | 11 | protected $namespace = 'Modules\Notification\Http\Controllers'; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * @return string |
|
| 14 | + * @return boolean |
|
| 15 | 15 | */ |
| 16 | 16 | protected function getFrontendRoute() |
| 17 | 17 | { |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | protected function getBackendRoute() |
| 25 | 25 | { |
| 26 | - return __DIR__ . '/../Http/backendRoutes.php'; |
|
| 26 | + return __DIR__.'/../Http/backendRoutes.php'; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -31,6 +31,6 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | protected function getApiRoute() |
| 33 | 33 | { |
| 34 | - return __DIR__ . '/../Http/apiRoutes.php'; |
|
| 34 | + return __DIR__.'/../Http/apiRoutes.php'; |
|
| 35 | 35 | } |
| 36 | 36 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | public function up() |
| 13 | 13 | { |
| 14 | - Schema::create('notification__notifications', function (Blueprint $table) { |
|
| 14 | + Schema::create('notification__notifications', function(Blueprint $table) { |
|
| 15 | 15 | $table->increments('id'); |
| 16 | 16 | $table->integer('user_id')->unsigned(); |
| 17 | 17 | $table->string('type')->nullable(); |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function broadcastOn() |
| 27 | 27 | { |
| 28 | - return ['asgardcms.notifications.' . $this->notification->user_id]; |
|
| 28 | + return [ 'asgardcms.notifications.'.$this->notification->user_id ]; |
|
| 29 | 29 | } |
| 30 | 30 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * Get the channels the event should broadcast on. |
| 26 | - * @return array |
|
| 26 | + * @return string[] |
|
| 27 | 27 | */ |
| 28 | 28 | public function broadcastOn() |
| 29 | 29 | { |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | use Illuminate\Routing\Router; |
| 4 | 4 | |
| 5 | 5 | /** @var Router $router */ |
| 6 | -$router->group(['prefix' => '/notification'], function (Router $router) { |
|
| 6 | +$router->group([ 'prefix' => '/notification' ], function(Router $router) { |
|
| 7 | 7 | $router->get('notifications', [ |
| 8 | 8 | 'as' => 'admin.notification.notification.index', |
| 9 | 9 | 'uses' => 'NotificationsController@index', |
@@ -3,4 +3,4 @@ |
||
| 3 | 3 | use Illuminate\Routing\Router; |
| 4 | 4 | |
| 5 | 5 | /** @var Router $router */ |
| 6 | -$router->post('notification/mark-read', ['as' => 'api.notification.read', 'uses' => 'NotificationsController@markAsRead']); |
|
| 6 | +$router->post('notification/mark-read', [ 'as' => 'api.notification.read', 'uses' => 'NotificationsController@markAsRead' ]); |
|
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $this->registerBindings(); |
| 36 | 36 | $this->registerViewComposers(); |
| 37 | 37 | |
| 38 | - $this->app['events']->listen( |
|
| 38 | + $this->app[ 'events' ]->listen( |
|
| 39 | 39 | BuildingSidebar::class, |
| 40 | 40 | $this->getSidebarClassForModule('blog', RegisterNotificationSidebar::class) |
| 41 | 41 | ); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | { |
| 46 | 46 | $this->publishConfig('notification', 'config'); |
| 47 | 47 | $this->publishConfig('notification', 'permissions'); |
| 48 | - $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); |
|
| 48 | + $this->loadMigrationsFrom(__DIR__.'/../Database/Migrations'); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -62,10 +62,10 @@ discard block |
||
| 62 | 62 | { |
| 63 | 63 | $this->app->bind( |
| 64 | 64 | NotificationRepository::class, |
| 65 | - function () { |
|
| 65 | + function() { |
|
| 66 | 66 | $repository = new EloquentNotificationRepository(new Notification()); |
| 67 | 67 | |
| 68 | - if (! config('app.cache')) { |
|
| 68 | + if (!config('app.cache')) { |
|
| 69 | 69 | return $repository; |
| 70 | 70 | } |
| 71 | 71 | |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | ); |
| 75 | 75 | |
| 76 | - $this->app->bind(\Modules\Notification\Services\Notification::class, function ($app) { |
|
| 77 | - return new AsgardNotification($app[NotificationRepository::class], $app[Authentication::class]); |
|
| 76 | + $this->app->bind(\Modules\Notification\Services\Notification::class, function($app) { |
|
| 77 | + return new AsgardNotification($app[ NotificationRepository::class ], $app[ Authentication::class ]); |
|
| 78 | 78 | }); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -40,15 +40,15 @@ |
||
| 40 | 40 | |
| 41 | 41 | protected function getEnvironmentSetUp($app) |
| 42 | 42 | { |
| 43 | - $app['path.base'] = __DIR__ . '/..'; |
|
| 44 | - $app['config']->set('database.default', 'sqlite'); |
|
| 45 | - $app['config']->set('database.connections.sqlite', array( |
|
| 43 | + $app[ 'path.base' ] = __DIR__.'/..'; |
|
| 44 | + $app[ 'config' ]->set('database.default', 'sqlite'); |
|
| 45 | + $app[ 'config' ]->set('database.connections.sqlite', array( |
|
| 46 | 46 | 'driver' => 'sqlite', |
| 47 | 47 | 'database' => ':memory:', |
| 48 | 48 | 'prefix' => '', |
| 49 | 49 | )); |
| 50 | - $app['config']->set('translatable.locales', ['en', 'fr']); |
|
| 51 | - $app['config']->set('modules.paths.modules', __DIR__ . '/../Modules'); |
|
| 50 | + $app[ 'config' ]->set('translatable.locales', [ 'en', 'fr' ]); |
|
| 51 | + $app[ 'config' ]->set('modules.paths.modules', __DIR__.'/../Modules'); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | private function resetDatabase() |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | ]); |
| 31 | 31 | |
| 32 | 32 | $this->assertCount(1, $this->notification->all()); |
| 33 | - $this->assertEquals('1' , $notification->user_id); |
|
| 34 | - $this->assertEquals('fa fa-link' , $notification->icon_class); |
|
| 35 | - $this->assertEquals('http://localhost/users' , $notification->link); |
|
| 36 | - $this->assertEquals('My notification' , $notification->title); |
|
| 37 | - $this->assertEquals('Is awesome!' , $notification->message); |
|
| 33 | + $this->assertEquals('1', $notification->user_id); |
|
| 34 | + $this->assertEquals('fa fa-link', $notification->icon_class); |
|
| 35 | + $this->assertEquals('http://localhost/users', $notification->link); |
|
| 36 | + $this->assertEquals('My notification', $notification->title); |
|
| 37 | + $this->assertEquals('Is awesome!', $notification->message); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** @test */ |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | $this->createNotification(); |
| 52 | 52 | $this->createNotification(); |
| 53 | 53 | $this->createNotification(); |
| 54 | - $this->createNotification(['user_id' => 2]); |
|
| 55 | - $this->createNotification(['user_id' => 2]); |
|
| 54 | + $this->createNotification([ 'user_id' => 2 ]); |
|
| 55 | + $this->createNotification([ 'user_id' => 2 ]); |
|
| 56 | 56 | |
| 57 | 57 | $this->assertCount(10, $this->notification->latestForUser(1)); |
| 58 | 58 | $this->assertCount(2, $this->notification->latestForUser(2)); |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | $this->createNotification(); |
| 73 | 73 | $this->createNotification(); |
| 74 | 74 | $this->createNotification(); |
| 75 | - $this->createNotification(['user_id' => 2]); |
|
| 76 | - $this->createNotification(['user_id' => 2]); |
|
| 75 | + $this->createNotification([ 'user_id' => 2 ]); |
|
| 76 | + $this->createNotification([ 'user_id' => 2 ]); |
|
| 77 | 77 | |
| 78 | 78 | $this->assertCount(11, $this->notification->allForUser(1)); |
| 79 | 79 | $this->assertCount(2, $this->notification->allForUser(2)); |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | public function it_can_get_all_unread_notifications_for_user() |
| 96 | 96 | { |
| 97 | 97 | $this->createNotification(); |
| 98 | - $this->createNotification(['is_read' => true]); |
|
| 99 | - $this->createNotification(['is_read' => true]); |
|
| 98 | + $this->createNotification([ 'is_read' => true ]); |
|
| 99 | + $this->createNotification([ 'is_read' => true ]); |
|
| 100 | 100 | $this->createNotification(); |
| 101 | 101 | |
| 102 | 102 | $this->assertCount(2, $this->notification->allUnreadForUser(1)); |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | public function it_can_get_all_read_notifications_for_user() |
| 107 | 107 | { |
| 108 | 108 | $this->createNotification(); |
| 109 | - $this->createNotification(['is_read' => true]); |
|
| 110 | - $this->createNotification(['is_read' => true]); |
|
| 109 | + $this->createNotification([ 'is_read' => true ]); |
|
| 110 | + $this->createNotification([ 'is_read' => true ]); |
|
| 111 | 111 | $this->createNotification(); |
| 112 | 112 | $this->createNotification(); |
| 113 | 113 | |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | $this->createNotification(); |
| 121 | 121 | $this->createNotification(); |
| 122 | 122 | $this->createNotification(); |
| 123 | - $this->createNotification(['user_id' => 2]); |
|
| 124 | - $this->createNotification(['user_id' => 2]); |
|
| 123 | + $this->createNotification([ 'user_id' => 2 ]); |
|
| 124 | + $this->createNotification([ 'user_id' => 2 ]); |
|
| 125 | 125 | |
| 126 | 126 | $this->assertCount(3, $this->notification->allForUser(1)); |
| 127 | 127 | $this->assertCount(2, $this->notification->allForUser(2)); |
@@ -138,8 +138,8 @@ discard block |
||
| 138 | 138 | $this->createNotification(); |
| 139 | 139 | $this->createNotification(); |
| 140 | 140 | $this->createNotification(); |
| 141 | - $this->createNotification(['user_id' => 2]); |
|
| 142 | - $this->createNotification(['user_id' => 2]); |
|
| 141 | + $this->createNotification([ 'user_id' => 2 ]); |
|
| 142 | + $this->createNotification([ 'user_id' => 2 ]); |
|
| 143 | 143 | |
| 144 | 144 | $this->assertCount(0, $this->notification->allReadForUser(1)); |
| 145 | 145 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $this->assertCount(3, $this->notification->allReadForUser(1)); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - private function createNotification(array $properties = []) : Notification |
|
| 150 | + private function createNotification(array $properties = [ ]) : Notification |
|
| 151 | 151 | { |
| 152 | 152 | $data = [ |
| 153 | 153 | 'user_id' => 1, |
@@ -21,11 +21,11 @@ discard block |
||
| 21 | 21 | public function latestForUser($userId) |
| 22 | 22 | { |
| 23 | 23 | return $this->cache |
| 24 | - ->tags([$this->entityName, 'global']) |
|
| 24 | + ->tags([ $this->entityName, 'global' ]) |
|
| 25 | 25 | ->remember( |
| 26 | 26 | "{$this->locale}.{$this->entityName}.latestForUser.{$userId}", |
| 27 | 27 | $this->cacheTime, |
| 28 | - function () use ($userId) { |
|
| 28 | + function() use ($userId) { |
|
| 29 | 29 | return $this->repository->latestForUser($userId); |
| 30 | 30 | } |
| 31 | 31 | ); |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | public function allForUser($userId) |
| 52 | 52 | { |
| 53 | 53 | return $this->cache |
| 54 | - ->tags([$this->entityName, 'global']) |
|
| 54 | + ->tags([ $this->entityName, 'global' ]) |
|
| 55 | 55 | ->remember( |
| 56 | 56 | "{$this->locale}.{$this->entityName}.allForUser.{$userId}", |
| 57 | 57 | $this->cacheTime, |
| 58 | - function () use ($userId) { |
|
| 58 | + function() use ($userId) { |
|
| 59 | 59 | return $this->repository->allForUser($userId); |
| 60 | 60 | } |
| 61 | 61 | ); |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | public function allReadForUser($userId) |
| 70 | 70 | { |
| 71 | 71 | return $this->cache |
| 72 | - ->tags([$this->entityName, 'global']) |
|
| 72 | + ->tags([ $this->entityName, 'global' ]) |
|
| 73 | 73 | ->remember( |
| 74 | 74 | "{$this->locale}.{$this->entityName}.allReadForUser.{$userId}", |
| 75 | 75 | $this->cacheTime, |
| 76 | - function () use ($userId) { |
|
| 76 | + function() use ($userId) { |
|
| 77 | 77 | return $this->repository->allReadForUser($userId); |
| 78 | 78 | } |
| 79 | 79 | ); |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | public function allUnreadForUser($userId) |
| 88 | 88 | { |
| 89 | 89 | return $this->cache |
| 90 | - ->tags([$this->entityName, 'global']) |
|
| 90 | + ->tags([ $this->entityName, 'global' ]) |
|
| 91 | 91 | ->remember( |
| 92 | 92 | "{$this->locale}.{$this->entityName}.allUnreadForUser.{$userId}", |
| 93 | 93 | $this->cacheTime, |
| 94 | - function () use ($userId) { |
|
| 94 | + function() use ($userId) { |
|
| 95 | 95 | return $this->repository->allUnreadForUser($userId); |
| 96 | 96 | } |
| 97 | 97 | ); |