Add telescope, fix kemaskini in lelong page

This commit is contained in:
Amir
2023-01-15 09:52:35 +08:00
parent d65279ebe5
commit 11b84bbe62
13 changed files with 477 additions and 5 deletions
+126
View File
@@ -50,6 +50,7 @@ use App\Models\Tetapan;
use App\Models\TransaksiKeuntungan;
use DateTime;
// use Nexmo\Laravel\Facade\Nexmo;
use Illuminate\Support\Facades\DB;
class LelongController extends Controller
{
@@ -939,6 +940,131 @@ class LelongController extends Controller
->with('success','Kemaskini Berjaya');
}
public function kemaskini2(Request $request)
{
/*
read LelKarat, done
create LelKarat_temp, done
update LelKarat, done
read LelongBid, done
read TransaksiKeuntungan - sum keuntungan_rebet, done
read TransaksiKeuntungan - sum bayaran_keuntungan, done
read Gadai, done
read LelongBidMarhun, done
update LelongBidMarhun, done
update LelongBid
create LogUser
update Lelong, done
*/
$currentNow = Carbon::now();
$lel_karats = LelKarat::where('lelong_id', $request->idlelong)->get();
$insert_harga2 = $request->harga2;
$lelkarat_temp_arr = [];
$cases = '';
foreach ($lel_karats as $index => $lel_karat) {
if ($insert_harga2[$index]) {
$lel_karats[$index]['harga_baru'] = $insert_harga2[$index];
}
$lel_karat_temp_to_be_inserted = [
'lelong_id' => $request->idlelong,
'karat' => $lel_karat->karat,
'keterangan' => $lel_karat->keterangan,
'harga' => $lel_karat->harga,
'harga2' => $lel_karat->harga2,
'created_at' => $currentNow,
'updated_at' => $currentNow,
];
array_push($lelkarat_temp_arr, $lel_karat_temp_to_be_inserted);
$cases .= sprintf(' WHEN id = %d THEN %s ', $lel_karat->id, $lel_karat->harga_baru);
}
$build_query = sprintf("CASE %s END", $cases);
// LelKarat_temp::insert($lelkarat_temp_arr);
// LelKarat::query()->where('lelong_id', $request->idlelong)->update(['harga2' => DB::raw($build_query)]);
// Lelong::find($request->idlelong)->update(['harga_emas_asas' => $request->harga2[3]]);
$new_lel_karat = LelKarat::where('lelong_id', $request->idlelong)->select('lelong_id', 'karat', 'harga2')->get()->keyBy('karat');
$lelong_bid = LelongBid::with('lelongBidMarhun')->where('lelong_id', $request->idlelong)->select('id', 'kodcaw', 'norujukan')->get();
/** -------------UPDATE LELONG BID MARHUN------------- */
$list_lelong_bid_marhun = collect();
foreach($lelong_bid as $item)
{
$list_lelong_bid_marhun = $list_lelong_bid_marhun->concat($item->lelongBidMarhun);
}
$cases_update_harga = '';
$cases_update_n_marhun = '';
$cases_update_hargaasas = '';
foreach($list_lelong_bid_marhun as $index => $marhun)
{
if ($new_lel_karat[$marhun->karat])
{
$harga_to_be_inserted = $new_lel_karat[$marhun->karat]->harga2;
$n_marhun_to_be_inserted = $marhun->berat * $new_lel_karat[$marhun->karat]->harga2;
$harga_asas_to_be_inserted = round($marhun->berat * $new_lel_karat[$marhun->karat]->harga2);
$list_lelong_bid_marhun[$index]['new_n_marhun'] = $n_marhun_to_be_inserted;
$list_lelong_bid_marhun[$index]['new_hargaasas'] = $harga_asas_to_be_inserted;
// UPDATE HARGA, N_MARHUN, HARGAASAS
$cases_update_harga .= sprintf(' WHEN id = %d THEN %s ', $marhun->id, $harga_to_be_inserted);
$cases_update_n_marhun .= sprintf(' WHEN id = %d THEN %s ', $marhun->id, $n_marhun_to_be_inserted);
$cases_update_hargaasas .= sprintf(' WHEN id = %d THEN %s ', $marhun->id, $harga_asas_to_be_inserted);
}
}
dd($list_lelong_bid_marhun[100]->toArray());
$build_query_update_harga = sprintf("CASE %s END", $cases_update_harga);
$build_query_update_n_marhun = sprintf("CASE %s END", $cases_update_n_marhun);
$build_query_update_hargaasas = sprintf("CASE %s END", $cases_update_hargaasas);
LelongBidMarhun::query()
->update([
'harga' => DB::raw($build_query_update_harga),
'n_marhun' => DB::raw($build_query_update_n_marhun),
'hargaasas' => DB::raw($build_query_update_hargaasas)
]);
/** -------------UPDATE LELONG BID------------- */
$lelong_bid_group_by_kodcaw = $lelong_bid->groupBy('kodcaw');
$list_gadai = [];
foreach($lelong_bid_group_by_kodcaw as $index => $cawangan)
{
$cawangan = $cawangan->pluck('norujukan');
$detail_gadai = Gadai::on($index)->whereIn('norujukan', $cawangan)->select('norujukan','tempoh', 'tempohbayar')->get();
$list_gadai = array_merge($list_gadai, $detail_gadai->keyBy('norujukan')->toArray());
}
$lelong_bid_pluck_norujukan = $lelong_bid->pluck('norujukan');
$transaksi_keuntungans = TransaksiKeuntungan::whereIn('norujukan', $lelong_bid_pluck_norujukan)->select('norujukan', 'keuntungan_rebet', 'bayaran_keuntungan')->get();
// update bakiupah@keuntungan
// create loguser
// update hargaasas
// update nmarhuns
return redirect()->route('home');
}
public function janapemenang($id){
$current = Carbon::now();
+3 -1
View File
@@ -16,7 +16,9 @@ class LelKarat_temp extends Model
'karat',
'keterangan',
'harga',
'harga2'
'harga2',
'created_at',
'updated_at',
];
}
@@ -0,0 +1,71 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Laravel\Telescope\IncomingEntry;
use Laravel\Telescope\Telescope;
use Laravel\Telescope\TelescopeApplicationServiceProvider;
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
// Telescope::night();
$this->hideSensitiveRequestDetails();
Telescope::filter(function (IncomingEntry $entry) {
if ($this->app->environment('local')) {
return true;
}
return $entry->isReportableException() ||
$entry->isFailedRequest() ||
$entry->isFailedJob() ||
$entry->isScheduledTask() ||
$entry->hasMonitoredTag();
});
}
/**
* Prevent sensitive request details from being logged by Telescope.
*
* @return void
*/
protected function hideSensitiveRequestDetails()
{
if ($this->app->environment('local')) {
return;
}
Telescope::hideRequestParameters(['_token']);
Telescope::hideRequestHeaders([
'cookie',
'x-csrf-token',
'x-xsrf-token',
]);
}
/**
* Register the Telescope gate.
*
* This gate determines who can access Telescope in non-local environments.
*
* @return void
*/
protected function gate()
{
Gate::define('viewTelescope', function ($user) {
return in_array($user->email, [
//
]);
});
}
}
+1
View File
@@ -27,6 +27,7 @@
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"laravel/telescope": "^4.10",
"laravel/ui": "^3.3",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^5.10",
Generated
+70 -2
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b693508e783afdca0b77c2e1dcf8217c",
"content-hash": "4481b3d80b4b9d2176d486f089a4174b",
"packages": [
{
"name": "asm89/stack-cors",
@@ -9197,6 +9197,74 @@
],
"time": "2022-09-28T13:13:22+00:00"
},
{
"name": "laravel/telescope",
"version": "v4.10.2",
"source": {
"type": "git",
"url": "https://github.com/laravel/telescope.git",
"reference": "3b1220b71ee08ac7be6be074635df50c2b83ab51"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/telescope/zipball/3b1220b71ee08ac7be6be074635df50c2b83ab51",
"reference": "3b1220b71ee08ac7be6be074635df50c2b83ab51",
"shasum": ""
},
"require": {
"ext-json": "*",
"laravel/framework": "^8.37|^9.0",
"php": "^7.3|^8.0",
"symfony/var-dumper": "^5.0|^6.0"
},
"require-dev": {
"ext-gd": "*",
"guzzlehttp/guzzle": "^6.0|^7.0",
"orchestra/testbench": "^6.0|^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.x-dev"
},
"laravel": {
"providers": [
"Laravel\\Telescope\\TelescopeServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Laravel\\Telescope\\": "src/",
"Laravel\\Telescope\\Database\\Factories\\": "database/factories/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
},
{
"name": "Mohamed Said",
"email": "mohamed@laravel.com"
}
],
"description": "An elegant debug assistant for the Laravel framework.",
"keywords": [
"debugging",
"laravel",
"monitoring"
],
"support": {
"issues": "https://github.com/laravel/telescope/issues",
"source": "https://github.com/laravel/telescope/tree/v4.10.2"
},
"time": "2022-12-19T11:20:10+00:00"
},
{
"name": "laravel/ui",
"version": "v3.4.6",
@@ -10974,5 +11042,5 @@
"php": "^7.3|^8.0"
},
"platform-dev": [],
"plugin-api-version": "2.0.0"
"plugin-api-version": "2.3.0"
}
+1
View File
@@ -174,6 +174,7 @@ return [
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\TelescopeServiceProvider::class,
Barryvdh\DomPDF\ServiceProvider::class,
//form
+182
View File
@@ -0,0 +1,182 @@
<?php
use Laravel\Telescope\Http\Middleware\Authorize;
use Laravel\Telescope\Watchers;
return [
/*
|--------------------------------------------------------------------------
| Telescope Domain
|--------------------------------------------------------------------------
|
| This is the subdomain where Telescope will be accessible from. If the
| setting is null, Telescope will reside under the same domain as the
| application. Otherwise, this value will be used as the subdomain.
|
*/
'domain' => env('TELESCOPE_DOMAIN', null),
/*
|--------------------------------------------------------------------------
| Telescope Path
|--------------------------------------------------------------------------
|
| This is the URI path where Telescope will be accessible from. Feel free
| to change this path to anything you like. Note that the URI will not
| affect the paths of its internal API that aren't exposed to users.
|
*/
'path' => env('TELESCOPE_PATH', 'telescope'),
/*
|--------------------------------------------------------------------------
| Telescope Storage Driver
|--------------------------------------------------------------------------
|
| This configuration options determines the storage driver that will
| be used to store Telescope's data. In addition, you may set any
| custom options as needed by the particular driver you choose.
|
*/
'driver' => env('TELESCOPE_DRIVER', 'database'),
'storage' => [
'database' => [
'connection' => env('DB_CONNECTION', 'mysql'),
'chunk' => 1000,
],
],
/*
|--------------------------------------------------------------------------
| Telescope Master Switch
|--------------------------------------------------------------------------
|
| This option may be used to disable all Telescope watchers regardless
| of their individual configuration, which simply provides a single
| and convenient way to enable or disable Telescope data storage.
|
*/
'enabled' => env('TELESCOPE_ENABLED', true),
/*
|--------------------------------------------------------------------------
| Telescope Route Middleware
|--------------------------------------------------------------------------
|
| These middleware will be assigned to every Telescope route, giving you
| the chance to add your own middleware to this list or change any of
| the existing middleware. Or, you can simply stick with this list.
|
*/
'middleware' => [
'web',
Authorize::class,
],
/*
|--------------------------------------------------------------------------
| Allowed / Ignored Paths & Commands
|--------------------------------------------------------------------------
|
| The following array lists the URI paths and Artisan commands that will
| not be watched by Telescope. In addition to this list, some Laravel
| commands, like migrations and queue commands, are always ignored.
|
*/
'only_paths' => [
// 'api/*'
],
'ignore_paths' => [
'nova-api*',
],
'ignore_commands' => [
//
],
/*
|--------------------------------------------------------------------------
| Telescope Watchers
|--------------------------------------------------------------------------
|
| The following array lists the "watchers" that will be registered with
| Telescope. The watchers gather the application's profile data when
| a request or task is executed. Feel free to customize this list.
|
*/
'watchers' => [
Watchers\BatchWatcher::class => env('TELESCOPE_BATCH_WATCHER', true),
Watchers\CacheWatcher::class => [
'enabled' => env('TELESCOPE_CACHE_WATCHER', true),
'hidden' => [],
],
Watchers\ClientRequestWatcher::class => env('TELESCOPE_CLIENT_REQUEST_WATCHER', true),
Watchers\CommandWatcher::class => [
'enabled' => env('TELESCOPE_COMMAND_WATCHER', true),
'ignore' => [],
],
Watchers\DumpWatcher::class => [
'enabled' => env('TELESCOPE_DUMP_WATCHER', true),
'always' => env('TELESCOPE_DUMP_WATCHER_ALWAYS', false),
],
Watchers\EventWatcher::class => [
'enabled' => env('TELESCOPE_EVENT_WATCHER', true),
'ignore' => [],
],
Watchers\ExceptionWatcher::class => env('TELESCOPE_EXCEPTION_WATCHER', true),
Watchers\GateWatcher::class => [
'enabled' => env('TELESCOPE_GATE_WATCHER', true),
'ignore_abilities' => [],
'ignore_packages' => true,
'ignore_paths' => [],
],
Watchers\JobWatcher::class => env('TELESCOPE_JOB_WATCHER', true),
Watchers\LogWatcher::class => env('TELESCOPE_LOG_WATCHER', true),
Watchers\MailWatcher::class => env('TELESCOPE_MAIL_WATCHER', true),
Watchers\ModelWatcher::class => [
'enabled' => env('TELESCOPE_MODEL_WATCHER', true),
'events' => ['eloquent.*'],
'hydrations' => true,
],
Watchers\NotificationWatcher::class => env('TELESCOPE_NOTIFICATION_WATCHER', true),
Watchers\QueryWatcher::class => [
'enabled' => env('TELESCOPE_QUERY_WATCHER', true),
'ignore_packages' => true,
'ignore_paths' => [],
'slow' => 100,
],
Watchers\RedisWatcher::class => env('TELESCOPE_REDIS_WATCHER', true),
Watchers\RequestWatcher::class => [
'enabled' => env('TELESCOPE_REQUEST_WATCHER', true),
'size_limit' => env('TELESCOPE_RESPONSE_SIZE_LIMIT', 64),
'ignore_http_methods' => [],
'ignore_status_codes' => [],
],
Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true),
Watchers\ViewWatcher::class => env('TELESCOPE_VIEW_WATCHER', true),
],
];
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

