diff --git a/TODO.md b/TODO.md index bc58527..ef2d0fd 100644 --- a/TODO.md +++ b/TODO.md @@ -11,8 +11,8 @@ - [x] Import Voucher - [x] Setting Web (enable affilate, amount bonus affilate) - [x] Setting Level Customer (view levels, edit name of level,minimal saldo, max amount saldo, max hutang) -- [ ] Deposit Menu (view daftar histori deposit) -- [ ] Manual Approve Deposit +- [x] Deposit Menu (view daftar histori deposit) +- [x] Manual Approve Deposit - [ ] Setting Bonus Coin (memasukan amount bonus coin yang didapat dengan level dan harga voucher) - coin rewards - [ ] View Customer Coin History - [ ] List Customer Verification diff --git a/app/Http/Controllers/Customer/AuthController.php b/app/Http/Controllers/Customer/AuthController.php index 88ea783..642a0b5 100644 --- a/app/Http/Controllers/Customer/AuthController.php +++ b/app/Http/Controllers/Customer/AuthController.php @@ -44,7 +44,7 @@ class AuthController extends Controller } return redirect()->route('customer.login') - ->with('message', ['type' => 'error', 'message' => 'invalid credentials']); + ->with('message', ['type' => 'error', 'message' => 'Invalid credentials']); } public function signin_google() diff --git a/app/Http/Controllers/DepositController.php b/app/Http/Controllers/DepositController.php index 4f1871d..78549cc 100644 --- a/app/Http/Controllers/DepositController.php +++ b/app/Http/Controllers/DepositController.php @@ -2,15 +2,62 @@ namespace App\Http\Controllers; +use App\Models\DepositHistory; use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; +use Illuminate\Validation\Rule; class DepositController extends Controller { - public function index() + public function index(Request $request) { + $query = DepositHistory::with(['customer', 'account']) + ->where('credit', 0) + ->orderBy('is_valid', 'desc') + ->orderBy('updated_at', 'desc'); + + if ($request->q != '') { + $query->where(function ($query) use ($request) { + $query->where('description', 'like', "%$request->q%") + ->orWhereHas('customer', function ($query) use ($request) { + $query->where('fullname', 'like', "%$request->q%") + ->orWhere('email', 'like', "%$request->q%") + ->orWhere('phone', 'like', "%$request->q%"); + }); + }); + } + + if ($request->status != '') { + $query->where('is_valid', $request->status); + } + + if ($request->customer_id != '') { + $query->where('is_valid', $request->customer_id); + } + + return inertia('DepositHistory/Index', [ + 'query' => $query->paginate() + ]); } - public function update() + public function update(Request $request, DepositHistory $deposit) { + $request->validate([ + 'status' => [ + 'required', + Rule::in([DepositHistory::STATUS_VALID, DepositHistory::STATUS_REJECT]) + ] + ]); + + DB::beginTransaction(); + $deposit->update([ + 'is_valid' => $request->status, + ]); + if ($request->status === DepositHistory::STATUS_VALID) { + $deposit->update_customer_balance(); + } + DB::commit(); + + session()->flash('message', ['type' => 'success', 'message' => 'Item has beed updated']); } } diff --git a/app/Models/DepositHistory.php b/app/Models/DepositHistory.php index 43bbdb7..4d1e738 100644 --- a/app/Models/DepositHistory.php +++ b/app/Models/DepositHistory.php @@ -48,12 +48,12 @@ class DepositHistory extends Model { return Attribute::make(get: function () { return [ - self::STATUS_VALID => ['text' => 'Success', 'color' => 'bg-green-600'], - self::STATUS_WAIT_UPLOAD => ['text' => 'Upload bukti transfer', 'color' => 'bg-red-600'], - self::STATUS_WAIT_APPROVE => ['text' => 'Menunggu Approve', 'color' => 'bg-green-600'], - self::STATUS_WAIT_PAYMENT => ['text' => 'Menunggu Pembayaran', 'color' => 'bg-green-600'], - self::STATUS_INVALID => ['text' => 'Error', 'color' => 'bg-red-600'], - self::STATUS_REJECT => ['text' => 'Reject', 'color' => 'bg-red-600'], + self::STATUS_VALID => ['text' => 'Success', 'color' => 'bg-green-600', 'text_color' => 'text-green-600'], + self::STATUS_WAIT_UPLOAD => ['text' => 'Upload bukti transfer', 'color' => 'bg-red-600', 'text_color' => 'text-red-600'], + self::STATUS_WAIT_APPROVE => ['text' => 'Menunggu Approve', 'color' => 'bg-green-600', 'text_color' => 'text-green-600'], + self::STATUS_WAIT_PAYMENT => ['text' => 'Menunggu Pembayaran', 'color' => 'bg-green-600', 'text_color' => 'text-green-600'], + self::STATUS_INVALID => ['text' => 'Error', 'color' => 'bg-red-600', 'text_color' => 'text-red-600'], + self::STATUS_REJECT => ['text' => 'Reject', 'color' => 'bg-red-600', 'text_color' => 'text-red-600'], ][$this->is_valid]; }); } @@ -76,9 +76,9 @@ class DepositHistory extends Model { return Attribute::make(get: function () { if ($this->credit == 0) { - return $this->debit; + return 'Rp' . number_format($this->debit, 0, ',', '.'); } - return $this->credit; + return '-Rp' . number_format($this->credit, 0, ',', '.'); }); } @@ -94,6 +94,11 @@ class DepositHistory extends Model return $this->belongsTo(Customer::class); } + public function account() + { + return $this->belongsTo(Account::class); + } + public function update_customer_balance() { $customer = Customer::find($this->customer_id); diff --git a/database/seeders/PermissionSeeder.php b/database/seeders/PermissionSeeder.php index 562eb22..91f38f8 100644 --- a/database/seeders/PermissionSeeder.php +++ b/database/seeders/PermissionSeeder.php @@ -61,8 +61,8 @@ class PermissionSeeder extends Seeder ['id' => Str::ulid(), 'label' => 'View Setting', 'name' => 'view-setting'], - ['id' => Str::ulid(), 'label' => 'View Deposit', 'name' => 'view-deposite'], - ['id' => Str::ulid(), 'label' => 'Update Deposit', 'name' => 'update-deposite'], + ['id' => Str::ulid(), 'label' => 'View Deposit', 'name' => 'view-deposit'], + ['id' => Str::ulid(), 'label' => 'Update Deposit', 'name' => 'update-deposit'], ['id' => Str::ulid(), 'label' => 'View Coin', 'name' => 'view-coin'], ['id' => Str::ulid(), 'label' => 'Update Coin', 'name' => 'update-coin'], diff --git a/resources/js/Components/FormInput.jsx b/resources/js/Components/FormInput.jsx index 20ab80b..ff5b4af 100644 --- a/resources/js/Components/FormInput.jsx +++ b/resources/js/Components/FormInput.jsx @@ -31,6 +31,7 @@ export default function FormInput({ {leftItem} )} { if (route().current(r)) { - return 'text-blue-700 h-8 w-8' + return 'text-blue-700' } - return 'text-gray-600 h-8 w-8' + return 'text-gray-600' } return ( @@ -33,41 +34,44 @@ export default function CustomerLayout({ children }) {
Customer | +: | +{data.customer_name} | +
Deskripsi | +: | +{data.description} | +
Metode Pembayaran | +: | +{data.payment_channel} | +
Bank Akun | +: | ++ {data.account.name} ({data.account.bank_name}) + | +
Jumlah | +: | +{data.amount} | +
Status | +: | +{data.status_text} | +
+ Customer + | ++ Deposit + | ++ Deskripsi + | ++ Status + | ++ |
---|---|---|---|---|
+ {deposit.customer.name} + | ++ {deposit.amount} + | ++ {deposit.description} + | ++ {deposit.status.text} + | +
+
+
+
+ Lihat
+
+ |
+