diff --git a/app/Entities/Payments/Payment.php b/app/Entities/Payments/Payment.php index e44aad0..00d6c8f 100755 --- a/app/Entities/Payments/Payment.php +++ b/app/Entities/Payments/Payment.php @@ -26,6 +26,6 @@ class Payment extends Model public function type() { - return paymentTypes($this->type_id); + return Type::getNameById($this->type_id); } } diff --git a/app/Entities/Payments/Type.php b/app/Entities/Payments/Type.php new file mode 100644 index 0000000..4031c82 --- /dev/null +++ b/app/Entities/Payments/Type.php @@ -0,0 +1,35 @@ + 'project', + 2 => 'add_feature', + 3 => 'maintenance', + ]; + + protected static $colors = [ + 1 => '#337ab7', + 2 => '#4caf50', + 3 => '#ff8181', + ]; + + public static function getNameById($singleId) + { + return trans('payment.types.'.static::getById($singleId)); + } + + public static function toArray() + { + $lists = []; + foreach (static::$lists as $key => $value) { + $lists[$key] = trans('payment.types.'.$value); + } + + return $lists; + } +} diff --git a/app/Http/Controllers/PaymentsController.php b/app/Http/Controllers/PaymentsController.php index 6e88ab2..eaf8051 100755 --- a/app/Http/Controllers/PaymentsController.php +++ b/app/Http/Controllers/PaymentsController.php @@ -21,7 +21,7 @@ class PaymentsController extends Controller public function index(Request $request) { - $payments = $this->repo->getPayments($request->only('q', 'partner_id')); + $payments = $this->repo->getPayments($request->only('q', 'partner_id')); $partnersList = Customer::pluck('name', 'id')->all(); return view('payments.index', compact('payments', 'partnersList')); } diff --git a/app/helpers.php b/app/helpers.php index 51a3f2b..f4e72e6 100755 --- a/app/helpers.php +++ b/app/helpers.php @@ -219,21 +219,6 @@ function dateDifference($date1, $date2, $differenceFormat = '%a') return $interval->format($differenceFormat); } -function paymentTypes($paymentTypeId = null) -{ - $paymentTypes = [1 => 'Project', 'Add Feature', 'Maintenance']; - - if (is_null($paymentTypeId)) { - return $paymentTypes; - } - - if (array_key_exists($paymentTypeId, $paymentTypes)) { - return $paymentTypes[$paymentTypeId]; - } - - return null; -} - function appLogoImage() { $logoString = ' Carbon\Carbon::class, 'Option' => App\Services\Facades\Option::class, 'Terbilang' => Riskihajar\Terbilang\Facades\Terbilang::class, + + // Reference Facades + 'PaymentType' => App\Entities\Payments\Type::class, + 'SubscriptionType' => App\Entities\Subscriptions\Type::class, ], ]; diff --git a/resources/lang/id/payment.php b/resources/lang/id/payment.php index 02ec76f..8d0a433 100644 --- a/resources/lang/id/payment.php +++ b/resources/lang/id/payment.php @@ -39,4 +39,11 @@ return [ 'cash_in' => 'Pemasukan', 'cash_out' => 'Pengeluaran', 'payer' => 'Pembayar', + + // Types + 'types' => [ + 'project' => 'Project', + 'add_feature' => 'Add Feature', + 'maintenance' => 'Maintenance', + ], ]; diff --git a/resources/views/payments/create.blade.php b/resources/views/payments/create.blade.php index 305341a..bd8cdb3 100755 --- a/resources/views/payments/create.blade.php +++ b/resources/views/payments/create.blade.php @@ -3,6 +3,7 @@ @section('title', trans('payment.create')) @section('content') +