From 53af55bf980e2a1136c55d9fe0bbe896a79d2a0b Mon Sep 17 00:00:00 2001 From: Aji Kamaludin Date: Sun, 2 Jul 2023 23:45:36 +0700 Subject: [PATCH] pint format --- TODO.md | 2 +- .../Controllers/Admin/CustomerController.php | 4 ++-- .../Admin/CustomerMitraController.php | 4 ++-- .../Controllers/Admin/PaylaterController.php | 2 +- .../Customer/DepositController.php | 8 +++---- .../Customer/PaylaterController.php | 13 +++++------ app/Models/DepositHistory.php | 14 ++++++------ app/Models/PaylaterCustomer.php | 5 +++-- app/Models/PaylaterHistory.php | 6 ++--- app/Services/GeneralService.php | 22 +++++++++---------- 10 files changed, 39 insertions(+), 41 deletions(-) diff --git a/TODO.md b/TODO.md index 0a16861..322a075 100644 --- a/TODO.md +++ b/TODO.md @@ -41,4 +41,4 @@ - [x] ubah filter di mitra list dan customer list menjadi seperti di sale index - [x] untuk detail mitra nanti akan ada button untuk (transaksi mitra dengan cakupan: pembelian voucher, pembayaran hutang, topuplimit, penambahan batas bayar, history deposit) -- [ ] tambah floating button untuk notifikasi deposit (angka saja), di dashboard tambahkan list deposit terbaru +- [ ] di dashboard tambahkan list deposit terbaru diff --git a/app/Http/Controllers/Admin/CustomerController.php b/app/Http/Controllers/Admin/CustomerController.php index ad0fc53..350b28f 100644 --- a/app/Http/Controllers/Admin/CustomerController.php +++ b/app/Http/Controllers/Admin/CustomerController.php @@ -115,8 +115,8 @@ class CustomerController extends Controller public function update(Request $request, Customer $customer) { $request->validate([ - 'email' => 'nullable|email|unique:customers,email,' . $customer->id, - 'username' => 'required|string|min:5|alpha_dash|unique:customers,username,' . $customer->id, + 'email' => 'nullable|email|unique:customers,email,'.$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', diff --git a/app/Http/Controllers/Admin/CustomerMitraController.php b/app/Http/Controllers/Admin/CustomerMitraController.php index ae76626..bf6d78b 100644 --- a/app/Http/Controllers/Admin/CustomerMitraController.php +++ b/app/Http/Controllers/Admin/CustomerMitraController.php @@ -220,8 +220,8 @@ class CustomerMitraController extends Controller public function update(Request $request, Customer $customer) { $request->validate([ - 'email' => 'nullable|email|unique:customers,email,' . $customer->id, - 'username' => 'required|string|min:5|alpha_dash|unique:customers,username,' . $customer->id, + 'email' => 'nullable|email|unique:customers,email,'.$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', diff --git a/app/Http/Controllers/Admin/PaylaterController.php b/app/Http/Controllers/Admin/PaylaterController.php index a7c8731..51d1cad 100644 --- a/app/Http/Controllers/Admin/PaylaterController.php +++ b/app/Http/Controllers/Admin/PaylaterController.php @@ -55,7 +55,7 @@ class PaylaterController extends Controller public function show(PaylaterHistory $paylater) { return inertia('Paylater/Detail', [ - 'paylater' => $paylater->load(['customer']) + 'paylater' => $paylater->load(['customer']), ]); } diff --git a/app/Http/Controllers/Customer/DepositController.php b/app/Http/Controllers/Customer/DepositController.php index 4b38a6f..a6827a6 100644 --- a/app/Http/Controllers/Customer/DepositController.php +++ b/app/Http/Controllers/Customer/DepositController.php @@ -42,7 +42,7 @@ class DepositController extends Controller public function create(Request $request) { $customer = $request->user('customer'); - if (!$customer->allow_transaction) { + if (! $customer->allow_transaction) { return redirect()->back() ->with('message', ['type' => 'error', 'message' => 'akun anda dibekukan tidak dapat melakukan transaksi']); } @@ -102,7 +102,7 @@ class DepositController extends Controller 'direct' => $request->direct, 'bank_admin_fee' => Setting::getByKey('ADMINFEE_MANUAL_TRANSFER'), 'cash_admin_fee' => Setting::getByKey('ADMINFEE_CASH_DEPOSIT'), - 'back' => $request->back ?? 'transactions.deposit.index' + 'back' => $request->back ?? 'transactions.deposit.index', ]); } @@ -157,7 +157,7 @@ class DepositController extends Controller if ($is_valid == DepositHistory::STATUS_VALID) { $deposit->update_customer_balance(); } - // TODO: update for paylater + // TODO: update for paylater DB::commit(); @@ -190,7 +190,7 @@ class DepositController extends Controller $deposit->save(); } - // TODO: update for paylater + // TODO: update for paylater DB::commit(); diff --git a/app/Http/Controllers/Customer/PaylaterController.php b/app/Http/Controllers/Customer/PaylaterController.php index 8f22bc3..9c1c319 100644 --- a/app/Http/Controllers/Customer/PaylaterController.php +++ b/app/Http/Controllers/Customer/PaylaterController.php @@ -3,10 +3,7 @@ namespace App\Http\Controllers\Customer; use App\Http\Controllers\Controller; -use App\Models\Account; -use App\Models\Customer; use App\Models\DepositHistory; -use App\Models\DepositLocation; use App\Models\PaylaterHistory; use App\Models\Setting; use App\Services\GeneralService; @@ -32,10 +29,10 @@ class PaylaterController extends Controller if ($paylater->type == PaylaterHistory::TYPE_REPAYMENT) { $deposit = DepositHistory::where('related_id', $paylater->id)->first(); - if (!in_array($deposit->is_valid, [DepositHistory::STATUS_VALID])) { + if (! in_array($deposit->is_valid, [DepositHistory::STATUS_VALID])) { return redirect()->route('transactions.deposit.show', [ 'deposit' => $deposit, - 'back' => 'customer.paylater.index' + 'back' => 'customer.paylater.index', ]); } } @@ -65,7 +62,7 @@ class PaylaterController extends Controller $customer = $request->user('customer'); - // validate amount + // validate amount if ($customer->paylater->usage < $request->amount) { return redirect()->back() ->with('message', ['type' => 'error', 'message' => 'Nominal Tagihan tidak boleh lebih dari tagihan']); @@ -75,7 +72,7 @@ class PaylaterController extends Controller $repayment = DepositHistory::query() ->where([ ['customer_id', '=', $customer->id], - ['type', '=', DepositHistory::TYPE_REPAYMENT] + ['type', '=', DepositHistory::TYPE_REPAYMENT], ])->where(function ($query) { $query->where('is_valid', '!=', DepositHistory::STATUS_VALID) ->where('is_valid', '!=', DepositHistory::STATUS_REJECT) @@ -130,7 +127,7 @@ class PaylaterController extends Controller return redirect()->route('transactions.deposit.show', [ 'deposit' => $deposit->id, 'direct' => 'true', - 'back' => 'customer.paylater.index' + 'back' => 'customer.paylater.index', ]); } } diff --git a/app/Models/DepositHistory.php b/app/Models/DepositHistory.php index 735930c..50c130d 100644 --- a/app/Models/DepositHistory.php +++ b/app/Models/DepositHistory.php @@ -52,7 +52,7 @@ class DepositHistory extends Model 'format_created_at', 'amount', 'image_prove_url', - 'admin_fee' + 'admin_fee', ]; protected static function booted(): void @@ -99,10 +99,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, ',', '.'); }); } @@ -165,7 +165,7 @@ class DepositHistory extends Model } Notification::create([ 'entity_type' => User::class, - 'description' => $this->customer->fullname . ' melakukan deposit transfer manual sebesar : ' . $this->amount . $status, + 'description' => $this->customer->fullname.' melakukan deposit transfer manual sebesar : '.$this->amount.$status, ]); } @@ -176,14 +176,14 @@ class DepositHistory extends Model } 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, ]); } } @@ -192,7 +192,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/PaylaterCustomer.php b/app/Models/PaylaterCustomer.php index d4aec2c..cf1ac13 100644 --- a/app/Models/PaylaterCustomer.php +++ b/app/Models/PaylaterCustomer.php @@ -17,7 +17,7 @@ class PaylaterCustomer extends Model ]; protected $appends = [ - 'paylater_description' + 'paylater_description', ]; public function customer() @@ -30,10 +30,11 @@ class PaylaterCustomer extends Model return Attribute::make(get: function () { if ($this->day_deadline_at != null) { $deadlineAt = Carbon::parse($this->day_deadline_at)->translatedFormat('d F Y'); + return "lunasi pinjaman kamu sebelum jatuh tempo pada {$deadlineAt}"; } - return "yuk gunakan terus saldo yang tersedia"; + return 'yuk gunakan terus saldo yang tersedia'; }); } } diff --git a/app/Models/PaylaterHistory.php b/app/Models/PaylaterHistory.php index ecfbe48..dedf62a 100644 --- a/app/Models/PaylaterHistory.php +++ b/app/Models/PaylaterHistory.php @@ -71,10 +71,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, ',', '.'); }); } @@ -116,7 +116,7 @@ class PaylaterHistory extends Model { Notification::create([ 'entity_id' => $this->customer_id, - 'description' => 'Pembayaran ' . $this->description . ' sebesar ' . $this->amount . ' sudah sukses diterima', + 'description' => 'Pembayaran '.$this->description.' sebesar '.$this->amount.' sudah sukses diterima', ]); } diff --git a/app/Services/GeneralService.php b/app/Services/GeneralService.php index 1dbaea4..e080677 100644 --- a/app/Services/GeneralService.php +++ b/app/Services/GeneralService.php @@ -139,9 +139,9 @@ class GeneralService $time = explode(':', $time); foreach ($time as $t) { //00 : 00 if ($t < 10) { - $r .= '0' . (int) $t . ':'; + $r .= '0'.(int) $t.':'; } else { - $r .= $t . ':'; + $r .= $t.':'; } } @@ -154,7 +154,7 @@ class GeneralService ->whereDate('created_at', now()) ->count() + 1; - return 'Invoice #TLH' . now()->format('dmy') . GeneralService::formatNumberCode($code); + return 'Invoice #TLH'.now()->format('dmy').GeneralService::formatNumberCode($code); } public static function generateDepositCode() @@ -163,7 +163,7 @@ class GeneralService ->whereDate('created_at', now()) ->count() + 1; - return 'Invoice #DSR' . now()->format('dmy') . GeneralService::formatNumberCode($code); + return 'Invoice #DSR'.now()->format('dmy').GeneralService::formatNumberCode($code); } public static function generateDepositRepayCode() @@ -172,7 +172,7 @@ class GeneralService ->whereDate('created_at', now()) ->count() + 1; - return 'Invoice #PLH' . now()->format('dmy') . GeneralService::formatNumberCode($code); + return 'Invoice #PLH'.now()->format('dmy').GeneralService::formatNumberCode($code); } public static function generateSaleVoucherCode() @@ -181,14 +181,14 @@ class GeneralService ->where('payed_with', '!=', Sale::PAYED_WITH_POIN) ->count() + 1; - return 'Invoice #VCR' . now()->format('dmy') . GeneralService::formatNumberCode($code); + return 'Invoice #VCR'.now()->format('dmy').GeneralService::formatNumberCode($code); } public static function generateBonusPoinCode() { $code = PoinHistory::whereDate('created_at', now())->count() + 1; - return 'Invoice #BPN' . now()->format('dmy') . GeneralService::formatNumberCode($code); + return 'Invoice #BPN'.now()->format('dmy').GeneralService::formatNumberCode($code); } public static function generateExchangePoinCode() @@ -197,19 +197,19 @@ class GeneralService ->where('payed_with', '=', Sale::PAYED_WITH_POIN) ->count() + 1; - return 'Invoice #PVC' . now()->format('dmy') . GeneralService::formatNumberCode($code); + return 'Invoice #PVC'.now()->format('dmy').GeneralService::formatNumberCode($code); } public static function formatNumberCode($number) { if ($number < 10) { - return '000' . $number; + return '000'.$number; } if ($number < 100) { - return '00' . $number; + return '00'.$number; } if ($number < 1000) { - return '0' . $number; + return '0'.$number; } return $number;