+5
View File
@@ -0,0 +1,5 @@
{
"/app.js": "/app.js?id=08317cb3c83c7035246fe3d474db3454",
"/app-dark.css": "/app-dark.css?id=3ae28ef5f7b987d68dc611118c646308",
"/app.css": "/app.css?id=7c970f699ed9cf60d80b273b4ad2ad61"
}
+2 -2
View File
@@ -76,7 +76,7 @@ Route::group(['middleware' => ['permission:pengguna'],'prefix'=>'pengguna'], fun
Route::group(['middleware' => ['permission:analisa'],'prefix'=>'analisa'], function () {
Route::get('/janasimulasi',['as'=>'analisa.janasimulasi','uses'=>'SimulasiController@index']);
Route::post('/kemaskini',['as'=>'analisa.kemaskiniharga','uses'=>'SimulasiController@kemaskini']);
Route::post('/kemaskini',['as'=>'analisa.kemaskiniharga','uses'=>'SimulasiController@kemaskini']); // FUNCTION NI, 7-JAN-2023
Route::post('/janadata',['as'=>'analisa.janadata','uses'=>'SimulasiController@janadata']);
Route::post('/janadata2',['as'=>'analisa.janadata2','uses'=>'SimulasiController@janadata2']);
Route::get('/pendingdaftarsimulasi',['as'=>'analisa.pendingdaftarsimulasi','uses'=>'SimulasiController@pendingDaftarSimulasi']);
@@ -218,7 +218,7 @@ Route::group(['prefix'=>'lelong'], function () {
});
Route::group(['middleware' => ['permission:kemaskinihargaasas']], function () {
Route::post('/kemaskini',['as'=>'lelong.kemaskinihargaasas','uses'=>'LelongController@kemaskini']);
Route::post('/kemaskini',['as'=>'lelong.kemaskinihargaasas','uses'=>'LelongController@kemaskini2']); // FUNCTION NI, 7-JAN-2023
});
Route::group(['middleware' => ['permission:lelongan']], function () {