├── .gitignore ├── composer.json ├── src ├── SparkKioskNotifyServiceProvider.php ├── routes.php └── resources │ ├── assets │ └── js │ │ └── SparkKioskNotify │ │ └── spark-kiosk-notify.js │ └── views │ └── notifications.blade.php ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | \.DS_Store 3 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vmitchell85/spark-kiosk-notify", 3 | "description": "Create user notifications from your kiosk", 4 | "license": "MIT", 5 | "keywords" : [ 6 | "spark", 7 | "kiosk", 8 | "laravel", 9 | "notifications" 10 | ], 11 | "authors": [ 12 | { 13 | "name": "Vince Mitchell", 14 | "email": "vincent.mitchell@gmail.com" 15 | } 16 | ], 17 | "homepage" : "https://github.com/vmitchell85/spark-kiosk-notify", 18 | "require": {}, 19 | "autoload": { 20 | "psr-4" : { 21 | "vmitchell85\\SparkKioskNotify\\" : "src/" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/SparkKioskNotifyServiceProvider.php: -------------------------------------------------------------------------------- 1 | loadViewsFrom(__DIR__.'/resources/views/', 'spark-kiosk-notify'); 17 | 18 | $this->publishes([ 19 | __DIR__.'/resources/assets/js/' => base_path('resources/assets/js/components/'), 20 | __DIR__ . '/resources/views/' => base_path('resources/views/vendor/spark-kiosk-notify/'), 21 | ]); 22 | } 23 | 24 | /** 25 | * Register the application services. 26 | * 27 | * @return void 28 | */ 29 | public function register() 30 | { 31 | if (! $this->app->routesAreCached()) { 32 | require __DIR__.'/routes.php'; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Vince Mitchell 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/routes.php: -------------------------------------------------------------------------------- 1 | ['web', 'dev']], function($router) { 4 | $router->get('/skn/notifications', function(){ 5 | return \Laravel\Spark\Notification::with('creator')->with('user')->orderBy('created_at', 'desc')->get(); 6 | }); 7 | 8 | $router->post('/skn/notifications/create', function(Illuminate\Http\Request $request){ 9 | 10 | $new_notification = new \Laravel\Spark\Notification; 11 | 12 | // Must generate an unique id since it's not auto increment 13 | $new_notification->id = Illuminate\Support\Facades\Hash::make( time() . Auth::user()->id ); 14 | $new_notification->body = $request->input('body'); 15 | $new_notification->user_id = $request->input('user_id'); 16 | $new_notification->action_text = $request->input('action_text'); 17 | $new_notification->action_url = $request->input('action_url'); 18 | $new_notification->created_by = Auth::user()->id; 19 | $new_notification->save(); 20 | 21 | return $new_notification; 22 | }); 23 | 24 | $router->get('/skn/users', function(){ 25 | return \App\User::all(); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /src/resources/assets/js/SparkKioskNotify/spark-kiosk-notify.js: -------------------------------------------------------------------------------- 1 | Vue.component('spark-kiosk-notify', { 2 | props: [ 3 | ], 4 | data() { 5 | return { 6 | 'notifications': [], 7 | 'users': [], 8 | 'newNotification': { 9 | "user_id": null 10 | } 11 | }; 12 | }, 13 | mounted(){ 14 | this.getNotifications(); 15 | this.getUsers(); 16 | }, 17 | methods: { 18 | /** 19 | * Get all of the announcements. 20 | */ 21 | getNotifications: function(){ 22 | axios.get('/skn/notifications') 23 | .then(response => { 24 | this.notifications = response.data; 25 | }); 26 | }, 27 | 28 | /** 29 | * Get all of the users. 30 | */ 31 | getUsers: function(){ 32 | axios.get('/skn/users') 33 | .then(response => { 34 | this.users = response.data; 35 | }); 36 | }, 37 | 38 | /** 39 | * Create Notification. 40 | */ 41 | createNotification: function(){ 42 | axios.post('/skn/notifications/create', this.newNotification) 43 | .then(response => { 44 | this.newNotification = {}; 45 | this.getNotifications(); 46 | }); 47 | } 48 | 49 | } 50 | }); 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spark Kiosk Notify 2 | 3 | Adds a notification panel to your Laravel Spark Kiosk, allowing you to send notifications to users. 4 | 5 | ## Spark 4.x 6 | Spark 4.0 replaced vue-resource for axios. The 2.1 release has been updated to use axios. 7 | 8 | If you are upgrading to Spark 4.0 you will need to remove the spark-kiosk-notify.js file and republish the resources. 9 | 10 | Please note the path was updated as well. 11 | 12 | ## Vue 1.x 13 | If you are using Vue 1.x please use the 1.0.5 release. The 2.x release is updated for Vue 2.x 14 | 15 | ## Planned / Desired Features 16 | 17 | - View notifications 18 | - Update notifications 19 | - Delete notifications 20 | - Send Notification on User's tab 21 | - Select Multiple Users 22 | - Search for users instead of listing? Listing all could be an issue if you have many users. 23 | - Switch to SparkForm? 24 | 25 | ## Installation process 26 | 27 | This package comes with predefined views and routes to use with your existing Spark installation. 28 | 29 | In order to install the Spark Kiosk Notifications Package into your Spark application: 30 | 31 | **1. Add this composer package to your composer.json using the command below** 32 | 33 | `composer require vmitchell85/spark-kiosk-notify` 34 | 35 | **2. Add the following to providers array in `config\app.php`** 36 | 37 | `vmitchell85\SparkKioskNotify\SparkKioskNotifyServiceProvider::class,` 38 | 39 | **3. Publish the Spark resources (views, VueJS components):** 40 | 41 | `php artisan vendor:publish --provider="vmitchell85\SparkKioskNotify\SparkKioskNotifyServiceProvider"` 42 | 43 | **4. Add the javascript components to your bootstrap.js file** 44 | 45 | Add `require('./components/SparkKioskNotify/spark-kiosk-notify');` to your `resources/assets/js/components/app.js` file. 46 | 47 | **5. Compile the Javascript components** 48 | 49 | `npm run dev` 50 | 51 | **6. Add the HTML snippets** 52 | 53 | File: `resources/views/vendor/spark/kiosk.blade.php` 54 | 55 | Place a link to the notifications settings tab: 56 | 57 | ```html 58 | 59 |
  • 60 | 61 | Notifications 62 | 63 |
  • 64 | ``` 65 | 66 | Inside the `` section, place the code to load the notifications tab: 67 | 68 | ```html 69 | 70 |
    71 | @include('spark-kiosk-notify::notifications') 72 |
    73 | ``` 74 | 75 | **7. Try it out** 76 | 77 | Log into your Spark application and access the new notifications tab located at: 78 | 79 | `http://your-spark.url/spark/kiosk#/notifications` 80 | -------------------------------------------------------------------------------- /src/resources/views/notifications.blade.php: -------------------------------------------------------------------------------- 1 | 2 |
    3 |
    4 |
    Create Notification
    5 | 6 |
    7 |
    8 | Notifications you create here will be sent to the "Notifications" section of 9 | the notifications modal window for that specific user. 10 |
    11 | 12 |
    13 | 14 | 15 |
    16 | 17 | 18 |
    19 | 23 |
    24 |
    25 | 26 | 27 |
    28 | 29 | 30 |
    31 | 33 |
    34 |
    35 | 36 | 37 |
    38 | 39 | 40 |
    41 | 42 |
    43 |
    44 | 45 | 46 |
    47 | 48 | 49 |
    50 | 51 |
    52 |
    53 | 54 | 55 |
    56 |
    57 | 60 |
    61 |
    62 |
    63 |
    64 |
    65 | 66 |
    67 |
    Recent Notifications
    68 | 69 |
    70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 84 | 85 | 86 | 91 | 94 | 95 | 96 | {{-- --}} 101 | 102 | 103 | 108 | 109 | 110 |
    Created ByDateUser
    82 | 83 | 87 |
    88 | @{{ notification.created_at | datetime }} 89 |
    90 |
    92 | 93 | 97 | 100 | 104 | {{-- --}} 107 |
    111 |
    112 |
    113 |
    114 |
    115 | --------------------------------------------------------------------------------