Backend parkir - itcn.co.id
This commit is contained in:
32
app/Console/Kernel.php
Normal file
32
app/Console/Kernel.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
41
app/Exceptions/Handler.php
Normal file
41
app/Exceptions/Handler.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
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<int, class-string<Throwable>>
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
63
app/Http/Controllers/Api/V1/ConfigParameter.php
Normal file
63
app/Http/Controllers/Api/V1/ConfigParameter.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\NamaPos;
|
||||
use App\Models\SoftSettings;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ConfigParameter extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
// $query = $request->query('gate');
|
||||
$query = $_GET['gate'] ?? null;
|
||||
|
||||
Log::info('Query Params:', $request->query());
|
||||
Log::info('Gate Param:', [$request->query('gate')]);
|
||||
|
||||
if (!array_key_exists('gate', $_GET)) {
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'desc' => 'Parameter undefined',
|
||||
],400);
|
||||
|
||||
}
|
||||
|
||||
if ($query === '') {
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'desc' => 'Parameter gate tidak boleh kosong',
|
||||
], 400);
|
||||
}
|
||||
|
||||
|
||||
$getLocation = SoftSettings::first();
|
||||
|
||||
$location = [
|
||||
'namaSoftware' => $getLocation->namasoft,
|
||||
'namaSystem' => $getLocation->namasystem,
|
||||
'LocatioName' => $getLocation->namalokasi,
|
||||
'locationAddress' => $getLocation->alamatlokasi ?? 'location Undefined',
|
||||
'CompanyName' => $getLocation->namaperusahaan,
|
||||
'merchantID' => $getLocation->cabang_lokasi,
|
||||
];
|
||||
|
||||
if($query) {
|
||||
$getPos = NamaPos::where('id', $request->query('gate'))->with('posParams','posHardware')->first();
|
||||
$location['gateDetails'] = $getPos;
|
||||
// Log::info($getPos->toSql());
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'details' => $location
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'details' => $location,
|
||||
]);
|
||||
}
|
||||
}
|
||||
314
app/Http/Controllers/Api/V1/TransaksiMember.php
Normal file
314
app/Http/Controllers/Api/V1/TransaksiMember.php
Normal file
@@ -0,0 +1,314 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\CardMember;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class TransaksiMember extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
|
||||
private function getData(Request $request)
|
||||
{
|
||||
// return DB::table('mergetransaksistikerdetail');
|
||||
|
||||
$allowedPath = ['nama', 'nopol','card'];
|
||||
|
||||
foreach ( $request->query() as $key => $value ) {
|
||||
if (!in_array($key, $allowedPath)) {
|
||||
return response()->json([
|
||||
'error' => 'Parameter tidak ditemukan',
|
||||
'suggest' => 'Jangan menebak parameter',
|
||||
'invalid_parameter' => $key,
|
||||
], 400);
|
||||
}
|
||||
|
||||
if (empty($value)) {
|
||||
return response()->json([
|
||||
'error' => 'Nilai parameter tidak dimasukkan',
|
||||
'parameter' => $key,
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
|
||||
$nama = $request->query('nama');
|
||||
$nopol = $request->query('nopol');
|
||||
$card = $request->query('card');
|
||||
|
||||
if (!$nama && !$nopol && !$card) {
|
||||
return response()->json([
|
||||
"application" => [
|
||||
"name" => "Transaksi Stiker",
|
||||
"environment" => env('APP_ENV'),
|
||||
"version" => "v1.0",
|
||||
"author" => "itcn.co.id",
|
||||
"description" => 'make sure your subscription has been renewed :)'
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
$query = DB::table('mergetransaksistikerdetail');
|
||||
|
||||
if ($nama) {
|
||||
$query->where('nama', Str::upper($nama));
|
||||
} elseif ($nopol) {
|
||||
$query->where('nopol', Str::upper($nopol));
|
||||
} elseif ($card) {
|
||||
$notrans = CardMember::where('no_card', $card);
|
||||
// if (!$notrans) {
|
||||
// // return response()->json(['status' => 'failed', 'result' => 'Kartu tidak ditemukan/tidak terdaftar'], 400);
|
||||
// return null;
|
||||
// }
|
||||
$query->where('no_id', $notrans);
|
||||
}
|
||||
|
||||
return $query;
|
||||
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
// $allowedPath = ['nama', 'nopol','card'];
|
||||
|
||||
// foreach ( $request->query() as $key => $value ) {
|
||||
// if (!in_array($key, $allowedPath)) {
|
||||
// return response()->json([
|
||||
// 'error' => 'Parameter tidak ditemukan',
|
||||
// 'suggest' => 'Jangan menebak parameter',
|
||||
// 'invalid_parameter' => $key,
|
||||
// ], 400);
|
||||
// }
|
||||
|
||||
// if (empty($value)) {
|
||||
// return response()->json([
|
||||
// 'error' => 'Nilai parameter tidak dimasukkan',
|
||||
// 'parameter' => $key,
|
||||
// ], 400);
|
||||
// }
|
||||
// }
|
||||
|
||||
// $nama = $request->query('nama');
|
||||
// $nopol = $request->query('nopol');
|
||||
// $card = $request->query('card');
|
||||
|
||||
// if (!$nama && !$nopol && !$card) {
|
||||
// return response()->json([
|
||||
// "application" => [
|
||||
// "name" => "Transaksi Stiker",
|
||||
// "environment" => env('APP_ENV'),
|
||||
// "version" => "v1.0",
|
||||
// "author" => "itcn.co.id",
|
||||
// "description" => 'make sure your subscription has been renewed :)'
|
||||
// ]
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// // $query = DB::table('mergetransaksistikerdetail')
|
||||
|
||||
|
||||
// if ($nama) {
|
||||
// // $query->where('nama', Str::upper($nama));
|
||||
// $query = $this->getData()->where('nama', Str::upper($nama));
|
||||
// }
|
||||
|
||||
// if ($nopol) {
|
||||
// // $query->where('nopol', Str::upper($nopol));
|
||||
// $query = $this->getData()->where('nopol', Str::upper($nopol));
|
||||
// }
|
||||
|
||||
// if ($card) {
|
||||
// // Log::info($card);
|
||||
// // $query->where('nama', Str::upper($nama));
|
||||
// $notrans = CardMember::where('no_card', $card)->first();
|
||||
// Log::info('ketemu : ' .$notrans->notrans);
|
||||
// // $query->where('no_id', $notrans->notrans);
|
||||
// $query = $this->getData()->where('no_id', $notrans->notrans);
|
||||
// }
|
||||
|
||||
// $query = $query
|
||||
// Log::info('Data : yg di cari : ' . $request);
|
||||
$query = $this->getData($request)
|
||||
->whereRaw('? BETWEEN awal AND akhir', [now()])
|
||||
->first();
|
||||
Log::info($query->toSql());
|
||||
|
||||
// Log::info('Data : ' . $query);
|
||||
if ($query) {
|
||||
$today = Carbon::now();
|
||||
$endDate = $query->akhir;
|
||||
$dayCount = $today->diffInDays($endDate);
|
||||
$monthCount = $today->diffInMonths($endDate);
|
||||
$yearCount = $today->diffInYears($endDate);
|
||||
Log::info($query->akhir);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'status_langganan' => 'active',
|
||||
'masa_aktif' => $dayCount . ' Hari.',
|
||||
'result' => $query,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'result' => 'Tidak ditemukan data',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function status (Request $request)
|
||||
{
|
||||
|
||||
// $allowedPath = ['nama', 'nopol','card'];
|
||||
|
||||
// foreach ( $request->query() as $key => $value ) {
|
||||
// if (!in_array($key, $allowedPath)) {
|
||||
// return response()->json([
|
||||
// 'error' => 'Parameter tidak ditemukan',
|
||||
// 'suggest' => 'Jangan menebak parameter',
|
||||
// 'invalid_parameter' => $key,
|
||||
// ], 400);
|
||||
// }
|
||||
|
||||
// if (empty($value)) {
|
||||
// return response()->json([
|
||||
// 'error' => 'Nilai parameter tidak dimasukkan',
|
||||
// 'parameter' => $key,
|
||||
// ], 400);
|
||||
// }
|
||||
// }
|
||||
|
||||
// $nama = $request->query('nama');
|
||||
// $nopol = $request->query('nopol');
|
||||
// $card = $request->query('card');
|
||||
|
||||
// if (!$nama && !$nopol && !$card) {
|
||||
// return response()->json([
|
||||
// "application" => [
|
||||
// "name" => "Transaksi Stiker",
|
||||
// "environment" => env('APP_ENV'),
|
||||
// "version" => "v1.0",
|
||||
// "author" => "itcn.co.id",
|
||||
// "description" => 'make sure your subscription has been renewed :)'
|
||||
// ]
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// if ($nama) {
|
||||
// // $query->where('nama', Str::upper($nama));
|
||||
// $query = $this->getData()->where('nama', Str::upper($nama));
|
||||
// }
|
||||
|
||||
// if ($nopol) {
|
||||
// // $query->where('nopol', Str::upper($nopol));
|
||||
// $query = $this->getData()->where('nopol', Str::upper($nopol));
|
||||
// }
|
||||
|
||||
// if ($card) {
|
||||
// // Log::info($card);
|
||||
// // $query->where('nama', Str::upper($nama));
|
||||
// $notrans = CardMember::where('no_card', $card)->first();
|
||||
// // Log::info('ketemu : ' .$notrans->notrans);
|
||||
// // $query->where('no_id', $notrans->notrans);
|
||||
// $query = $this->getData()->where('no_id', $notrans->notrans);
|
||||
// }
|
||||
|
||||
// $data = $query
|
||||
$data = $this->getData($request)
|
||||
->orderBy('tanggal', 'desc')
|
||||
->get();
|
||||
|
||||
Log::info('Data yg ditemukan : ' . $data);
|
||||
|
||||
if ($data->isNotEmpty()) {
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'result' => $data,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'result' => 'Tidak ditemukan data',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
159
app/Http/Controllers/Api/V1/TransaksiParkir.php
Normal file
159
app/Http/Controllers/Api/V1/TransaksiParkir.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\CardMember;
|
||||
use App\Models\TransaksiParkir as TransPark;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class TransaksiParkir extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = $request->query('find');
|
||||
|
||||
if ($query) {
|
||||
|
||||
$data = $request->query('find');
|
||||
Log::info($data);
|
||||
|
||||
$card = CardMember::where('no_card', Str::upper($data))->first();
|
||||
|
||||
if (!$card) {
|
||||
$trans = TransPark::where('no_pol', Str::upper($data))->where('status', 1)->first();
|
||||
|
||||
if ($trans) {
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'desc' => 'Nomor Polisi/Kartu masih di dalam'
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
Log::info($card);
|
||||
$validMember = DB::table('mergetransaksistikerdetail')->where('no_id', $card->notrans)->first();
|
||||
if (!$validMember) {
|
||||
return response()->json([
|
||||
'status' => 'ok'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'desc' => 'Tidak ditemukan data'
|
||||
]);
|
||||
|
||||
} else {
|
||||
return response()->json([
|
||||
'status' => 'failed',
|
||||
'desc' => 'parameter tidak ditemukan'
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
Log::info($request->no_pol);
|
||||
$gateID = $request->id_pintu_masuk ?? '00';
|
||||
$dateNow = Carbon::now()->format('Y-m-d H:i:s');
|
||||
$idTrans = TransPark::select('id')->orderBy('id', 'desc')->first();
|
||||
if (!$idTrans) {
|
||||
$newTrans = 0;
|
||||
} else {
|
||||
Log::info('data sebelumnya ' . $idTrans->id);
|
||||
$newTrans = $idTrans->id + 1;
|
||||
Log::info('setelah dijumlah ' . $newTrans);
|
||||
}
|
||||
$trans = str_pad($newTrans, 4, '0', STR_PAD_LEFT);
|
||||
Log::info($newTrans);
|
||||
|
||||
Log::info('Tanggal hari ini : ' . $dateNow);
|
||||
$transaksi = TransPark::create([
|
||||
'id' => $gateID . $trans,
|
||||
'no_pol' => $request->no_pol ?? $gateID . $trans . Carbon::now()->format('YmdHis'),
|
||||
'id_kendaraan' => 'A',
|
||||
'id_pintu_masuk' => $request->id_pintu_masuk ?? $gateID,
|
||||
'status' => 1,
|
||||
'status_transaksi' => $request->status_transaksi,
|
||||
'waktu_masuk' => $request->waktu_masuk ?? $dateNow,
|
||||
'tanggal' => $request->waktu_masuk ?? $dateNow,
|
||||
]);
|
||||
|
||||
return $transaksi;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
13
app/Http/Controllers/Controller.php
Normal file
13
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
67
app/Http/Kernel.php
Normal file
67
app/Http/Kernel.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Fruitcake\Cors\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
'throttle:api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
];
|
||||
}
|
||||
21
app/Http/Middleware/Authenticate.php
Normal file
21
app/Http/Middleware/Authenticate.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string|null
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('login');
|
||||
}
|
||||
}
|
||||
}
|
||||
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
32
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
32
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @param string|null ...$guards
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ...$guards)
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
19
app/Http/Middleware/TrimStrings.php
Normal file
19
app/Http/Middleware/TrimStrings.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
||||
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts()
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Middleware/TrustProxies.php
Normal file
28
app/Http/Middleware/TrustProxies.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
||||
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
23
app/Models/CardMember.php
Normal file
23
app/Models/CardMember.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class CardMember extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'card_member';
|
||||
|
||||
protected $fillable = [
|
||||
'notrans','no_card','no_urut','tanggal','adm','trans_id','harga'
|
||||
];
|
||||
|
||||
public function stiker ()
|
||||
{
|
||||
return $this->BelongsTo(TransaksiStiker::class, 'notrans', 'no_id');
|
||||
}
|
||||
}
|
||||
32
app/Models/ConfigHardware.php
Normal file
32
app/Models/ConfigHardware.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ConfigHardware extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'config_pos_hardware';
|
||||
|
||||
protected $fillable = [
|
||||
'printer1_avail','printer1_conn','printer1_spd','printer1_stdfile','printer1_autocutter','printer1_bgconnect',
|
||||
'printer1_dummy','video1_avail','video1_conn','video1_channel','video1_version','feedisplay_avail',
|
||||
'feedisplay_conn','feedisplay_paralel','feedisplay_version','bg_avail',' bg_conn ','bg_paralel','bg_value',
|
||||
'sound_avail','sound_conn','sound_version','sound_partisi','id_pos','sizeable','pjg_lcd','video1_bright',
|
||||
'video2_avail','video2_conn','video2_channel','video2_version','video2_bright','video2_sizeable','smartcard_avail',
|
||||
'smartcard_speed','smartcard_port','printer2_avail','printer2_conn','printer2_spd','printer2_stdfile','printer2_autocutter',
|
||||
'printer2_bgconnect','printer2_dummy','bg_usb','fan1_maxval','fan2_maxval','temp1_maxval','temp2_maxval','sensor_fan1',
|
||||
'sensor_fan2','sensor_temp1','sensor_temp2','bg_type','video3_avail','video3_conn','video3_channel','video3_version',
|
||||
'video3_bright','video3_sizeale','bank_reader_avail','bank_reader_comm','mandiri_sam_pin','mandiri_reader_tid',
|
||||
'mandiri_reader_mid','bca_reader_tid','bca_reader_mid','bca_batch','bank_reader_tid','bank_reader_mid','bank_reader_key',
|
||||
'bni_tid','bni_mid','lpr_ip','lpr_avail','qrisdisp_avail','qrisdisp_speed','qrisdisp_port'
|
||||
];
|
||||
|
||||
public function posHardware()
|
||||
{
|
||||
return $this->belongsTo(NamaPos::class, 'id_pos','id');
|
||||
}
|
||||
}
|
||||
30
app/Models/ConfigPos.php
Normal file
30
app/Models/ConfigPos.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ConfigPos extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'config_pos';
|
||||
|
||||
protected $fillable = [
|
||||
'prefix','max_load_index','camera_refresh','max_nopol_avail','max_nopol','max_member_on_a_time','message',
|
||||
'info_member','ploting','info_volume','login_a_time','tiket_masalah','use_barcode','warning_member',
|
||||
'start_warning_member','add_barcode_struk_in','type_barcode_struk_in','input_kode_pisah','cek_mobil_masalah',
|
||||
'overwrite','no_reinput','pos_for_any_kode','any_kode','confirm_input','akses_for_reprint','no_input_notrans',
|
||||
'only_input_any_digit','any_digit','input_notrans_only_open_gate','max_input_notrans','max_input_notrans_value',
|
||||
'autoprint_struk','reprint_struk_activ','no_reinput_out','id_pos','shortcut_kode','footer1','footer2','cetak_tambahan',
|
||||
'ouc','ouc_tipe_barcode','footer3','footer4','kend_valid','swapable','id_pos_alternative','manual_bg_enable','soe',
|
||||
'lbi','falidasi_instant','print_total_nol','iuc','vericode_unix','limit_validasi','form_denda','customer_counter',
|
||||
'disable_manual','enable_icmp','show_print_counter','detail_muatan','debug_window','lobby_mode'
|
||||
];
|
||||
|
||||
public function posParams()
|
||||
{
|
||||
return $this->belongsTo(NamaPos::class, 'id_pos','id');
|
||||
}
|
||||
}
|
||||
11
app/Models/DetailTransaksiStiker.php
Normal file
11
app/Models/DetailTransaksiStiker.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DetailTransaksiStiker extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
11
app/Models/MergeTransaksiStikerDetail.php
Normal file
11
app/Models/MergeTransaksiStikerDetail.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MergeTransaksiStikerDetail extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
28
app/Models/NamaPos.php
Normal file
28
app/Models/NamaPos.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class NamaPos extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'nama_pos';
|
||||
protected $primaryKey = 'id';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'id','nama','jenis','tanggal','lokasi','grace_period','manless','area'
|
||||
];
|
||||
|
||||
public function posParams() {
|
||||
return $this->hasOne(ConfigPos::class, 'id_pos', 'id');
|
||||
}
|
||||
|
||||
public function posHardware() {
|
||||
return $this->hasOne(ConfigHardware::class, 'id_pos', 'id');
|
||||
}
|
||||
}
|
||||
20
app/Models/SoftSettings.php
Normal file
20
app/Models/SoftSettings.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SoftSettings extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'softseting';
|
||||
|
||||
protected $fillable = [
|
||||
'namasoft','versoft','namasystem','versystem','namaperusahaan','alamat','telepon','namalokasi',
|
||||
'alamatlokasi','softplatform','lisensi','period','tipesoft','banyakclient','logo','tanggal','parkintf',
|
||||
'npwp','nppkp','smson','mail_name','mail_address','incom_mail','out_mail','pasw_mail','stok_awal',
|
||||
'stok_kunci','cabang_lokasi','izin'
|
||||
];
|
||||
}
|
||||
25
app/Models/TransaksiParkir.php
Normal file
25
app/Models/TransaksiParkir.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TransaksiParkir extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'transaksi_parkir';
|
||||
|
||||
protected $fillable = [
|
||||
'id','no_pol','id_kendaraan','status','id_pintu_masuk','id_pintu_keluar','waktu_masuk','waktu_keluar','id_op_masuk','id_op_keluar','id_shift_masuk',
|
||||
'id_shift_keluar','kategori','status_transaksi','bayar_masuk','bayar_keluar','jenis_system','tanggal','pic_body_masuk','pic_body_keluar',
|
||||
'pic_driver_masuk','pic_driver_keluar','pic_no_pol_masuk','pic_no_pol_keluar','sinkron','adm','alasan','pmlogin','pklogin','upload','manual',
|
||||
'veri_kode','veri_check','veri_adm','veri_date','denda','extra_bayar','no_barcode','jenis_langganan','post_pay','reff_kode','valet_adm','waktu_valet',
|
||||
'valet_charge','valet_ops','valet_nopol','login_waktu_valet','cara_bayar','unit_member','reserved','no_voucher','seri_voucher','no_access_in',
|
||||
'no_access_out','inap','seq_in','seq_out','rep_has_settle','rep_content','rep_bank','no_kartu','card_bank','tid_bank','saldo','balance',
|
||||
'refference_id_settlement','reffrence_id_settlement','mid_bank','veri_time','has_update','tgl_update','operator'
|
||||
];
|
||||
|
||||
public $timestamps = false;
|
||||
}
|
||||
11
app/Models/TransaksiStiker.php
Normal file
11
app/Models/TransaksiStiker.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TransaksiStiker extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
44
app/Models/User.php
Normal file
44
app/Models/User.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
11
app/Models/keyallow.php
Normal file
11
app/Models/keyallow.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class keyallow extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
28
app/Providers/AppServiceProvider.php
Normal file
28
app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
30
app/Providers/AuthServiceProvider.php
Normal file
30
app/Providers/AuthServiceProvider.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
21
app/Providers/BroadcastServiceProvider.php
Normal file
21
app/Providers/BroadcastServiceProvider.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
32
app/Providers/EventServiceProvider.php
Normal file
32
app/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event listener mappings for the application.
|
||||
*
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
63
app/Providers/RouteServiceProvider.php
Normal file
63
app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* This is used by Laravel authentication to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/home';
|
||||
|
||||
/**
|
||||
* The controller namespace for the application.
|
||||
*
|
||||
* When present, controller route declarations will automatically be prefixed with this namespace.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
// protected $namespace = 'App\\Http\\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->configureRateLimiting();
|
||||
|
||||
$this->routes(function () {
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the rate limiters for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configureRateLimiting()
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user