Add accept button for payment

This commit is contained in:
philipp lang 2021-07-04 17:03:56 +02:00
parent 1dd676d326
commit 7d49134f91
3 changed files with 15 additions and 0 deletions

View File

@ -21,6 +21,7 @@ class PaymentResource extends JsonResource
'status_id' => $this->status->id, 'status_id' => $this->status->id,
'nr' => $this->nr, 'nr' => $this->nr,
'id' => $this->id, 'id' => $this->id,
'is_accepted' => $this->status->isAccepted(),
]; ];
} }
} }

View File

@ -11,8 +11,17 @@ class Status extends Model
public $fillable = ['name', 'is_bill', 'is_remember']; public $fillable = ['name', 'is_bill', 'is_remember'];
public $timestamps = false; public $timestamps = false;
public $casts = [
'is_bill' => 'boolean',
'is_remember' => 'boolean',
];
public static function default() { public static function default() {
return static::where('is_bill', true)->where('is_remember', true)->first()->id; return static::where('is_bill', true)->where('is_remember', true)->first()->id;
} }
public function isAccepted() {
return $this->is_bill === false && $this->is_remember === false;
}
} }

View File

@ -16,6 +16,7 @@
<div v-text="payment.subscription_name"></div> <div v-text="payment.subscription_name"></div>
<div class="flex"> <div class="flex">
<inertia-link :href="`/member/${value.data.id}/payment/${payment.id}/edit`" class="inline-flex btn btn-warning btn-sm"><sprite src="pencil"></sprite></inertia-link> <inertia-link :href="`/member/${value.data.id}/payment/${payment.id}/edit`" class="inline-flex btn btn-warning btn-sm"><sprite src="pencil"></sprite></inertia-link>
<inertia-link v-show="!payment.is_accepted" href="#" @click.prevent="accept(payment)" class="inline-flex btn btn-success btn-sm"><sprite src="check"></sprite></inertia-link>
<inertia-link href="#" @click.prevent="remove(payment)" class="inline-flex btn btn-danger btn-sm"><sprite src="trash"></sprite></inertia-link> <inertia-link href="#" @click.prevent="remove(payment)" class="inline-flex btn btn-danger btn-sm"><sprite src="trash"></sprite></inertia-link>
</div> </div>
</div> </div>
@ -32,6 +33,10 @@ export default {
methods: { methods: {
remove(payment) { remove(payment) {
this.$inertia.delete(`/member/${this.value.data.id}/payment/${payment.id}`); 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 });
} }
}, },