mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-22 14:04:06 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 569a22c0db |
@@ -22,6 +22,7 @@ class Kernel extends HttpKernel
|
|||||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||||
\App\Http\Middleware\TrimStrings::class,
|
\App\Http\Middleware\TrimStrings::class,
|
||||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||||
|
\App\Http\Middleware\RouteLogs::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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');
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user