From 4138f22f0d4e106a775b1685abd3c104cfdb717d Mon Sep 17 00:00:00 2001 From: Aji Kamaludin Date: Thu, 8 Jun 2023 11:17:27 +0700 Subject: [PATCH] bug fix import voucher update --- .../Api/NotificationController.php | 4 +- app/Http/Controllers/CoinRewardController.php | 2 +- .../Controllers/Customer/AuthController.php | 8 ++-- .../Controllers/Customer/CartController.php | 13 +++---- .../Controllers/Customer/CoinController.php | 1 - .../Customer/CoinExchangeController.php | 5 +-- .../Customer/DepositController.php | 2 +- .../Controllers/Customer/HomeController.php | 2 +- .../Customer/ProfileController.php | 2 +- .../Customer/TransactionController.php | 2 +- app/Http/Controllers/CustomerController.php | 6 +-- app/Http/Controllers/GeneralController.php | 2 +- .../Controllers/NotificationController.php | 1 - .../Controllers/VerificationController.php | 8 ++-- app/Http/Controllers/VoucherController.php | 38 ++++++++++--------- app/Models/CoinHistory.php | 1 - app/Models/Customer.php | 9 +++-- app/Models/CustomerRefferal.php | 2 +- app/Models/DepositHistory.php | 14 +++---- app/Models/Notification.php | 3 +- app/Models/PaylaterHistory.php | 4 +- app/Models/Sale.php | 11 +++--- app/Models/SaleItem.php | 6 +-- app/Models/Voucher.php | 14 ++++--- config/laradumps.php | 32 ++++++++-------- database/seeders/DummySeeder.php | 4 +- routes/admin.php | 4 +- routes/api.php | 4 +- routes/web.php | 3 +- 29 files changed, 104 insertions(+), 103 deletions(-) diff --git a/app/Http/Controllers/Api/NotificationController.php b/app/Http/Controllers/Api/NotificationController.php index 8e9c15e..321c9cc 100644 --- a/app/Http/Controllers/Api/NotificationController.php +++ b/app/Http/Controllers/Api/NotificationController.php @@ -4,14 +4,14 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; use App\Models\Notification; -use Illuminate\Http\Request; class NotificationController extends Controller { public function update(Notification $notif) { if ($notif->id == null) { - (new Notification())->mark_all_as_read(); + (new Notification)->mark_all_as_read(); + return; } $notif->mark_as_read(); diff --git a/app/Http/Controllers/CoinRewardController.php b/app/Http/Controllers/CoinRewardController.php index 99aa06a..f9c3248 100644 --- a/app/Http/Controllers/CoinRewardController.php +++ b/app/Http/Controllers/CoinRewardController.php @@ -15,7 +15,7 @@ class CoinRewardController extends Controller return inertia('CoinReward/Index', [ 'query' => $query->paginate(), - 'levels' => CustomerLevel::all() + 'levels' => CustomerLevel::all(), ]); } diff --git a/app/Http/Controllers/Customer/AuthController.php b/app/Http/Controllers/Customer/AuthController.php index c978f05..9f96e03 100644 --- a/app/Http/Controllers/Customer/AuthController.php +++ b/app/Http/Controllers/Customer/AuthController.php @@ -71,7 +71,7 @@ class AuthController extends Controller 'fullname' => $user->name, 'name' => $user->nickname, 'email' => $user->email, - 'username' => Str::slug($user->name . '_' . Str::random(5), '_'), + 'username' => Str::slug($user->name.'_'.Str::random(5), '_'), 'google_id' => $user->id, 'google_oauth_response' => json_encode($user), ]); @@ -97,7 +97,7 @@ class AuthController extends Controller 'phone' => 'required|numeric', 'username' => 'required|string|min:5|alpha_dash|unique:customers,username', 'password' => 'required|string|min:8|confirmed', - 'referral_code' => 'nullable|exists:customers,referral_code' + 'referral_code' => 'nullable|exists:customers,referral_code', ]); DB::beginTransaction(); @@ -114,7 +114,7 @@ class AuthController extends Controller $refferal = Customer::where('referral_code', $request->referral_code)->first(); $refferal->customerRefferals()->create([ 'refferal_id' => $customer->id, - 'customer_code' => $refferal->referral_code + 'customer_code' => $refferal->referral_code, ]); $affilateEnabled = Setting::getByKey('AFFILATE_ENABLED'); @@ -122,7 +122,7 @@ class AuthController extends Controller $bonusCoin = Setting::getByKey('AFFILATE_COIN_AMOUNT'); $coin = $refferal->coins()->create([ 'debit' => $bonusCoin, - 'description' => 'Bonus Refferal #' . Str::random(5), + 'description' => 'Bonus Refferal #'.Str::random(5), ]); $coin->update_customer_balance(); diff --git a/app/Http/Controllers/Customer/CartController.php b/app/Http/Controllers/Customer/CartController.php index c82fadd..51a4e61 100644 --- a/app/Http/Controllers/Customer/CartController.php +++ b/app/Http/Controllers/Customer/CartController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers\Customer; use App\Http\Controllers\Controller; -use App\Models\CoinHistory; use App\Models\CoinReward; use App\Models\Customer; use App\Models\DepositHistory; @@ -19,7 +18,6 @@ class CartController extends Controller * show list of item in cart * has payed button * show payment method -> deposit, coin, paylater - * */ public function index() { @@ -41,7 +39,6 @@ class CartController extends Controller /** * handle cart add, remove or sub - * */ public function store(Request $request, Voucher $voucher) { @@ -113,10 +110,11 @@ class CartController extends Controller $batchCount = $item['voucher']->count_unsold(); if ($batchCount < $item['quantity']) { session()->remove('carts'); + return redirect()->route('home.index') ->with('message', ['type' => 'error', 'message' => 'transaksi gagal, voucher sedang tidak tersedia']); } - }; + } $total = $carts->sum(function ($item) { return $item['quantity'] * $item['voucher']->validate_price; @@ -127,6 +125,7 @@ class CartController extends Controller $paylater_limit = (int) $customer->paylater_limit; if (($paylater_limit + $customer->deposit_balance) < $total) { session()->remove('carts'); + return redirect()->route('home.index') ->with('message', ['type' => 'error', 'message' => 'transaksi gagal, pembayaran ditolak']); } @@ -167,13 +166,13 @@ class CartController extends Controller if ($bonus != null) { $coin = $customer->coins()->create([ 'debit' => $bonus->bonus_coin, - 'description' => 'Bonus Pembelian #' . $sale->code, + 'description' => 'Bonus Pembelian #'.$sale->code, ]); $coin->update_customer_balance(); } - $description = 'Pembayaran #' . $sale->code; + $description = 'Pembayaran #'.$sale->code; if ($customer->deposit_balance < $total) { if ($customer->deposit_balance > 0) { @@ -191,7 +190,7 @@ class CartController extends Controller $payedWithPaylater = $total - $customer->deposit_balance; $paylater = $customer->paylaterHistories()->create([ 'debit' => $payedWithPaylater, - 'description' => $description + 'description' => $description, ]); $paylater->update_customer_paylater(); diff --git a/app/Http/Controllers/Customer/CoinController.php b/app/Http/Controllers/Customer/CoinController.php index 900c02e..3e1861b 100644 --- a/app/Http/Controllers/Customer/CoinController.php +++ b/app/Http/Controllers/Customer/CoinController.php @@ -4,7 +4,6 @@ namespace App\Http\Controllers\Customer; use App\Http\Controllers\Controller; use App\Models\CoinHistory; -use Illuminate\Http\Request; class CoinController extends Controller { diff --git a/app/Http/Controllers/Customer/CoinExchangeController.php b/app/Http/Controllers/Customer/CoinExchangeController.php index 90fb111..9d3e581 100644 --- a/app/Http/Controllers/Customer/CoinExchangeController.php +++ b/app/Http/Controllers/Customer/CoinExchangeController.php @@ -9,7 +9,6 @@ use App\Models\Sale; use App\Models\Voucher; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; -use Illuminate\Support\Str; class CoinExchangeController extends Controller { @@ -53,7 +52,7 @@ class CoinExchangeController extends Controller DB::beginTransaction(); $sale = $customer->sales()->create([ - 'code' => 'Tukar Coin ' . str()->upper(str()->random(5)), + 'code' => 'Tukar Coin '.str()->upper(str()->random(5)), 'date_time' => now(), 'amount' => 0, 'payed_with' => Sale::PAYED_WITH_COIN, @@ -68,7 +67,7 @@ class CoinExchangeController extends Controller 'additional_info_json' => json_encode([ 'id' => $voucher->id, 'quantity' => 1, - 'voucher' => $voucher->load(['location']) + 'voucher' => $voucher->load(['location']), ]), ]); diff --git a/app/Http/Controllers/Customer/DepositController.php b/app/Http/Controllers/Customer/DepositController.php index 3c9925c..512dd52 100644 --- a/app/Http/Controllers/Customer/DepositController.php +++ b/app/Http/Controllers/Customer/DepositController.php @@ -48,7 +48,7 @@ class DepositController extends Controller $deposit = DepositHistory::make([ 'customer_id' => auth()->id(), 'debit' => $request->amount, - 'description' => 'Top Up #' . Str::random(5), + 'description' => 'Top Up #'.Str::random(5), 'payment_channel' => $request->payment, ]); diff --git a/app/Http/Controllers/Customer/HomeController.php b/app/Http/Controllers/Customer/HomeController.php index c852eed..9ed4527 100644 --- a/app/Http/Controllers/Customer/HomeController.php +++ b/app/Http/Controllers/Customer/HomeController.php @@ -47,7 +47,7 @@ class HomeController extends Controller Notification::where('entity_id', auth()->id())->where('is_read', Notification::UNREAD)->update(['is_read' => Notification::READ]); return inertia('Index/Notification', [ - 'notification' => Notification::where('entity_id', auth()->id())->orderBy('created_at', 'desc')->paginate() + 'notification' => Notification::where('entity_id', auth()->id())->orderBy('created_at', 'desc')->paginate(), ]); } } diff --git a/app/Http/Controllers/Customer/ProfileController.php b/app/Http/Controllers/Customer/ProfileController.php index c4035f3..ed709ca 100644 --- a/app/Http/Controllers/Customer/ProfileController.php +++ b/app/Http/Controllers/Customer/ProfileController.php @@ -26,7 +26,7 @@ class ProfileController extends Controller 'name' => 'string|required', 'address' => 'string|required', 'phone' => 'string|required|numeric', - 'username' => 'string|required|min:5|alpha_dash|unique:customers,username,' . $customer->id, + 'username' => 'string|required|min:5|alpha_dash|unique:customers,username,'.$customer->id, 'password' => 'nullable|string|min:8|confirmed', 'image' => 'nullable|image', ]); diff --git a/app/Http/Controllers/Customer/TransactionController.php b/app/Http/Controllers/Customer/TransactionController.php index 943786e..7377c95 100644 --- a/app/Http/Controllers/Customer/TransactionController.php +++ b/app/Http/Controllers/Customer/TransactionController.php @@ -20,7 +20,7 @@ class TransactionController extends Controller public function show(Sale $sale) { return inertia('Trx/Detail', [ - 'sale' => $sale->load(['items.voucher.location']) + 'sale' => $sale->load(['items.voucher.location']), ]); } } diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index 1b80398..3f870d4 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -59,14 +59,14 @@ class CustomerController extends Controller { return inertia('Customer/Form', [ 'customer' => $customer->load(['level']), - 'levels' => CustomerLevel::all() + 'levels' => CustomerLevel::all(), ]); } public function update(Request $request, Customer $customer) { $request->validate([ - 'username' => 'required|string|min:5|alpha_dash|unique:customers,username,' . $customer->id, + 'username' => 'required|string|min:5|alpha_dash|unique:customers,username,'.$customer->id, 'password' => 'nullable|string|min:8', 'name' => 'required|string', 'fullname' => 'required|string', @@ -121,7 +121,7 @@ class CustomerController extends Controller $customer->paylater()->updateOrCreate([ 'customer_id' => $customer->id, ], [ - 'limit' => $request->paylater_limit + 'limit' => $request->paylater_limit, ]); return redirect()->route('customer.index') diff --git a/app/Http/Controllers/GeneralController.php b/app/Http/Controllers/GeneralController.php index 297e994..adb97db 100644 --- a/app/Http/Controllers/GeneralController.php +++ b/app/Http/Controllers/GeneralController.php @@ -66,7 +66,7 @@ class GeneralController extends Controller ->orderBy('date_time', 'asc') ->groupBy(DB::raw("strftime('%m/%d/%Y', date_time)")); - // filter lokasi + // filter lokasi if ($request->location_id != '') { $charts->whereHas('items', function ($q) use ($request) { $q->join('vouchers', 'vouchers.id', '=', 'sale_items.entity_id') diff --git a/app/Http/Controllers/NotificationController.php b/app/Http/Controllers/NotificationController.php index 77dc325..49a295f 100644 --- a/app/Http/Controllers/NotificationController.php +++ b/app/Http/Controllers/NotificationController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers; use App\Models\Notification; -use Illuminate\Http\Request; class NotificationController extends Controller { diff --git a/app/Http/Controllers/VerificationController.php b/app/Http/Controllers/VerificationController.php index e0a23b9..ec41881 100644 --- a/app/Http/Controllers/VerificationController.php +++ b/app/Http/Controllers/VerificationController.php @@ -15,7 +15,7 @@ class VerificationController extends Controller ->orderBy('updated_at', 'desc'); return inertia('Verification/Index', [ - 'query' => $query->paginate() + 'query' => $query->paginate(), ]); } @@ -28,7 +28,7 @@ class VerificationController extends Controller return inertia('Verification/Form', [ 'customer' => $customer->load(['level']), - 'levels' => $levels + 'levels' => $levels, ]); } @@ -43,13 +43,13 @@ class VerificationController extends Controller $customer->update([ 'customer_level_id' => $level->id, - 'identity_verified' => Customer::VERIFIED + 'identity_verified' => Customer::VERIFIED, ]); $customer->paylater()->updateOrCreate([ 'customer_id' => $customer->id, ], [ - 'limit' => $request->paylater_limit + 'limit' => $request->paylater_limit, ]); return redirect()->route('customer-verification.index') diff --git a/app/Http/Controllers/VoucherController.php b/app/Http/Controllers/VoucherController.php index c896f4a..641bad9 100644 --- a/app/Http/Controllers/VoucherController.php +++ b/app/Http/Controllers/VoucherController.php @@ -33,7 +33,7 @@ class VoucherController extends Controller public function create() { return inertia('Voucher/Form', [ - 'levels' => CustomerLevel::all() + 'levels' => CustomerLevel::all(), ]); } @@ -55,7 +55,7 @@ class VoucherController extends Controller 'expired_unit' => 'required|string', 'prices' => 'nullable|array', 'prices.*.customer_level_id' => 'required|exists:customer_levels,id', - 'prices.*.display_price' => 'required|numeric' + 'prices.*.display_price' => 'required|numeric', ]); DB::beginTransaction(); @@ -96,7 +96,7 @@ class VoucherController extends Controller { return inertia('Voucher/Form', [ 'voucher' => $voucher->load(['prices.level']), - 'levels' => CustomerLevel::all() + 'levels' => CustomerLevel::all(), ]); } @@ -118,11 +118,13 @@ class VoucherController extends Controller 'expired_unit' => 'required|string', 'prices' => 'nullable|array', 'prices.*.customer_level_id' => 'required|exists:customer_levels,id', - 'prices.*.display_price' => 'required|numeric' + 'prices.*.display_price' => 'required|numeric', ]); DB::beginTransaction(); - $voucher->update([ + + $vouchers = Voucher::where('batch_id', $voucher->batch_id); + $vouchers->update([ 'name' => $request->name, 'description' => $request->description, 'location_id' => $request->location_id, @@ -137,17 +139,19 @@ class VoucherController extends Controller 'expired' => $request->expired, ]); - $voucher->prices()->delete(); - foreach (collect($request->prices) as $price) { - $finalPrice = $price['display_price']; - if ($voucher->discount > 0) { - $finalPrice = $finalPrice - round($finalPrice * ($voucher->discount / 100), 2); + foreach ($vouchers->get() as $voucher) { + $voucher->prices()->delete(); + foreach (collect($request->prices) as $price) { + $finalPrice = $price['display_price']; + if ($voucher->discount > 0) { + $finalPrice = $finalPrice - round($finalPrice * ($voucher->discount / 100), 2); + } + $voucher->prices()->create([ + 'customer_level_id' => $price['customer_level_id'], + 'price' => $finalPrice, + 'display_price' => $price['display_price'], + ]); } - $voucher->prices()->create([ - 'customer_level_id' => $price['customer_level_id'], - 'price' => $finalPrice, - 'display_price' => $price['display_price'], - ]); } DB::commit(); @@ -166,7 +170,7 @@ class VoucherController extends Controller public function form_import() { return inertia('Voucher/Import', [ - 'levels' => CustomerLevel::all() + 'levels' => CustomerLevel::all(), ]); } @@ -182,7 +186,7 @@ class VoucherController extends Controller 'expired_unit' => 'required|string', 'prices' => 'nullable|array', 'prices.*.customer_level_id' => 'required|exists:customer_levels,id', - 'prices.*.display_price' => 'required|numeric' + 'prices.*.display_price' => 'required|numeric', ]); $batchId = Str::ulid(); diff --git a/app/Models/CoinHistory.php b/app/Models/CoinHistory.php index 8ba3a9f..3578029 100644 --- a/app/Models/CoinHistory.php +++ b/app/Models/CoinHistory.php @@ -36,7 +36,6 @@ class CoinHistory extends Model }); } - public function amount(): Attribute { return Attribute::make(get: function () { diff --git a/app/Models/Customer.php b/app/Models/Customer.php index 75ca6a2..2ac9e6a 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -126,7 +126,7 @@ class Customer extends Authenticatable return ' - '; } - return '+62' . $this->phone; + return '+62'.$this->phone; }); } @@ -150,6 +150,7 @@ class Customer extends Authenticatable if ($this->is_allow_paylater) { return $this->paylater->limit - $this->paylater->usage; } + return ''; }); } @@ -167,7 +168,7 @@ class Customer extends Authenticatable return [ self::VERIFIED => 'Terverifikasi', self::IN_VERICATION => 'Menunggu Verifikasi', - self::NOT_VERIFIED => 'Tidak Terverifikasi' + self::NOT_VERIFIED => 'Tidak Terverifikasi', ][$this->identity_verified]; }); } @@ -233,13 +234,13 @@ class Customer extends Authenticatable $paylater = $this->paylaterHistories()->create([ 'credit' => $cut, - 'description' => $deposit->description . " (Pengembalian)", + 'description' => $deposit->description.' (Pengembalian)', ]); $paylater->update_customer_paylater(); $deposit = $this->deposites()->create([ 'credit' => $cut, - 'description' => 'Pembayaran Paylater' + 'description' => 'Pembayaran Paylater', ]); $deposit->update_customer_balance(); } diff --git a/app/Models/CustomerRefferal.php b/app/Models/CustomerRefferal.php index 9da6a2b..b2d0718 100644 --- a/app/Models/CustomerRefferal.php +++ b/app/Models/CustomerRefferal.php @@ -6,7 +6,7 @@ class CustomerRefferal extends Model { protected $fillable = [ 'customer_id', //customer has code - 'refferal_id', //customer use the code + 'refferal_id', //customer use the code 'customer_code', //code of referal ]; } diff --git a/app/Models/DepositHistory.php b/app/Models/DepositHistory.php index 65d8efa..31fd35b 100644 --- a/app/Models/DepositHistory.php +++ b/app/Models/DepositHistory.php @@ -76,10 +76,10 @@ class DepositHistory extends Model { return Attribute::make(get: function () { if ($this->credit == 0) { - return 'Rp' . number_format($this->debit, is_float($this->debit) ? 2 : 0, ',', '.'); + return 'Rp'.number_format($this->debit, is_float($this->debit) ? 2 : 0, ',', '.'); } - return '-Rp' . number_format($this->credit, is_float($this->credit) ? 2 : 0, ',', '.'); + return '-Rp'.number_format($this->credit, is_float($this->credit) ? 2 : 0, ',', '.'); }); } @@ -109,20 +109,20 @@ class DepositHistory extends Model public function create_notification() { if ($this->payment_channel == Setting::PAYMENT_MANUAL) { - $status = ""; + $status = ''; if ($this->is_valid == self::STATUS_WAIT_APPROVE) { - $status = " (bukti bayar di upload, membutuhkan konfirmasi)"; + $status = ' (bukti bayar di upload, membutuhkan konfirmasi)'; } Notification::create([ 'entity_type' => User::class, - 'description' => $this->customer->fullname . ' melakukan deposit manual sebesar : ' . $this->amount . $status, + 'description' => $this->customer->fullname.' melakukan deposit manual sebesar : '.$this->amount.$status, ]); } if ($this->payment_channel == Setting::PAYMENT_MIDTRANS) { Notification::create([ 'entity_type' => User::class, - 'description' => $this->customer->fullname . ' melakukan deposit via midtrans sebesar : ' . $this->amount, + 'description' => $this->customer->fullname.' melakukan deposit via midtrans sebesar : '.$this->amount, ]); } } @@ -131,7 +131,7 @@ class DepositHistory extends Model { Notification::create([ 'entity_id' => $this->customer_id, - 'description' => 'Deposit ' . $this->description . ' sebesar ' . $this->amount . ' sudah sukses diterima', + 'description' => 'Deposit '.$this->description.' sebesar '.$this->amount.' sudah sukses diterima', ]); } } diff --git a/app/Models/Notification.php b/app/Models/Notification.php index bef61c6..f120cc1 100644 --- a/app/Models/Notification.php +++ b/app/Models/Notification.php @@ -8,6 +8,7 @@ use Illuminate\Support\Carbon; class Notification extends Model { const UNREAD = 0; + const READ = 1; protected $fillable = [ @@ -18,7 +19,7 @@ class Notification extends Model ]; protected $appends = [ - 'format_created_at' + 'format_created_at', ]; public function mark_as_read() diff --git a/app/Models/PaylaterHistory.php b/app/Models/PaylaterHistory.php index b38a021..27b4fc6 100644 --- a/app/Models/PaylaterHistory.php +++ b/app/Models/PaylaterHistory.php @@ -45,10 +45,10 @@ class PaylaterHistory extends Model { return Attribute::make(get: function () { if ($this->credit == 0) { - return 'Rp' . number_format($this->debit, is_float($this->debit) ? 2 : 0, ',', '.'); + return 'Rp'.number_format($this->debit, is_float($this->debit) ? 2 : 0, ',', '.'); } - return '-Rp' . number_format($this->credit, is_float($this->credit) ? 2 : 0, ',', '.'); + return '-Rp'.number_format($this->credit, is_float($this->credit) ? 2 : 0, ',', '.'); }); } } diff --git a/app/Models/Sale.php b/app/Models/Sale.php index bec0d5e..8017575 100644 --- a/app/Models/Sale.php +++ b/app/Models/Sale.php @@ -30,7 +30,6 @@ class Sale extends Model 'payment_type', ]; - protected $appends = [ 'format_human_created_at', 'format_created_at', @@ -64,7 +63,7 @@ class Sale extends Model public function displayAmount(): Attribute { return Attribute::make(get: function () { - return 'Rp' . number_format($this->amount, is_float($this->amount) ? 2 : 0, ',', '.'); + return 'Rp'.number_format($this->amount, is_float($this->amount) ? 2 : 0, ',', '.'); }); } @@ -73,12 +72,12 @@ class Sale extends Model if ($this->payed_with == self::PAYED_WITH_COIN) { Notification::create([ 'entity_type' => User::class, - 'description' => $this->customer->fullname . ' melakukan penukaran ' . $this->items()->count() . ' voucher sebesar ' . $this->items->value('price') . ' coin', + 'description' => $this->customer->fullname.' melakukan penukaran '.$this->items()->count().' voucher sebesar '.$this->items->value('price').' coin', ]); Notification::create([ 'entity_id' => auth()->id(), - 'description' => 'Transaksi ' . $this->code . ' berhasil', + 'description' => 'Transaksi '.$this->code.' berhasil', ]); return; @@ -86,12 +85,12 @@ class Sale extends Model Notification::create([ 'entity_type' => User::class, - 'description' => $this->customer->fullname . ' melakukan pembelian ' . $this->items()->count() . ' voucher sebesar ' . $this->display_amount, + 'description' => $this->customer->fullname.' melakukan pembelian '.$this->items()->count().' voucher sebesar '.$this->display_amount, ]); Notification::create([ 'entity_id' => auth()->id(), - 'description' => 'Transaksi pembelian anda #' . $this->code . ' sebesar ' . $this->display_amount . ' berhasil', + 'description' => 'Transaksi pembelian anda #'.$this->code.' sebesar '.$this->display_amount.' berhasil', ]); } } diff --git a/app/Models/SaleItem.php b/app/Models/SaleItem.php index 97e7a04..cdac160 100644 --- a/app/Models/SaleItem.php +++ b/app/Models/SaleItem.php @@ -41,21 +41,21 @@ class SaleItem extends Model if ($item == null) { return ''; } - $string = "Hai, aku baru beli voucher {$item->voucher->location->name} di " . route('home.index'); + $string = "Hai, aku baru beli voucher {$item->voucher->location->name} di ".route('home.index'); $string .= " voucher {$item->voucher->display_quota} buat {$item->voucher->display_expired} Username : {$item->voucher->username} Password : {$item->voucher->password} "; - $string .= "Cuman Rp" . number_format($this->price, is_float($this->price) ? 2 : 0, ',', '.') . " aja, "; + $string .= 'Cuman Rp'.number_format($this->price, is_float($this->price) ? 2 : 0, ',', '.').' aja, '; if ($item->voucher->discount > 0) { $string .= "lagi ada discount {$item->voucher->discount}% loh. "; } - $string .= "dapatkat penawaran voucher lainnya di " . route('home.index'); + $string .= 'dapatkat penawaran voucher lainnya di '.route('home.index'); return $string; }); diff --git a/app/Models/Voucher.php b/app/Models/Voucher.php index 053f1e7..6f5202b 100644 --- a/app/Models/Voucher.php +++ b/app/Models/Voucher.php @@ -63,14 +63,14 @@ class Voucher extends Model public function displayQuota(): Attribute { return Attribute::make(get: function () { - return round($this->quota / (1024 * 1024 * 1024), 2) . ' GB'; + return round($this->quota / (1024 * 1024 * 1024), 2).' GB'; }); } public function displayExpired(): Attribute { return Attribute::make(get: function () { - return $this->expired . ' ' . $this->expired_unit; + return $this->expired.' '.$this->expired_unit; }); } @@ -80,6 +80,7 @@ class Voucher extends Model if (auth('customer')->check()) { if ($this->prices()->count() > 0) { $price = $this->prices()->where('customer_level_id', auth()->user()->customer_level_id)->value('price'); + return $price; } } @@ -94,6 +95,7 @@ class Voucher extends Model if (auth('customer')->check()) { if ($this->prices()->count() > 0) { $price = $this->prices()->where('customer_level_id', auth()->user()->customer_level_id)->value('display_price'); + return $price; } } @@ -116,7 +118,7 @@ class Voucher extends Model { $voucher = Voucher::where([ ['is_sold', '=', self::UNSOLD], - ['batch_id', '=', $this->batch_id] + ['batch_id', '=', $this->batch_id], ])->first(); return $voucher; @@ -126,7 +128,7 @@ class Voucher extends Model { $voucher = Voucher::where([ ['is_sold', '=', self::UNSOLD], - ['batch_id', '=', $this->batch_id] + ['batch_id', '=', $this->batch_id], ])->count(); return $voucher; @@ -136,7 +138,7 @@ class Voucher extends Model { $count = Voucher::where([ ['is_sold', '=', self::UNSOLD], - ['batch_id', '=', $this->batch_id] + ['batch_id', '=', $this->batch_id], ])->count(); $treshold = Setting::getByKey('VOUCHER_STOCK_NOTIFICATION'); @@ -144,7 +146,7 @@ class Voucher extends Model if ($count <= $treshold) { Notification::create([ 'entity_type' => User::class, - 'description' => "stok voucher " . $this->location->name . " ( " . $this->profile . " ) " . "tersisa : " . $count, + 'description' => 'stok voucher '.$this->location->name.' ( '.$this->profile.' ) '.'tersisa : '.$count, ]); } } diff --git a/config/laradumps.php b/config/laradumps.php index 5f0bd9a..c26ee35 100644 --- a/config/laradumps.php +++ b/config/laradumps.php @@ -208,7 +208,7 @@ return [ 'send_livewire_failed_validation' => [ 'enabled' => env('DS_SEND_LIVEWIRE_FAILED_VALIDATION', false), - 'sleep' => env('DS_SEND_LIVEWIRE_FAILED_VALIDATION_SLEEP', 400), + 'sleep' => env('DS_SEND_LIVEWIRE_FAILED_VALIDATION_SLEEP', 400), ], /* @@ -271,27 +271,27 @@ return [ 'ide_handlers' => [ 'atom' => [ - 'handler' => 'atom://core/open/file?filename=', + 'handler' => 'atom://core/open/file?filename=', 'line_separator' => '&line=', ], 'phpstorm' => [ - 'handler' => 'phpstorm://open?file=', + 'handler' => 'phpstorm://open?file=', 'line_separator' => '&line=', ], 'sublime' => [ - 'handler' => 'subl://open?url=file://', + 'handler' => 'subl://open?url=file://', 'line_separator' => '&line=', ], 'vscode' => [ - 'handler' => 'vscode://file/', + 'handler' => 'vscode://file/', 'line_separator' => ':', ], 'vscode_remote' => [ - 'handler' => 'vscode://vscode-remote/', + 'handler' => 'vscode://vscode-remote/', 'line_separator' => ':', - 'local_path' => 'wsl+' . env('DS_PREFERRED_WSL_DISTRO', 'Ubuntu20.04LTS'), - 'remote_path' => env('DS_REMOTE_PATH', null), - 'work_dir' => env('DS_WORKDIR', '/var/www/html'), + 'local_path' => 'wsl+'.env('DS_PREFERRED_WSL_DISTRO', 'Ubuntu20.04LTS'), + 'remote_path' => env('DS_REMOTE_PATH', null), + 'work_dir' => env('DS_WORKDIR', '/var/www/html'), ], ], @@ -404,13 +404,13 @@ return [ */ 'level_log_colors_map' => [ - 'error' => env('DS_LOG_COLOR_ERROR', 'border-red-600'), - 'critical' => env('DS_LOG_COLOR_CRITICAL', 'border-red-900'), - 'alert' => env('DS_LOG_COLOR_ALERT', 'border-red-500'), + 'error' => env('DS_LOG_COLOR_ERROR', 'border-red-600'), + 'critical' => env('DS_LOG_COLOR_CRITICAL', 'border-red-900'), + 'alert' => env('DS_LOG_COLOR_ALERT', 'border-red-500'), 'emergency' => env('DS_LOG_COLOR_EMERGENCY', 'border-red-600'), - 'warning' => env('DS_LOG_COLOR_WARNING', 'border-orange-300'), - 'notice' => env('DS_LOG_COLOR_NOTICE', 'border-green-300'), - 'info' => env('DS_LOG_COLOR_INFO', 'border-blue-300'), - 'debug' => env('DS_LOG_COLOR_INFO', 'border-black'), + 'warning' => env('DS_LOG_COLOR_WARNING', 'border-orange-300'), + 'notice' => env('DS_LOG_COLOR_NOTICE', 'border-green-300'), + 'info' => env('DS_LOG_COLOR_INFO', 'border-blue-300'), + 'debug' => env('DS_LOG_COLOR_INFO', 'border-black'), ], ]; diff --git a/database/seeders/DummySeeder.php b/database/seeders/DummySeeder.php index 061defd..016161b 100644 --- a/database/seeders/DummySeeder.php +++ b/database/seeders/DummySeeder.php @@ -41,8 +41,8 @@ class DummySeeder extends Seeder $images = ['1.webp', '2.webp', '3.webp']; foreach ($images as $index => $image) { Banner::create([ - 'title' => 'Banner ' . $index, - 'image' => 'sample/' . $image, + 'title' => 'Banner '.$index, + 'image' => 'sample/'.$image, 'description' => '

Banner

', ]); } diff --git a/routes/admin.php b/routes/admin.php index ea78f7d..3ef9823 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -1,22 +1,22 @@ name('customer.logout'); - // paylater + // paylater Route::get('paylater', [PaylaterController::class, 'index'])->name('customer.paylater.index'); Route::get('paylater/trx/{paylater}', [PaylaterController::class, 'show'])->name('customer.paylater.show'); @@ -58,7 +58,6 @@ Route::middleware(['http_secure_aware', 'guard_should_customer', 'inertia.custom Route::get('coin', [CoinController::class, 'index'])->name('customer.coin.index'); Route::get('coin/{coin}', [CoinController::class, 'show'])->name('customer.coin.show'); - // cart Route::get('cart', [CartController::class, 'index'])->name('cart.index'); Route::post('cart/process', [CartController::class, 'purchase'])->name('cart.purchase');