Add: delete member
This commit is contained in:
parent
fa4467006f
commit
782983686b
|
@ -133,6 +133,10 @@ class Member extends Model
|
|||
$model->bill_kind_id = null;
|
||||
}
|
||||
});
|
||||
|
||||
static::deleting(function($model) {
|
||||
$model->payments->each->delete();
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------- Scopes -----------------------------------
|
||||
|
|
|
@ -14,6 +14,7 @@ use App\Activity;
|
|||
use App\Group;
|
||||
use App\Payment\Subscription;
|
||||
use App\Http\Views\MemberView;
|
||||
use App\Member\DeleteJob;
|
||||
|
||||
class MemberController extends Controller
|
||||
{
|
||||
|
@ -81,4 +82,14 @@ class MemberController extends Controller
|
|||
|
||||
return redirect()->route('member.index');
|
||||
}
|
||||
|
||||
public function destroy(Member $member) {
|
||||
if ($member->has_nami) {
|
||||
DeleteJob::dispatch($member, auth()->user());
|
||||
}
|
||||
|
||||
$member->delete();
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
<div class="flex">
|
||||
<inertia-link :href="`/member/${member.id}/edit`" class="inline-flex btn btn-warning btn-sm"><sprite src="pencil"></sprite></inertia-link>
|
||||
<inertia-link :href="`/member/${member.id}/payment`" class="inline-flex btn btn-info btn-sm"><sprite src="money"></sprite></inertia-link>
|
||||
<inertia-link href="#" @click.prevent="remove(member)" class="inline-flex btn btn-danger btn-sm"><sprite src="trash"></sprite></inertia-link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -62,10 +63,19 @@ import Payments from './Payments.vue';
|
|||
import PaymentForm from './PaymentForm.vue';
|
||||
|
||||
export default {
|
||||
|
||||
layout: App,
|
||||
|
||||
components: { Payments, PaymentForm },
|
||||
|
||||
methods: {
|
||||
remove(member) {
|
||||
if (window.confirm('Mitglied löschen?')) {
|
||||
this.$inertia.delete(`/member/${member.id}`);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
props:{
|
||||
data: {},
|
||||
single: {
|
||||
|
|
Loading…
Reference in New Issue