Fix: updated AdminController and added SMS for credentials

This commit is contained in:
Kwesi Banson Jnr 2026-03-10 08:52:35 +00:00
parent c20e02c408
commit 0f7c5731dd
7 changed files with 85 additions and 2 deletions

View File

@ -6,6 +6,7 @@ APP_URL=http://localhost:9031
LOG_CHANNEL=daily
LUPMISAPIKEY=1c46538c712e9b5b
MNOTOFYKEY=hFsiPMAPS3sIdwYSIthRO5JtS
DB_CONNECTION=mysql
DB_HOST=host.docker.internal
DB_PORT=3306

View File

@ -13,7 +13,7 @@ class PermitsController extends Controller
$url = "permit/get_applications_by_district.php";
$data = json_encode([
'district_id' => 80,
'district_id' => session('district_id'),
'api_token' => env('LUPMISAPIKEY')
]);
$result = ApiCalls::CurlPost($data, $url);
@ -31,7 +31,7 @@ class PermitsController extends Controller
public function statusIndex($status){
$url = "permit/get_applications_by_district.php";
$data = json_encode([
'district_id' => 80,
'district_id' => session('district_id'),
'api_token' => env('LUPMISAPIKEY')
]);
$result = ApiCalls::CurlPost($data, $url);

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Utilities\ApiCalls;
use App\Utilities\SmsLibrary;
use Session;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
@ -85,6 +86,18 @@ class UsersController extends Controller
$recipientEmail = 'recipient@example.com';
Mail::to($recipientEmail)->send(new UserAccountsMail($password, $request->username));
//dd('Email sent!');
$sms_message = "Hello $request->full_name your LUPMIS account has been successfully created\n";
$sms_message .= "Username : . $request->username \n";
$sms_message .= "Password : $password\n";
$sms_message .= 'Login URL : https://lupmis4luspa.org';
$sms_data = [
'recipient' => $request['phone'],
'message' => $sms_message
];
$sms_result = SmsLibrary::SendMnotitySms($sms_data);
\Log::info("SMS Body : $sms_message");
\Log::info("SMS API Response : $sms_result");
if (request()->expectsJson()) {
return response()->json($result);

View File

@ -0,0 +1,26 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Utilities\ApiCalls;
use App\Utilities\SmsLibrary;
class UtilityController extends Controller
{
public function sendSms(){
// code...
$sms_message = "Hello Susana your LUPMIS account has been successfully created\n";
$sms_message .= "Username : . sussie \n";
$sms_message .= "Password : securepass\n";
$sms_message .= 'Login URL : https://lupmis4luspa.org';
$sms_data = [
'recipient' => '0555344661',
'message' => $sms_message
];
$sms_result = SmsLibrary::SendMnotitySms($sms_data);
\Log::info("SMS API Response : $sms_result");
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace App\Utilities;
class SmsLibrary{
public static function SendMnotitySms($data){
$endPoint = 'https://api.mnotify.com/api/sms/quick';
$apiKey = env('MNOTOFYKEY');
$url = $endPoint . '?key=' . $apiKey;
$data = [
'recipient' => [$data['recipient']],
'sender' => 'LUPMIS',
'message' => $data['message'],
'is_schedule' => false,
'schedule_date' => '',
// uncomment the below line to send OTP sms
// When sms_type: "otp" is included in your payload, a charge of 0.035 per campaign will be deducted from your main wallet.
// 'sms_type': 'otp' please do not include in payload when the purpose of the blast is not for otp
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$result = curl_exec($ch);
// $result = json_decode($result, TRUE);
curl_close($ch);
return $result;
}
}

View File

@ -1,3 +1,9 @@
composer create-project laravel/laravel:^11.0 my-laravel-11-project
chmod -R 0777 storage/
chmod -R 0777 bootstrap/
<li>Username: kwesilupmis</li>
<li>Password: 7aa0478bce </li>
<li>URL: https://lupmis4luspa.org</li>

View File

@ -23,6 +23,8 @@ Auth::routes([
Route::get('/view-pdf/{filename}', [App\Http\Controllers\PermitsController::class, 'viewPdf'])->name('view.pdf');
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
Route::get('/sendsms', [App\Http\Controllers\UtilityController::class, 'sendSms'])->name('sendsms');
Route::get('/user-login', [App\Http\Controllers\UserloginController::class, 'index']);
Route::post('/user-login', [App\Http\Controllers\UserloginController::class, 'handleLogin']);
Route::get('/user-logout', [App\Http\Controllers\UserloginController::class, 'handle_logout'])->name('user-logout');