diff --git a/.env.example b/.env.example index cd8c266..9b9e818 100644 --- a/.env.example +++ b/.env.example @@ -3,6 +3,7 @@ APP_ENV=local APP_KEY= APP_DEBUG=true APP_LOG_LEVEL=debug +DEBUGBAR_ENABLED=true APP_URL=http://localhost:8000/ API_CHALLENGE=change_me diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index a2c3541..dfa5f59 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -12,6 +12,6 @@ class VerifyCsrfToken extends BaseVerifier * @var array */ protected $except = [ - // + '/sms/receive' ]; } diff --git a/composer.json b/composer.json index 4849f16..776ad26 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "maatwebsite/excel": "^2.1", "nesbot/carbon": "^1.22", "nexmo/client": "^1.0", + "nexmo/laravel": "^1.0", "predis/predis": "^1.1", "spatie/laravel-activitylog": "^2.1", "yajra/laravel-datatables-buttons": "3.*", diff --git a/config/nexmo.php b/config/nexmo.php new file mode 100644 index 0000000..e43bac1 --- /dev/null +++ b/config/nexmo.php @@ -0,0 +1,31 @@ + function_exists('env') ? env('NEXMO_KEY', '') : '', + 'api_secret' => function_exists('env') ? env('NEXMO_SECRET', '') : '', + + /* + |-------------------------------------------------------------------------- + | Signature Secret + |-------------------------------------------------------------------------- + | + | If you're using a signature secret, use this section. This can be used + | without an `api_secret` for some APIs, as well as with an `api_secret` + | for all APIs. + | + */ + + 'signature_secret' => function_exists('env') ? env('NEXMO_SIGNATURE_SECRET', '') : '', + +]; diff --git a/routes/web.php b/routes/web.php index c88648b..7041e3b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -83,6 +83,24 @@ *-----------------------*/ Route::resource('site', 'SiteController'); +/*-----------------------* + * SMS Controller * + *-----------------------*/ +Route::get('/sms/send/{to}', function(\Nexmo\Client $nexmo, $to){ + $message = $nexmo->message()->send([ + 'to' => $to, + 'from' => env('NEXMO_FROM'), + 'text' => 'This is a test sms message from SmartSettia.' + ]); + Log::info('sent message: ' . $message['message-id']); +}); +Route::post('/sms/receive', function(\Nexmo\Client $nexmo){ + $message = \Nexmo\Message\InboundMessage::createFromGlobals(); + Log::info('got text: ' . $message->getBody()); + $reply =$nexmo->message()->send($message->createReply('This is for SmartSettia notifications only. Please contact admin@smartsettia.com for assistance.')); + Log::info('sent reply: ' . $reply['message-id']); +}); + // TODO Route::get('unit', 'DashboardController@index')->name('unit'); Route::get('admin', 'DashboardController@index')->name('admin');