Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to laravel 8 and add feature API #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

[*.yml]
[*.{yml,yaml}]
indent_size = 2

[docker-compose.yml]
indent_size = 4
18 changes: 13 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
APP_NAME=Laravel
APP_NAME=SMSManager
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_DEBUG=false
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
Expand All @@ -15,25 +17,31 @@ DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
Expand Down
30 changes: 12 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
vendor/
node_modules/
npm-debug.log

# Laravel 4 specific
bootstrap/compiled.php
app/storage/

# Laravel 5 & Lumen specific
public/storage
public/hot
storage/*.key
.env.*.php
.env.php
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
Homestead.yaml
.env.backup
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log

# Rocketeer PHP task runner and deployment package. /~https://github.com/rocketeers/rocketeer
.rocketeer/
/.idea
/.vscode
3 changes: 2 additions & 1 deletion .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
php:
preset: laravel
version: 8
disabled:
- unused_use
- no_unused_imports
finder:
not-name:
- index.php
Expand Down
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src="https://www.whatcounts.com/wp-content/uploads/2018/06/SMS-Marketing-FAQs.jpg" alt="SMS Management"/>
</p>

# SMS Management
# SMS Management & SMS API

SMS Management is free and open source SMS Management software with Gammu as core service.

Expand Down Expand Up @@ -35,7 +35,7 @@ Another OS : [here](https://wammu.eu/download/gammu/)


```
$ cd ~ && git clone /~https://github.com/arifsetyo21/sms-management.git
$ cd ~ && git clone /~https://github.com/elouafidev/sms-management.git

$ cd sms-management

Expand All @@ -60,6 +60,34 @@ $ php artisan db:seed --class="adminSeeder"

Add additional notes about how to deploy this on a live system

### API Document
```
url local : http://example.com:8000/api/latest

parameters :
- access_key : token for authentication
- request : request you want send to (send - check_status )
- phone : The phone number to which you want to send SMS
- content : SMS content

Response (json):
- success (boolean): true or false
- data : Get the result of the request if success is true
- error : : Get the error of the request if success is false

example :
{
Success : // true OR false
Data : "send" // result for request
error : {
'code' : // code error {202 ,404,…}
'type' : //‘ missing_access_key’,’ missing_access_key’,’ bad_request’,…
'info' : // Error information
},
}

```

## Built With

* [Laravel](/~https://github.com/laravel/laravel) - Laravel is a web application framework with expressive, elegant syntax.
Expand All @@ -76,4 +104,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
## Acknowledgments

* [Cara Membuat SMS Gateway Dengan Gammu + USB Modem + MySQL Database](https://medium.com/@juniyadi/cara-membuat-sms-gateway-dengan-gammu-usb-modem-mysql-database-1faae8f7d6a7)
* [How to setup a USB 3G Modem on Raspberry PI using usb_modeswitch and wvdial](https://www.thefanclub.co.za/how-to/how-setup-usb-3g-modem-raspberry-pi-using-usbmodeswitch-and-wvdial)
* [How to setup a USB 3G Modem on Raspberry PI using usb_modeswitch and wvdial](https://www.thefanclub.co.za/how-to/how-setup-usb-3g-modem-raspberry-pi-using-usbmodeswitch-and-wvdial)
14 changes: 7 additions & 7 deletions app/Console/Commands/NotifySmsContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace App\Console\Commands;

use App\Models\ScheduledSms;
use Illuminate\Console\Command;
use Carbon\Carbon;
use App\ScheduledSms;
use App\Jobs\SendSMSJob;

class NotifySmsContact extends Command
Expand Down Expand Up @@ -44,7 +44,7 @@ public function handle()
// $ids = ScheduledSms::all();
// $ids->map(function ($item, $key) {
// ScheduledSms::destroy($item->id);
// return "ScheduledSms with id $item->id deleted";
// return "ScheduledSms with id $item->id deleted";
// });

// echo "notify:sms-contact done operate\n\n";
Expand All @@ -58,13 +58,13 @@ public function handle()
$scheduledSmses->where('day', $now_day)->where('time', $now_hour)->each(function($scheduledSms) {
if($scheduledSms->sent_at == null || $scheduledSms->repeat == 0){
\dispatch(new SendSMSJob(
$scheduledSms->id,
$scheduledSms->phone_number,
$scheduledSms->sms_content,
$scheduledSms->CreatorID,
$scheduledSms->id,
$scheduledSms->phone_number,
$scheduledSms->sms_content,
$scheduledSms->CreatorID,
$scheduledSms->repeat)
);

$scheduledSms->sent_at = Carbon::now();
$scheduledSms->save();
}
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function schedule(Schedule $schedule)
// $schedule->command('inspire')
// ->hourly();
$schedule->command('notify:sms-contact')
->everyMinute();
->everyMinute();
}

/**
Expand Down
28 changes: 9 additions & 19 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
* @var array<int, class-string<Throwable>>
*/
protected $dontReport = [
//
Expand All @@ -19,33 +19,23 @@ class Handler extends ExceptionHandler
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];

/**
* Report or log an exception.
* Register the exception handling callbacks for the application.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
public function register()
{
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
$this->reportable(function (Throwable $e) {
//
});
}
}
104 changes: 104 additions & 0 deletions app/Http/Controllers/API/Auth/RegisterController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

namespace App\Http\Controllers\API\Auth;

use Illuminate\Http\Request;

use App\Http\Controllers\API\BaseController as BaseController;

use App\Models\User;

use Illuminate\Support\Facades\Auth;

use Illuminate\Support\Facades\Validator;


class RegisterController extends BaseController

{

/**
* Register api
*

* @return \Illuminate\Http\JsonResponse
*/

public function register(Request $request)

{

$validator = Validator::make($request->all(), [

'name' => 'required',

'email' => 'required|email',

'password' => 'required',

'c_password' => 'required|same:password',

]);



if($validator->fails()){

return $this->sendError('Validation Error.', $validator->errors());

}



$input = $request->all();

$input['password'] = bcrypt($input['password']);

$user = User::create($input);

$success['token'] = $user->createToken('MyApp')->plainTextToken;

$success['name'] = $user->name;



return $this->sendResponse($success, 'User register successfully.');

}



/**
* Login api
*

* @return \Illuminate\Http\JsonResponse
*/

public function login(Request $request)

{

if(Auth::attempt(['email' => $request->email, 'password' => $request->password])){

$user = Auth::user();

$success['token'] = $user->createToken('MyApp')->plainTextToken;

$success['name'] = $user->name;



return $this->sendResponse($success, 'User login successfully.');

}

else{

return $this->sendError('Unauthorised.', ['error'=>'Unauthorised']);

}

}

}
Loading