Add: Delete course
continuous-integration/drone/push Build is passing Details

This commit is contained in:
philipp lang 2021-11-20 01:43:20 +01:00
parent bcc5d7af4b
commit ef20eee81d
6 changed files with 23 additions and 28 deletions

View File

@ -17,20 +17,20 @@ class CourseController extends Controller
{ {
$request->persist($member); $request->persist($member);
return redirect()->route('member.index'); return redirect()->back();
} }
public function update(Member $member, CourseMember $course, UpdateRequest $request): RedirectResponse public function update(Member $member, CourseMember $course, UpdateRequest $request): RedirectResponse
{ {
$request->persist($member, $course); $request->persist($member, $course);
return redirect()->route('member.index'); return redirect()->back();
} }
public function destroy(Member $member, CourseMember $course, DestroyRequest $request): RedirectResponse public function destroy(Member $member, CourseMember $course, DestroyRequest $request): RedirectResponse
{ {
$request->persist($member, $course); $request->persist($member, $course);
return redirect()->route('member.index'); return redirect()->back();
} }
} }

View File

@ -17,11 +17,12 @@ class CourseResource extends JsonResource
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'organizer' => $this->pivot->organizer, 'organizer' => $this->organizer,
'event_name' => $this->pivot->event_name, 'event_name' => $this->event_name,
'completed_at_human' => Carbon::parse($this->pivot->completed_at)->format('d.m.Y'), 'completed_at_human' => Carbon::parse($this->completed_at)->format('d.m.Y'),
'completed_at' => $this->pivot->completed_at, 'completed_at' => $this->completed_at,
'course_name' => $this->name, 'course_name' => $this->course->name,
'course_id' => $this->course->id,
]; ];
} }
} }

View File

@ -2,8 +2,8 @@
namespace App\Initialize; namespace App\Initialize;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class InitializeController extends Controller class InitializeController extends Controller
{ {
@ -14,6 +14,6 @@ class InitializeController extends Controller
public function store() { public function store() {
InitializeJob::dispatch(auth()->user()); InitializeJob::dispatch(auth()->user());
return \Inertia::render('Initialize/Index'); return redirect()->route('home');
} }
} }

@ -1 +1 @@
Subproject commit d348aea5f6bba6cf3eb8e2050a738817f281b4c3 Subproject commit d96457dd338857306b6ffb14da5444b8cf08417a

View File

@ -3,9 +3,10 @@
<sidebar-header :links="indexLinks" @close="$emit('close')" @create="mode = 'create'; single = {}" title="Ausbildungen"></sidebar-header> <sidebar-header :links="indexLinks" @close="$emit('close')" @create="mode = 'create'; single = {}" title="Ausbildungen"></sidebar-header>
<form v-if="single" class="p-6 grid gap-4 justify-start" @submit.prevent="submit"> <form v-if="single" class="p-6 grid gap-4 justify-start" @submit.prevent="submit">
<f-text id="nr" v-model="single.nr" label="Jahr" required></f-text> <f-text id="completed_at" type="date" v-model="single.completed_at" label="Datum" required></f-text>
<f-select id="subscription_id" :options="subscriptions" v-model="single.subscription_id" label="Beitrag" required></f-select> <f-select id="course_id" :options="courses" v-model="single.course_id" label="Baustein" required></f-select>
<f-select id="status_id" :options="statuses" v-model="single.status_id" label="Status" required></f-select> <f-text id="event_name" v-model="single.event_name" label="Veranstaltung" required></f-text>
<f-text id="organizer" v-model="single.organizer" label="Veranstalter" required></f-text>
<button type="submit" class="btn btn-primary">Absenden</button> <button type="submit" class="btn btn-primary">Absenden</button>
</form> </form>
@ -47,6 +48,7 @@ export default {
}, },
props: { props: {
courses: {},
value: {} value: {}
}, },
@ -54,11 +56,7 @@ export default {
methods: { methods: {
remove(payment) { remove(payment) {
this.$inertia.delete(`/member/${this.value.id}/payment/${payment.id}`); this.$inertia.delete(`/member/${this.value.id}/course/${payment.id}`);
},
accept(payment) {
this.$inertia.patch(`/member/${this.value.id}/payment/${payment.id}`, { ...payment, status_id: 3 });
}, },
openLink(link) { openLink(link) {
@ -73,23 +71,17 @@ export default {
var _self = this; var _self = this;
this.mode === 'create' this.mode === 'create'
? this.$inertia.post(`/member/${this.value.id}/payment`, this.single, { ? this.$inertia.post(`/member/${this.value.id}/course`, this.single, {
onFinish() { onFinish() {
_self.single = null; _self.single = null;
} }
}) })
: this.$inertia.patch(`/member/${this.value.id}/payment/${this.single.id}`, this.single, { : this.$inertia.patch(`/member/${this.value.id}/course/${this.single.id}`, this.single, {
onFinish() { onFinish() {
_self.single = null; _self.single = null;
} }
}); });
} }
},
props: {
value: {},
subscriptions: {},
statuses: {},
} }
}; };
</script> </script>

View File

@ -2,6 +2,8 @@
namespace Tests\Feature\Member; namespace Tests\Feature\Member;
use App\Course\Models\Course;
use App\Course\Models\CourseMember;
use App\Member\Member; use App\Member\Member;
use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase; use Tests\TestCase;
@ -16,7 +18,7 @@ class IndexTest extends TestCase
$this->withoutExceptionHandling(); $this->withoutExceptionHandling();
$this->login(); $this->login();
Member::factory()->defaults()->create(['firstname' => '::firstname']); Member::factory()->defaults()->has(CourseMember::factory()->for(Course::factory()), 'courses')->create(['firstname' => '::firstname']);
$this->get('/member')->assertInertia('member/Index', ['firstname' => '::firstname'], 'data.data.0'); $this->get('/member')->assertInertia('member/Index', ['firstname' => '::firstname'], 'data.data.0');
} }