diff --git a/app/Payment/PaymentResource.php b/app/Payment/PaymentResource.php index 711073e8..2a283678 100644 --- a/app/Payment/PaymentResource.php +++ b/app/Payment/PaymentResource.php @@ -21,6 +21,7 @@ class PaymentResource extends JsonResource 'status_id' => $this->status->id, 'nr' => $this->nr, 'id' => $this->id, + 'is_accepted' => $this->status->isAccepted(), ]; } } diff --git a/app/Payment/Status.php b/app/Payment/Status.php index d22f70f5..195ef917 100644 --- a/app/Payment/Status.php +++ b/app/Payment/Status.php @@ -11,8 +11,17 @@ class Status extends Model public $fillable = ['name', 'is_bill', 'is_remember']; public $timestamps = false; + public $casts = [ + 'is_bill' => 'boolean', + 'is_remember' => 'boolean', + ]; + public static function default() { return static::where('is_bill', true)->where('is_remember', true)->first()->id; } + + public function isAccepted() { + return $this->is_bill === false && $this->is_remember === false; + } } diff --git a/resources/js/views/member/Payments.vue b/resources/js/views/member/Payments.vue index 93279ee0..6415e5c4 100644 --- a/resources/js/views/member/Payments.vue +++ b/resources/js/views/member/Payments.vue @@ -16,6 +16,7 @@
+
@@ -32,6 +33,10 @@ export default { methods: { remove(payment) { this.$inertia.delete(`/member/${this.value.data.id}/payment/${payment.id}`); + }, + + accept(payment) { + this.$inertia.patch(`/member/${this.value.data.id}/payment/${payment.id}`, { ...payment, status_id: 3 }); } },