Compare commits

..

1 Commits

Author SHA1 Message Date
WAKOYA_KUMSA\waqo1 569a22c0db route activity log 2022-12-28 13:15:15 +03:00
5 changed files with 120 additions and 8 deletions
@@ -22,7 +22,7 @@ class CreatesBillplzBill
public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null, ?bool $wallet = null) {
try{
// config('billplz.maybank')
$requestBody = [
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
'collection_id' => config('billplz.collection_id'),
'name' => $name,
'email' => $email,
@@ -34,13 +34,7 @@ class CreatesBillplzBill
'reference_1' => $bankCode ? $bankCode : '',
'reference_2_label' => 'Bill Number',
'reference_2' => $billNumber
];
if (in_array(app()->environment(), ['development', 'staging', 'production'])) {
$response = Http::withBasicAuth(config('billplz.api_key') . ':', '')->post(config('billplz.base_url') . '/api/v3/bills', $requestBody);
} else {
$response = Http::withoutVerifying()->withBasicAuth(config('billplz.api_key') . ':', '')->post(config('billplz.base_url') . '/api/v3/bills', $requestBody);
}
]);
if($response->successful()){
$data = $response->json();
+1
View File
@@ -22,6 +22,7 @@ class Kernel extends HttpKernel
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\RouteLogs::class,
];
/**
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use App\Models\RouteLog;
use Auth;
// use Location;
class RouteLogs
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
$ip_address = getenv('REMOTE_ADDR');
$url = $request->fullUrl();
$call_metthod = $request->method();
$platform = $request->header('sec-ch-ua-platform');
// dd(\Location::get($ip_address));
$browser = Str::after($request->header('sec-ch-ua'),'Not?A_Brand";v="8", "Chromium";v="108", "');
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$ip_address"));
$longitude = $geo["geoplugin_longitude"];
$latitude = $geo["geoplugin_latitude"];
$last_page = url()->previous();
$countryName = $geo["geoplugin_countryName"];
RouteLog::create([
// 'user_id' => Auth::user()->id,
'user_id' => '1',
'ip_address' => $request->ip(),
'url' => $url,
'call_method'=> $call_metthod,
'browser' => $browser,
'platform' => $platform,
'longitude' =>$longitude,
'latitude' => $latitude,
'last_page' => $last_page,
'countryname' =>$countryName
]);
return $next($request);
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class RouteLog extends Model
{
use HasFactory;
protected $fillable = [
'user_id',
'ip_address',
'url',
'call_method',
'browser',
'platform',
'longitude',
'latitude',
'last_page',
'countryname'
];
}
@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateRouteLogsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('route_logs', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->unsigned();
$table->string('ip_address');
$table->string('url');
$table->string('desc')->nullable();
$table->string('call_method');
$table->string('browser')->nullable();
$table->string('platform')->nullable();
$table->string('longitude');
$table->string('latitude');
$table->string('last_page')->nullable();
$table->string('countryname')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('route_logs');
}
}