Compare commits
19 Commits
a26f064698
...
e345ace428
Author | SHA1 | Date |
---|---|---|
|
e345ace428 | |
|
9a898315a0 | |
|
a84d9f428d | |
|
36c0ebced0 | |
|
6d4dda869a | |
|
9813482741 | |
|
1e74a6055e | |
|
c764f3d3b7 | |
|
8846adef5b | |
|
20833426ca | |
|
e60bc94b80 | |
|
356a69507e | |
|
1fb2dd19e7 | |
|
767239fb62 | |
|
2fbad36700 | |
|
37a6dd8330 | |
|
bfc4663ba4 | |
|
450e715acd | |
|
128d9af3ee |
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Course\Actions;
|
||||||
|
|
||||||
|
use App\Course\Models\CourseMember;
|
||||||
|
use App\Lib\JobMiddleware\JobChannels;
|
||||||
|
use App\Lib\JobMiddleware\WithJobState;
|
||||||
|
use App\Lib\Queue\TracksJob;
|
||||||
|
use App\Setting\NamiSettings;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class CourseDestroyAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
use TracksJob;
|
||||||
|
|
||||||
|
public function handle(int $courseId): void
|
||||||
|
{
|
||||||
|
$course = CourseMember::find($courseId);
|
||||||
|
app(NamiSettings::class)->login()->deleteCourse($course->member->nami_id, $course->nami_id);
|
||||||
|
|
||||||
|
$course->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asController(CourseMember $course): JsonResponse
|
||||||
|
{
|
||||||
|
$this->startJob($course->id, $course->member->fullname);
|
||||||
|
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $parameters
|
||||||
|
*/
|
||||||
|
public function jobState(WithJobState $jobState, ...$parameters): WithJobState
|
||||||
|
{
|
||||||
|
$memberFullname = $parameters[1];
|
||||||
|
|
||||||
|
return $jobState
|
||||||
|
->before('Ausbildung für ' . $memberFullname . ' wird gelöscht')
|
||||||
|
->after('Ausbildung für ' . $memberFullname . ' gelöscht')
|
||||||
|
->failed('Fehler beim Löschen der Ausbildung für ' . $memberFullname)
|
||||||
|
->shouldReload(JobChannels::make()->add('member')->add('course'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Course\Actions;
|
||||||
|
|
||||||
|
use App\Course\Models\Course;
|
||||||
|
use App\Course\Resources\CourseMemberResource;
|
||||||
|
use App\Member\Member;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class CourseIndexAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, Course>
|
||||||
|
*/
|
||||||
|
public function handle(Member $member): Collection
|
||||||
|
{
|
||||||
|
return $member->courses()->with('course')->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asController(Member $member): AnonymousResourceCollection
|
||||||
|
{
|
||||||
|
return CourseMemberResource::collection($this->handle($member))
|
||||||
|
->additional([
|
||||||
|
'meta' => CourseMemberResource::memberMeta($member),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Course\Actions;
|
||||||
|
|
||||||
|
use App\Course\Models\Course;
|
||||||
|
use App\Lib\JobMiddleware\JobChannels;
|
||||||
|
use App\Lib\JobMiddleware\WithJobState;
|
||||||
|
use App\Lib\Queue\TracksJob;
|
||||||
|
use App\Member\Member;
|
||||||
|
use App\Setting\NamiSettings;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class CourseStoreAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
use TracksJob;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $attributes
|
||||||
|
*/
|
||||||
|
public function handle(Member $member, array $attributes): void
|
||||||
|
{
|
||||||
|
$course = Course::where('id', $attributes['course_id'])->firstOrFail();
|
||||||
|
|
||||||
|
$payload = collect($attributes)->only(['event_name', 'completed_at', 'organizer'])->merge([
|
||||||
|
'course_id' => $course->nami_id,
|
||||||
|
])->toArray();
|
||||||
|
|
||||||
|
$namiId = app(NamiSettings::class)->login()->createCourse($member->nami_id, $payload);
|
||||||
|
|
||||||
|
$member->courses()->create([
|
||||||
|
...$attributes,
|
||||||
|
'nami_id' => $namiId,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'organizer' => 'required|max:255',
|
||||||
|
'event_name' => 'required|max:255',
|
||||||
|
'completed_at' => 'required|date',
|
||||||
|
'course_id' => 'required|exists:courses,id',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asController(Member $member, ActionRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$this->startJob($member, $request->validated());
|
||||||
|
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $parameters
|
||||||
|
*/
|
||||||
|
public function jobState(WithJobState $jobState, ...$parameters): WithJobState
|
||||||
|
{
|
||||||
|
$member = $parameters[0];
|
||||||
|
|
||||||
|
return $jobState
|
||||||
|
->before('Ausbildung für ' . $member->fullname . ' wird gespeichert')
|
||||||
|
->after('Ausbildung für ' . $member->fullname . ' gespeichert')
|
||||||
|
->failed('Fehler beim Erstellen der Ausbildung für ' . $member->fullname)
|
||||||
|
->shouldReload(JobChannels::make()->add('member')->add('course'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Course\Actions;
|
||||||
|
|
||||||
|
use App\Course\Models\Course;
|
||||||
|
use App\Course\Models\CourseMember;
|
||||||
|
use App\Course\Resources\CourseMemberResource;
|
||||||
|
use App\Lib\JobMiddleware\JobChannels;
|
||||||
|
use App\Lib\JobMiddleware\WithJobState;
|
||||||
|
use App\Lib\Queue\TracksJob;
|
||||||
|
use App\Member\Member;
|
||||||
|
use App\Setting\NamiSettings;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||||
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class CourseUpdateAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
use TracksJob;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, Course>
|
||||||
|
*/
|
||||||
|
public function handle(CourseMember $course, array $attributes): void
|
||||||
|
{
|
||||||
|
app(NamiSettings::class)->login()->updateCourse(
|
||||||
|
$course->member->nami_id,
|
||||||
|
$course->nami_id,
|
||||||
|
[
|
||||||
|
...$attributes,
|
||||||
|
'course_id' => Course::find($attributes['course_id'])->nami_id,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$course->update($attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'organizer' => 'required|max:255',
|
||||||
|
'event_name' => 'required|max:255',
|
||||||
|
'completed_at' => 'required|date',
|
||||||
|
'course_id' => 'required|exists:courses,id',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asController(CourseMember $course, ActionRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$this->startJob($course, $request->validated());
|
||||||
|
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $parameters
|
||||||
|
*/
|
||||||
|
public function jobState(WithJobState $jobState, ...$parameters): WithJobState
|
||||||
|
{
|
||||||
|
$member = $parameters[0]->member;
|
||||||
|
|
||||||
|
return $jobState
|
||||||
|
->before('Ausbildung für ' . $member->fullname . ' wird gespeichert')
|
||||||
|
->after('Ausbildung für ' . $member->fullname . ' gespeichert')
|
||||||
|
->failed('Fehler beim Erstellen der Ausbildung für ' . $member->fullname)
|
||||||
|
->shouldReload(JobChannels::make()->add('member')->add('course'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,36 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Course\Controllers;
|
|
||||||
|
|
||||||
use App\Course\Models\CourseMember;
|
|
||||||
use App\Course\Requests\DestroyRequest;
|
|
||||||
use App\Course\Requests\StoreRequest;
|
|
||||||
use App\Course\Requests\UpdateRequest;
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Member\Member;
|
|
||||||
use App\Setting\NamiSettings;
|
|
||||||
use Illuminate\Http\RedirectResponse;
|
|
||||||
|
|
||||||
class CourseController extends Controller
|
|
||||||
{
|
|
||||||
public function store(Member $member, StoreRequest $request, NamiSettings $settings): RedirectResponse
|
|
||||||
{
|
|
||||||
$request->persist($member, $settings);
|
|
||||||
|
|
||||||
return redirect()->back()->success('Ausbildung erstellt');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(Member $member, CourseMember $course, UpdateRequest $request, NamiSettings $settings): RedirectResponse
|
|
||||||
{
|
|
||||||
$request->persist($member, $course, $settings);
|
|
||||||
|
|
||||||
return redirect()->back()->success('Ausbildung aktualisiert');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function destroy(Member $member, CourseMember $course, DestroyRequest $request, NamiSettings $settings): RedirectResponse
|
|
||||||
{
|
|
||||||
$request->persist($member, $course, $settings);
|
|
||||||
|
|
||||||
return redirect()->back()->success('Ausbildung gelöscht');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,4 +22,12 @@ class Course extends Model
|
||||||
->trim()
|
->trim()
|
||||||
->replaceMatches('/ - .*/', '');
|
->replaceMatches('/ - .*/', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array{id: int, name: string}>
|
||||||
|
*/
|
||||||
|
public static function forSelect(): array
|
||||||
|
{
|
||||||
|
return static::select('name', 'id')->get()->toArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Course\Models;
|
namespace App\Course\Models;
|
||||||
|
|
||||||
|
use App\Member\Member;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
@ -20,4 +21,12 @@ class CourseMember extends Model
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Course::class);
|
return $this->belongsTo(Course::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return BelongsTo<Member, self>
|
||||||
|
*/
|
||||||
|
public function member(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Member::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Course\Requests;
|
|
||||||
|
|
||||||
use App\Course\Models\CourseMember;
|
|
||||||
use App\Member\Member;
|
|
||||||
use App\Setting\NamiSettings;
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
|
||||||
|
|
||||||
class DestroyRequest extends FormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Determine if the user is authorized to make this request.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function authorize()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public function rules()
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function persist(Member $member, CourseMember $course, NamiSettings $settings): void
|
|
||||||
{
|
|
||||||
$settings->login()->deleteCourse($member->nami_id, $course->nami_id);
|
|
||||||
|
|
||||||
$course->delete();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Course\Requests;
|
|
||||||
|
|
||||||
use App\Course\Models\Course;
|
|
||||||
use App\Member\Member;
|
|
||||||
use App\Setting\NamiSettings;
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
|
||||||
|
|
||||||
class StoreRequest extends FormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Determine if the user is authorized to make this request.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function authorize()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public function rules()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'organizer' => 'required|max:255',
|
|
||||||
'event_name' => 'required|max:255',
|
|
||||||
'completed_at' => 'required|date',
|
|
||||||
'course_id' => 'required|exists:courses,id',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function persist(Member $member, NamiSettings $settings): void
|
|
||||||
{
|
|
||||||
$course = Course::where('id', $this->input('course_id'))->firstOrFail();
|
|
||||||
|
|
||||||
$payload = collect($this->input())->only(['event_name', 'completed_at', 'organizer'])->merge([
|
|
||||||
'course_id' => $course->nami_id,
|
|
||||||
])->toArray();
|
|
||||||
|
|
||||||
$namiId = $settings->login()->createCourse($member->nami_id, $payload);
|
|
||||||
|
|
||||||
$member->courses()->create($this->safe()->collect()->put('nami_id', $namiId)->toArray());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Course\Requests;
|
|
||||||
|
|
||||||
use App\Course\Models\Course;
|
|
||||||
use App\Course\Models\CourseMember;
|
|
||||||
use App\Member\Member;
|
|
||||||
use App\Setting\NamiSettings;
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
|
||||||
|
|
||||||
class UpdateRequest extends FormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Determine if the user is authorized to make this request.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function authorize()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public function rules()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'organizer' => 'required|max:255',
|
|
||||||
'event_name' => 'required|max:255',
|
|
||||||
'completed_at' => 'required|date',
|
|
||||||
'course_id' => 'required|exists:courses,id',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function persist(Member $member, CourseMember $course, NamiSettings $settings): void
|
|
||||||
{
|
|
||||||
$settings->login()->updateCourse(
|
|
||||||
$member->nami_id,
|
|
||||||
$course->nami_id,
|
|
||||||
$this->safe()->merge(['course_id' => Course::find($this->input('course_id'))->nami_id])->toArray()
|
|
||||||
);
|
|
||||||
|
|
||||||
$course->update($this->safe()->toArray());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace App\Course\Resources;
|
namespace App\Course\Resources;
|
||||||
|
|
||||||
|
use App\Course\Models\Course;
|
||||||
|
use App\Member\Member;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
@ -28,6 +30,29 @@ class CourseMemberResource extends JsonResource
|
||||||
'course_name' => $this->course->name,
|
'course_name' => $this->course->name,
|
||||||
'course_id' => $this->course->id,
|
'course_id' => $this->course->id,
|
||||||
'course' => new CourseResource($this->whenLoaded('course')),
|
'course' => new CourseResource($this->whenLoaded('course')),
|
||||||
|
'links' => [
|
||||||
|
'update' => route('course.update', ['course' => $this->getModel()]),
|
||||||
|
'destroy' => route('course.destroy', ['course' => $this->getModel()]),
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public static function memberMeta(Member $member): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'default' => [
|
||||||
|
'event_name' => '',
|
||||||
|
'completed_at' => null,
|
||||||
|
'course_id' => null,
|
||||||
|
'organizer' => ''
|
||||||
|
],
|
||||||
|
'courses' => Course::forSelect(),
|
||||||
|
'links' => [
|
||||||
|
'store' => route('member.course.store', ['member' => $member]),
|
||||||
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,28 +2,27 @@
|
||||||
|
|
||||||
namespace App\Lib\Events;
|
namespace App\Lib\Events;
|
||||||
|
|
||||||
|
use App\Lib\JobMiddleware\JobChannels;
|
||||||
use Illuminate\Broadcasting\Channel;
|
use Illuminate\Broadcasting\Channel;
|
||||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Ramsey\Uuid\Lazy\LazyUuidFromString;
|
|
||||||
use Ramsey\Uuid\UuidInterface;
|
use Ramsey\Uuid\UuidInterface;
|
||||||
|
|
||||||
class JobEvent implements ShouldBroadcastNow
|
class JobEvent implements ShouldBroadcastNow
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
public bool $reload = false;
|
|
||||||
public string $message = '';
|
public string $message = '';
|
||||||
|
|
||||||
final private function __construct(public string $channel, public UuidInterface $jobId)
|
final private function __construct(public UuidInterface $jobId)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function on(string $channel, UuidInterface $jobId): static
|
public static function on(UuidInterface $jobId): static
|
||||||
{
|
{
|
||||||
return new static($channel, $jobId);
|
return new static($jobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withMessage(string $message): static
|
public function withMessage(string $message): static
|
||||||
|
@ -46,15 +45,7 @@ class JobEvent implements ShouldBroadcastNow
|
||||||
public function broadcastOn()
|
public function broadcastOn()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new Channel($this->channel),
|
|
||||||
new Channel('jobs'),
|
new Channel('jobs'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function shouldReload(): static
|
|
||||||
{
|
|
||||||
$this->reload = true;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Lib\Events;
|
||||||
|
|
||||||
|
use App\Lib\JobMiddleware\JobChannels;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ReloadTriggered implements ShouldBroadcastNow
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
final private function __construct(public JobChannels $channels)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function on(JobChannels $channels): self
|
||||||
|
{
|
||||||
|
return new static($channels);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dispatch(): void
|
||||||
|
{
|
||||||
|
event($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return array<int, Channel>
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return $this->channels->toBroadcast();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Lib\JobMiddleware;
|
||||||
|
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Contracts\Support\Arrayable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implements Arrayable<int, string>
|
||||||
|
*/
|
||||||
|
class JobChannels implements Arrayable
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function make(): self
|
||||||
|
{
|
||||||
|
return new self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<int, string> $channels
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
public array $channels = []
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add(string $channelName): self
|
||||||
|
{
|
||||||
|
$this->channels[] = $channelName;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toArray(): array
|
||||||
|
{
|
||||||
|
return $this->channels;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, Channel>
|
||||||
|
*/
|
||||||
|
public function toBroadcast(): array
|
||||||
|
{
|
||||||
|
return array_map(fn ($channel) => new Channel($channel), $this->channels);
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,9 +5,9 @@ namespace App\Lib\JobMiddleware;
|
||||||
use App\Lib\Events\JobFailed;
|
use App\Lib\Events\JobFailed;
|
||||||
use App\Lib\Events\JobFinished;
|
use App\Lib\Events\JobFinished;
|
||||||
use App\Lib\Events\JobStarted;
|
use App\Lib\Events\JobStarted;
|
||||||
|
use App\Lib\Events\ReloadTriggered;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Lorisleiva\Actions\Decorators\JobDecorator;
|
use Lorisleiva\Actions\Decorators\JobDecorator;
|
||||||
use Ramsey\Uuid\Lazy\LazyUuidFromString;
|
|
||||||
use Ramsey\Uuid\UuidInterface;
|
use Ramsey\Uuid\UuidInterface;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
|
@ -17,51 +17,47 @@ class WithJobState
|
||||||
public ?JobStarted $beforeMessage = null;
|
public ?JobStarted $beforeMessage = null;
|
||||||
public ?JobFinished $afterMessage = null;
|
public ?JobFinished $afterMessage = null;
|
||||||
public ?JobFailed $failedMessage = null;
|
public ?JobFailed $failedMessage = null;
|
||||||
|
public ?ReloadTriggered $reloadAfter = null;
|
||||||
|
|
||||||
private function __construct(public string $channel, public UuidInterface $jobId)
|
private function __construct(public UuidInterface $jobId)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function make(string $channel, UuidInterface $jobId): self
|
public static function make(UuidInterface $jobId): self
|
||||||
{
|
{
|
||||||
return new self($channel, $jobId);
|
return new self($jobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function before(string $message): self
|
public function before(string $message): self
|
||||||
{
|
{
|
||||||
$this->beforeMessage = JobStarted::on($this->channel, $this->jobId)->withMessage($message);
|
$this->beforeMessage = JobStarted::on($this->jobId)->withMessage($message);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function after(string $message): self
|
public function after(string $message): self
|
||||||
{
|
{
|
||||||
$this->afterMessage = JobFinished::on($this->channel, $this->jobId)->withMessage($message);
|
$this->afterMessage = JobFinished::on($this->jobId)->withMessage($message);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function failed(string $message): self
|
public function failed(string $message): self
|
||||||
{
|
{
|
||||||
$this->failedMessage = JobFailed::on($this->channel, $this->jobId)->withMessage($message);
|
$this->failedMessage = JobFailed::on($this->jobId)->withMessage($message);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function shouldReload(): self
|
public function shouldReload(JobChannels $channels): self
|
||||||
{
|
{
|
||||||
$this->afterMessage?->shouldReload();
|
$this->reloadAfter = ReloadTriggered::on($channels);
|
||||||
$this->failedMessage?->shouldReload();
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(JobDecorator $job, Closure $next): void
|
public function handle(JobDecorator $job, Closure $next): void
|
||||||
{
|
{
|
||||||
if ($this->beforeMessage) {
|
|
||||||
event($this->beforeMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$next($job);
|
$next($job);
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
|
@ -74,5 +70,9 @@ class WithJobState
|
||||||
if ($this->afterMessage) {
|
if ($this->afterMessage) {
|
||||||
event($this->afterMessage);
|
event($this->afterMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->reloadAfter) {
|
||||||
|
event($this->reloadAfter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
namespace App\Lib\Queue;
|
namespace App\Lib\Queue;
|
||||||
|
|
||||||
|
use App\Lib\JobMiddleware\JobChannels;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use App\Lib\JobMiddleware\WithJobState;
|
use App\Lib\JobMiddleware\WithJobState;
|
||||||
|
|
||||||
trait TracksJob
|
trait TracksJob
|
||||||
{
|
{
|
||||||
abstract public function jobState(WithJobState $jobState, ...$parameters): WithJobState;
|
abstract public function jobState(WithJobState $jobState, ...$parameters): WithJobState;
|
||||||
abstract public function jobChannel(): string;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $parameters
|
* @param mixed $parameters
|
||||||
|
@ -16,7 +16,7 @@ trait TracksJob
|
||||||
public function startJob(...$parameters): void
|
public function startJob(...$parameters): void
|
||||||
{
|
{
|
||||||
$jobId = Str::uuid();
|
$jobId = Str::uuid();
|
||||||
$jobState = WithJobState::make($this->jobChannel(), $jobId);
|
$jobState = WithJobState::make($jobId);
|
||||||
$this->jobState(...[$jobState, ...$parameters])->beforeMessage->dispatch();
|
$this->jobState(...[$jobState, ...$parameters])->beforeMessage->dispatch();
|
||||||
$parameters[] = $jobId;
|
$parameters[] = $jobId;
|
||||||
static::dispatch(...$parameters);
|
static::dispatch(...$parameters);
|
||||||
|
@ -30,7 +30,7 @@ trait TracksJob
|
||||||
public function getJobMiddleware(...$parameters): array
|
public function getJobMiddleware(...$parameters): array
|
||||||
{
|
{
|
||||||
$jobId = array_pop($parameters);
|
$jobId = array_pop($parameters);
|
||||||
$jobState = WithJobState::make($this->jobChannel(), $jobId);
|
$jobState = WithJobState::make($jobId);
|
||||||
$jobState = $this->jobState(...[$jobState, ...$parameters]);
|
$jobState = $this->jobState(...[$jobState, ...$parameters]);
|
||||||
$jobState->beforeMessage = null;
|
$jobState->beforeMessage = null;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Member\Actions;
|
namespace App\Member\Actions;
|
||||||
|
|
||||||
|
use App\Lib\JobMiddleware\JobChannels;
|
||||||
use App\Lib\JobMiddleware\WithJobState;
|
use App\Lib\JobMiddleware\WithJobState;
|
||||||
use App\Lib\Queue\TracksJob;
|
use App\Lib\Queue\TracksJob;
|
||||||
use App\Maildispatcher\Actions\ResyncAction;
|
use App\Maildispatcher\Actions\ResyncAction;
|
||||||
|
@ -45,11 +46,6 @@ class MemberDeleteAction
|
||||||
->before('Mitglied ' . $member->fullname . ' wird gelöscht')
|
->before('Mitglied ' . $member->fullname . ' wird gelöscht')
|
||||||
->after('Mitglied ' . $member->fullname . ' gelöscht')
|
->after('Mitglied ' . $member->fullname . ' gelöscht')
|
||||||
->failed('Löschen von ' . $member->fullname . ' fehlgeschlagen.')
|
->failed('Löschen von ' . $member->fullname . ' fehlgeschlagen.')
|
||||||
->shouldReload();
|
->shouldReload(JobChannels::make()->add('member'));
|
||||||
}
|
|
||||||
|
|
||||||
public function jobChannel(): string
|
|
||||||
{
|
|
||||||
return 'member';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ class MemberController extends Controller
|
||||||
'data' => MemberResource::collection(Member::search($filter->search)->query(
|
'data' => MemberResource::collection(Member::search($filter->search)->query(
|
||||||
fn ($q) => $q->select('*')
|
fn ($q) => $q->select('*')
|
||||||
->withFilter($filter)
|
->withFilter($filter)
|
||||||
->with(['payments.subscription', 'courses', 'subscription', 'leaderMemberships', 'ageGroupMemberships'])
|
->with(['subscription', 'leaderMemberships', 'ageGroupMemberships'])
|
||||||
->withPendingPayment()
|
->withPendingPayment()
|
||||||
->ordered()
|
->ordered()
|
||||||
)->paginate(15)),
|
)->paginate(15)),
|
||||||
|
|
|
@ -106,6 +106,8 @@ class MemberResource extends JsonResource
|
||||||
'lon' => $this->lon,
|
'lon' => $this->lon,
|
||||||
'links' => [
|
'links' => [
|
||||||
'membership_index' => route('member.membership.index', ['member' => $this->getModel()]),
|
'membership_index' => route('member.membership.index', ['member' => $this->getModel()]),
|
||||||
|
'payment_index' => route('member.payment.index', ['member' => $this->getModel()]),
|
||||||
|
'course_index' => route('member.course.index', ['member' => $this->getModel()]),
|
||||||
'show' => route('member.show', ['member' => $this->getModel()]),
|
'show' => route('member.show', ['member' => $this->getModel()]),
|
||||||
'edit' => route('member.edit', ['member' => $this->getModel()]),
|
'edit' => route('member.edit', ['member' => $this->getModel()]),
|
||||||
],
|
],
|
||||||
|
@ -135,7 +137,6 @@ class MemberResource extends JsonResource
|
||||||
'filter' => FilterScope::fromRequest(request()->input('filter', '')),
|
'filter' => FilterScope::fromRequest(request()->input('filter', '')),
|
||||||
'courses' => Course::pluck('name', 'id'),
|
'courses' => Course::pluck('name', 'id'),
|
||||||
'regions' => Region::forSelect(),
|
'regions' => Region::forSelect(),
|
||||||
'statuses' => Status::pluck('name', 'id'),
|
|
||||||
'subscriptions' => Subscription::pluck('name', 'id'),
|
'subscriptions' => Subscription::pluck('name', 'id'),
|
||||||
'countries' => Country::pluck('name', 'id'),
|
'countries' => Country::pluck('name', 'id'),
|
||||||
'genders' => Gender::pluck('name', 'id'),
|
'genders' => Gender::pluck('name', 'id'),
|
||||||
|
|
|
@ -7,11 +7,9 @@ use App\Member\Membership;
|
||||||
use App\Membership\MembershipResource;
|
use App\Membership\MembershipResource;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
class ApiIndexAction
|
class IndexAction
|
||||||
{
|
{
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use Illuminate\Http\JsonResponse;
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
class ApiListAction
|
class ListForGroupAction
|
||||||
{
|
{
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
|
|
@ -2,45 +2,59 @@
|
||||||
|
|
||||||
namespace App\Membership\Actions;
|
namespace App\Membership\Actions;
|
||||||
|
|
||||||
|
use App\Lib\JobMiddleware\JobChannels;
|
||||||
|
use App\Lib\JobMiddleware\WithJobState;
|
||||||
|
use App\Lib\Queue\TracksJob;
|
||||||
use App\Maildispatcher\Actions\ResyncAction;
|
use App\Maildispatcher\Actions\ResyncAction;
|
||||||
use App\Member\Member;
|
|
||||||
use App\Member\Membership;
|
use App\Member\Membership;
|
||||||
use App\Setting\NamiSettings;
|
use App\Setting\NamiSettings;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
class MembershipDestroyAction
|
class MembershipDestroyAction
|
||||||
{
|
{
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
use TracksJob;
|
||||||
|
|
||||||
public function handle(Member $member, Membership $membership, NamiSettings $settings): void
|
public function handle(int $membershipId): void
|
||||||
{
|
{
|
||||||
$api = $settings->login();
|
$membership = Membership::find($membershipId);
|
||||||
|
$api = app(NamiSettings::class)->login();
|
||||||
|
|
||||||
if ($membership->hasNami) {
|
if ($membership->hasNami) {
|
||||||
$settings->login()->deleteMembership(
|
$api->deleteMembership(
|
||||||
$member->nami_id,
|
$membership->member->nami_id,
|
||||||
$api->membership($member->nami_id, $membership->nami_id)
|
$api->membership($membership->member->nami_id, $membership->nami_id)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$membership->delete();
|
$membership->delete();
|
||||||
|
|
||||||
if ($membership->hasNami) {
|
if ($membership->hasNami) {
|
||||||
$member->syncVersion();
|
$membership->member->syncVersion();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function asController(Membership $membership, NamiSettings $settings): JsonResponse
|
|
||||||
{
|
|
||||||
$this->handle(
|
|
||||||
$membership->member,
|
|
||||||
$membership,
|
|
||||||
$settings,
|
|
||||||
);
|
|
||||||
|
|
||||||
ResyncAction::dispatch();
|
ResyncAction::dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asController(Membership $membership): JsonResponse
|
||||||
|
{
|
||||||
|
$this->startJob($membership->id, $membership->member->fullname);
|
||||||
|
|
||||||
return response()->json([]);
|
return response()->json([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $parameters
|
||||||
|
*/
|
||||||
|
public function jobState(WithJobState $jobState, ...$parameters): WithJobState
|
||||||
|
{
|
||||||
|
$memberName = $parameters[1];
|
||||||
|
|
||||||
|
return $jobState
|
||||||
|
->before('Mitgliedschaft für ' . $memberName . ' wird gelöscht')
|
||||||
|
->after('Mitgliedschaft für ' . $memberName . ' gelöscht')
|
||||||
|
->failed('Fehler beim Löschen der Mitgliedschaft für ' . $memberName)
|
||||||
|
->shouldReload(JobChannels::make()->add('member')->add('membership'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,16 @@ namespace App\Membership\Actions;
|
||||||
|
|
||||||
use App\Activity;
|
use App\Activity;
|
||||||
use App\Group;
|
use App\Group;
|
||||||
|
use App\Lib\JobMiddleware\JobChannels;
|
||||||
|
use App\Lib\JobMiddleware\WithJobState;
|
||||||
|
use App\Lib\Queue\TracksJob;
|
||||||
use App\Maildispatcher\Actions\ResyncAction;
|
use App\Maildispatcher\Actions\ResyncAction;
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use App\Member\Membership;
|
use App\Member\Membership;
|
||||||
use App\Setting\NamiSettings;
|
use App\Setting\NamiSettings;
|
||||||
use App\Subactivity;
|
use App\Subactivity;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Illuminate\Validation\Rules\In;
|
use Illuminate\Validation\Rules\In;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
@ -22,8 +25,9 @@ use Zoomyboy\LaravelNami\Exceptions\HttpException;
|
||||||
class MembershipStoreAction
|
class MembershipStoreAction
|
||||||
{
|
{
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
use TracksJob;
|
||||||
|
|
||||||
public function handle(Member $member, Activity $activity, ?Subactivity $subactivity, Group $group, ?Carbon $promisedAt, NamiSettings $settings): Membership
|
public function handle(Member $member, Activity $activity, ?Subactivity $subactivity, Group $group, ?Carbon $promisedAt): Membership
|
||||||
{
|
{
|
||||||
$from = now()->startOfDay();
|
$from = now()->startOfDay();
|
||||||
|
|
||||||
|
@ -31,7 +35,7 @@ class MembershipStoreAction
|
||||||
|
|
||||||
if ($activity->hasNami && ($subactivity->id === null || $subactivity->hasNami)) {
|
if ($activity->hasNami && ($subactivity->id === null || $subactivity->hasNami)) {
|
||||||
try {
|
try {
|
||||||
$namiId = $settings->login()->putMembership($member->nami_id, NamiMembership::from([
|
$namiId = app(NamiSettings::class)->login()->putMembership($member->nami_id, NamiMembership::from([
|
||||||
'startsAt' => $from,
|
'startsAt' => $from,
|
||||||
'groupId' => $group->nami_id,
|
'groupId' => $group->nami_id,
|
||||||
'activityId' => $activity->nami_id,
|
'activityId' => $activity->nami_id,
|
||||||
|
@ -55,6 +59,8 @@ class MembershipStoreAction
|
||||||
$member->syncVersion();
|
$member->syncVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResyncAction::dispatch();
|
||||||
|
|
||||||
return $membership;
|
return $membership;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,19 +91,30 @@ class MembershipStoreAction
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function asController(Member $member, ActionRequest $request, NamiSettings $settings): RedirectResponse
|
public function asController(Member $member, ActionRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$this->handle(
|
$this->startJob(
|
||||||
$member,
|
$member,
|
||||||
Activity::find($request->activity_id),
|
Activity::find($request->activity_id),
|
||||||
$request->subactivity_id ? Subactivity::find($request->subactivity_id) : null,
|
$request->subactivity_id ? Subactivity::find($request->subactivity_id) : null,
|
||||||
Group::findOrFail($request->input('group_id', -1)),
|
Group::findOrFail($request->input('group_id', -1)),
|
||||||
$request->promised_at ? Carbon::parse($request->promised_at) : null,
|
$request->promised_at ? Carbon::parse($request->promised_at) : null,
|
||||||
$settings,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
ResyncAction::dispatch();
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
/**
|
||||||
|
* @param mixed $parameters
|
||||||
|
*/
|
||||||
|
public function jobState(WithJobState $jobState, ...$parameters): WithJobState
|
||||||
|
{
|
||||||
|
$member = $parameters[0];
|
||||||
|
|
||||||
|
return $jobState
|
||||||
|
->before('Mitgliedschaft für ' . $member->fullname . ' wird gespeichert')
|
||||||
|
->after('Mitgliedschaft für ' . $member->fullname . ' gespeichert')
|
||||||
|
->failed('Fehler beim Erstellen der Mitgliedschaft für ' . $member->fullname)
|
||||||
|
->shouldReload(JobChannels::make()->add('member')->add('membership'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
namespace App\Membership\Actions;
|
namespace App\Membership\Actions;
|
||||||
|
|
||||||
use App\Activity;
|
use App\Activity;
|
||||||
|
use App\Lib\JobMiddleware\JobChannels;
|
||||||
|
use App\Lib\JobMiddleware\WithJobState;
|
||||||
|
use App\Lib\Queue\TracksJob;
|
||||||
use App\Maildispatcher\Actions\ResyncAction;
|
use App\Maildispatcher\Actions\ResyncAction;
|
||||||
use App\Member\Membership;
|
use App\Member\Membership;
|
||||||
use App\Subactivity;
|
use App\Subactivity;
|
||||||
|
@ -16,6 +19,7 @@ use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
class MembershipUpdateAction
|
class MembershipUpdateAction
|
||||||
{
|
{
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
use TracksJob;
|
||||||
|
|
||||||
public function handle(Membership $membership, Activity $activity, ?Subactivity $subactivity, ?Carbon $promisedAt): Membership
|
public function handle(Membership $membership, Activity $activity, ?Subactivity $subactivity, ?Carbon $promisedAt): Membership
|
||||||
{
|
{
|
||||||
|
@ -25,6 +29,8 @@ class MembershipUpdateAction
|
||||||
'promised_at' => $promisedAt,
|
'promised_at' => $promisedAt,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
ResyncAction::dispatch();
|
||||||
|
|
||||||
return $membership;
|
return $membership;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,15 +61,27 @@ class MembershipUpdateAction
|
||||||
|
|
||||||
public function asController(Membership $membership, ActionRequest $request): JsonResponse
|
public function asController(Membership $membership, ActionRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$this->handle(
|
$this->startJob(
|
||||||
$membership,
|
$membership,
|
||||||
Activity::find($request->activity_id),
|
Activity::find($request->activity_id),
|
||||||
$request->subactivity_id ? Subactivity::find($request->subactivity_id) : null,
|
$request->subactivity_id ? Subactivity::find($request->subactivity_id) : null,
|
||||||
$request->promised_at ? Carbon::parse($request->promised_at) : null,
|
$request->promised_at ? Carbon::parse($request->promised_at) : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
ResyncAction::dispatch();
|
|
||||||
|
|
||||||
return response()->json([]);
|
return response()->json([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $parameters
|
||||||
|
*/
|
||||||
|
public function jobState(WithJobState $jobState, ...$parameters): WithJobState
|
||||||
|
{
|
||||||
|
$member = $parameters[0]->member;
|
||||||
|
|
||||||
|
return $jobState
|
||||||
|
->before('Mitgliedschaft für ' . $member->fullname . ' wird aktualisiert')
|
||||||
|
->after('Mitgliedschaft für ' . $member->fullname . ' aktualisiert')
|
||||||
|
->failed('Fehler beim Aktualisieren der Mitgliedschaft für ' . $member->fullname)
|
||||||
|
->shouldReload(JobChannels::make()->add('member')->add('membership'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,12 @@ use App\Lib\Queue\TracksJob;
|
||||||
use App\Maildispatcher\Actions\ResyncAction;
|
use App\Maildispatcher\Actions\ResyncAction;
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use App\Member\Membership;
|
use App\Member\Membership;
|
||||||
use App\Setting\NamiSettings;
|
|
||||||
use App\Subactivity;
|
use App\Subactivity;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
class SyncAction
|
class StoreForGroupAction
|
||||||
{
|
{
|
||||||
use AsAction;
|
use AsAction;
|
||||||
use TracksJob;
|
use TracksJob;
|
||||||
|
@ -47,7 +46,7 @@ class SyncAction
|
||||||
];
|
];
|
||||||
|
|
||||||
Membership::where($attributes)->active()->whereNotIn('member_id', $members)->get()
|
Membership::where($attributes)->active()->whereNotIn('member_id', $members)->get()
|
||||||
->each(fn ($membership) => MembershipDestroyAction::run($membership->member, $membership, app(NamiSettings::class)));
|
->each(fn ($membership) => MembershipDestroyAction::run($membership));
|
||||||
|
|
||||||
collect($members)
|
collect($members)
|
||||||
->except(Membership::where($attributes)->active()->pluck('member_id'))
|
->except(Membership::where($attributes)->active()->pluck('member_id'))
|
||||||
|
@ -58,7 +57,6 @@ class SyncAction
|
||||||
$subactivity,
|
$subactivity,
|
||||||
$group,
|
$group,
|
||||||
null,
|
null,
|
||||||
app(NamiSettings::class),
|
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,9 +89,4 @@ class SyncAction
|
||||||
->after('Gruppen aktualisiert')
|
->after('Gruppen aktualisiert')
|
||||||
->failed('Aktualisieren von Gruppen fehlgeschlagen');
|
->failed('Aktualisieren von Gruppen fehlgeschlagen');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function jobChannel(): string
|
|
||||||
{
|
|
||||||
return 'group';
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Membership;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Member\Member;
|
|
||||||
use App\Member\Membership;
|
|
||||||
use App\Setting\NamiSettings;
|
|
||||||
use Illuminate\Http\RedirectResponse;
|
|
||||||
|
|
||||||
class MembershipController extends Controller
|
|
||||||
{
|
|
||||||
public function destroy(Member $member, Membership $membership, NamiSettings $settings): RedirectResponse
|
|
||||||
{
|
|
||||||
$api = $settings->login();
|
|
||||||
$api->deleteMembership(
|
|
||||||
$member->nami_id,
|
|
||||||
$api->membership($member->nami_id, $membership->nami_id)
|
|
||||||
);
|
|
||||||
$membership->delete();
|
|
||||||
$member->syncVersion();
|
|
||||||
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Payment\Actions;
|
||||||
|
|
||||||
|
use App\Member\Member;
|
||||||
|
use App\Payment\Payment;
|
||||||
|
use App\Payment\PaymentResource;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class IndexAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, Payment>
|
||||||
|
*/
|
||||||
|
public function handle(Member $member): Collection
|
||||||
|
{
|
||||||
|
return $member->payments()->with('subscription')->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asController(Member $member): AnonymousResourceCollection
|
||||||
|
{
|
||||||
|
return PaymentResource::collection($this->handle($member))
|
||||||
|
->additional([
|
||||||
|
'meta' => PaymentResource::memberMeta($member),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Payment\Actions;
|
||||||
|
|
||||||
|
use App\Lib\JobMiddleware\JobChannels;
|
||||||
|
use App\Lib\JobMiddleware\WithJobState;
|
||||||
|
use App\Lib\Queue\TracksJob;
|
||||||
|
use App\Payment\Payment;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class PaymentDestroyAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
use TracksJob;
|
||||||
|
|
||||||
|
public function handle(int $paymentId): void
|
||||||
|
{
|
||||||
|
Payment::find($paymentId)->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asController(Payment $payment): JsonResponse
|
||||||
|
{
|
||||||
|
$this->startJob($payment->id, $payment->member->fullname);
|
||||||
|
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $parameters
|
||||||
|
*/
|
||||||
|
public function jobState(WithJobState $jobState, ...$parameters): WithJobState
|
||||||
|
{
|
||||||
|
$memberName = $parameters[1];
|
||||||
|
|
||||||
|
return $jobState
|
||||||
|
->before('Zahlung für ' . $memberName . ' wird gelöscht')
|
||||||
|
->after('Zahlung für ' . $memberName . ' gelöscht')
|
||||||
|
->failed('Fehler beim Löschen der Zahlung für ' . $memberName)
|
||||||
|
->shouldReload(JobChannels::make()->add('member')->add('payment'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Payment\Actions;
|
||||||
|
|
||||||
|
use App\Lib\JobMiddleware\JobChannels;
|
||||||
|
use App\Lib\JobMiddleware\WithJobState;
|
||||||
|
use App\Lib\Queue\TracksJob;
|
||||||
|
use App\Member\Member;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Validation\Rules\In;
|
||||||
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class PaymentStoreAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
use TracksJob;
|
||||||
|
|
||||||
|
public function handle(Member $member, array $attributes): void
|
||||||
|
{
|
||||||
|
$member->createPayment($attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, array<int, string|In>>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'nr' => 'required',
|
||||||
|
'subscription_id' => 'required|exists:subscriptions,id',
|
||||||
|
'status_id' => 'required|exists:statuses,id',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asController(Member $member, ActionRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$this->startJob($member, $request->validated());
|
||||||
|
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $parameters
|
||||||
|
*/
|
||||||
|
public function jobState(WithJobState $jobState, ...$parameters): WithJobState
|
||||||
|
{
|
||||||
|
$member = $parameters[0];
|
||||||
|
|
||||||
|
return $jobState
|
||||||
|
->before('Zahlung für ' . $member->fullname . ' wird gespeichert')
|
||||||
|
->after('Zahlung für ' . $member->fullname . ' gespeichert')
|
||||||
|
->failed('Fehler beim Erstellen der Zahlung für ' . $member->fullname)
|
||||||
|
->shouldReload(JobChannels::make()->add('member')->add('payment'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Payment\Actions;
|
||||||
|
|
||||||
|
use App\Lib\JobMiddleware\JobChannels;
|
||||||
|
use App\Lib\JobMiddleware\WithJobState;
|
||||||
|
use App\Lib\Queue\TracksJob;
|
||||||
|
use App\Payment\Payment;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Validation\Rules\In;
|
||||||
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class PaymentUpdateAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
use TracksJob;
|
||||||
|
|
||||||
|
public function handle(Payment $payment, array $attributes): void
|
||||||
|
{
|
||||||
|
$payment->update($attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, array<int, string|In>>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'nr' => 'required',
|
||||||
|
'subscription_id' => 'required|exists:subscriptions,id',
|
||||||
|
'status_id' => 'required|exists:statuses,id',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asController(Payment $payment, ActionRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$this->startJob($payment, $request->validated());
|
||||||
|
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $parameters
|
||||||
|
*/
|
||||||
|
public function jobState(WithJobState $jobState, ...$parameters): WithJobState
|
||||||
|
{
|
||||||
|
$member = $parameters[0]->member;
|
||||||
|
|
||||||
|
return $jobState
|
||||||
|
->before('Zahlung für ' . $member->fullname . ' wird aktualisiert')
|
||||||
|
->after('Zahlung für ' . $member->fullname . ' aktualisiert')
|
||||||
|
->failed('Fehler beim Aktualisieren der Zahlung für ' . $member->fullname)
|
||||||
|
->shouldReload(JobChannels::make()->add('member')->add('payment'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,47 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Payment;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Lib\Events\ClientMessage;
|
|
||||||
use App\Member\Member;
|
|
||||||
use Illuminate\Http\RedirectResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class PaymentController extends Controller
|
|
||||||
{
|
|
||||||
public function store(Request $request, Member $member): RedirectResponse
|
|
||||||
{
|
|
||||||
$member->createPayment($request->validate([
|
|
||||||
'nr' => 'required',
|
|
||||||
'subscription_id' => 'required|exists:subscriptions,id',
|
|
||||||
'status_id' => 'required|exists:statuses,id',
|
|
||||||
]));
|
|
||||||
|
|
||||||
ClientMessage::make('Zahlung erstellt.')->shouldReload()->dispatch();
|
|
||||||
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(Request $request, Member $member, Payment $payment): RedirectResponse
|
|
||||||
{
|
|
||||||
$payment->update($request->validate([
|
|
||||||
'nr' => 'required',
|
|
||||||
'subscription_id' => 'required|exists:subscriptions,id',
|
|
||||||
'status_id' => 'required|exists:statuses,id',
|
|
||||||
]));
|
|
||||||
|
|
||||||
ClientMessage::make('Zahlung aktualisiert.')->shouldReload()->dispatch();
|
|
||||||
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function destroy(Request $request, Member $member, Payment $payment): RedirectResponse
|
|
||||||
{
|
|
||||||
$payment->delete();
|
|
||||||
|
|
||||||
ClientMessage::make('Zahlung gelöscht.')->shouldReload()->dispatch();
|
|
||||||
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Payment;
|
namespace App\Payment;
|
||||||
|
|
||||||
|
use App\Member\Member;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,6 +27,29 @@ class PaymentResource extends JsonResource
|
||||||
'nr' => $this->nr,
|
'nr' => $this->nr,
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'is_accepted' => $this->status->isAccepted(),
|
'is_accepted' => $this->status->isAccepted(),
|
||||||
|
'links' => [
|
||||||
|
'update' => route('payment.update', ['payment' => $this->getModel()]),
|
||||||
|
'destroy' => route('payment.destroy', ['payment' => $this->getModel()]),
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public static function memberMeta(Member $member): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'statuses' => Status::forSelect(),
|
||||||
|
'subscriptions' => Subscription::forSelect(),
|
||||||
|
'default' => [
|
||||||
|
'nr' => '',
|
||||||
|
'subscription_id' => null,
|
||||||
|
'status_id' => null
|
||||||
|
],
|
||||||
|
'links' => [
|
||||||
|
'store' => route('member.payment.store', ['member' => $member]),
|
||||||
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,4 +38,12 @@ class Status extends Model
|
||||||
return $query->where('is_bill', true)->orWhere('is_remember', true);
|
return $query->where('is_bill', true)->orWhere('is_remember', true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array{name: string, id: int}>
|
||||||
|
*/
|
||||||
|
public static function forSelect(): array
|
||||||
|
{
|
||||||
|
return static::select('name', 'id')->get()->toArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,4 +50,12 @@ class Subscription extends Model
|
||||||
{
|
{
|
||||||
static::deleting(fn ($model) => $model->children()->delete());
|
static::deleting(fn ($model) => $model->children()->delete());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array{name: string, id: int}>
|
||||||
|
*/
|
||||||
|
public static function forSelect(): array
|
||||||
|
{
|
||||||
|
return static::select('name', 'id')->get()->toArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,6 @@
|
||||||
echo "drop database scoutrobot;" | sudo mysql
|
echo "drop database scoutrobot;" | sudo mysql
|
||||||
echo "create database scoutrobot;" | sudo mysql
|
echo "create database scoutrobot;" | sudo mysql
|
||||||
|
|
||||||
ssh -l stammsilva zoomyboy.de "mysqldump -u nami -p$SCOUTROBOT_DB_PASSWORD nami" > db.tmp && sudo mysql scoutrobot < db.tmp
|
ssh -l stammsilva zoomyboy.de "cd /usr/share/webapps/nami_silva && docker compose exec db mysqldump -udb -p$SCOUTROBOT_DB_PASSWORD db" > db.tmp
|
||||||
|
sudo mysql scoutrobot < db.tmp
|
||||||
rm db.tmp
|
rm db.tmp
|
||||||
|
|
|
@ -7,6 +7,5 @@
|
||||||
@import 'layout';
|
@import 'layout';
|
||||||
@import 'buttons';
|
@import 'buttons';
|
||||||
@import 'table';
|
@import 'table';
|
||||||
@import 'sidebar';
|
|
||||||
@import 'bool';
|
@import 'bool';
|
||||||
@import 'form';
|
@import 'form';
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
.sidebar {
|
|
||||||
@apply fixed w-max shadow-2xl bg-gray-600 right-0 top-0 h-full;
|
|
||||||
}
|
|
|
@ -6,7 +6,7 @@
|
||||||
<slot name="toolbar"></slot>
|
<slot name="toolbar"></slot>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center space-x-2 ml-2">
|
<div class="flex items-center space-x-2 ml-2">
|
||||||
<a href="#" v-if="$attrs.onClose" @click.prevent="$emit('close')" class="btn label btn-primary-light icon">
|
<a v-if="$attrs.onClose" href="#" class="btn label btn-primary-light icon" @click.prevent="$emit('close')">
|
||||||
<ui-sprite class="w-3 h-3" src="close"></ui-sprite>
|
<ui-sprite class="w-3 h-3" src="close"></ui-sprite>
|
||||||
</a>
|
</a>
|
||||||
<slot name="right"></slot>
|
<slot name="right"></slot>
|
||||||
|
@ -14,14 +14,13 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
export default {
|
defineProps({
|
||||||
props: {
|
|
||||||
title: {
|
title: {
|
||||||
|
type: String,
|
||||||
default: function () {
|
default: function () {
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="fixed w-full w-[80vw] max-w-[40rem] shadow-2xl bg-gray-600 right-0 top-0 h-full flex flex-col group is-bright">
|
||||||
|
<suspense>
|
||||||
|
<slot></slot>
|
||||||
|
|
||||||
|
<template #fallback>
|
||||||
|
<div class="flex flex-col h-full">
|
||||||
|
<page-header title="Lade …" @close="$emit('close')"> </page-header>
|
||||||
|
<div class="grow flex items-center justify-center">
|
||||||
|
<ui-spinner class="border-primary-400 w-32 h-32"></ui-spinner>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</suspense>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
defineEmits(['close']);
|
||||||
|
</script>
|
|
@ -0,0 +1,83 @@
|
||||||
|
import {ref, inject, onBeforeUnmount} from 'vue';
|
||||||
|
import {router} from '@inertiajs/vue3';
|
||||||
|
import useQueueEvents from './useQueueEvents.js';
|
||||||
|
|
||||||
|
export function useApiIndex(url, siteName) {
|
||||||
|
const axios = inject('axios');
|
||||||
|
const {startListener, stopListener} = useQueueEvents(siteName, () => reload());
|
||||||
|
const single = ref(null);
|
||||||
|
const inner = {
|
||||||
|
data: ref([]),
|
||||||
|
meta: ref({}),
|
||||||
|
};
|
||||||
|
|
||||||
|
async function reload(resetPage = true) {
|
||||||
|
var params = {
|
||||||
|
page: resetPage ? 1 : inner.meta.value.current_page,
|
||||||
|
};
|
||||||
|
|
||||||
|
var response = (await axios.get(url, params)).data;
|
||||||
|
inner.data.value = response.data;
|
||||||
|
inner.meta.value = response.meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
function create() {
|
||||||
|
single.value = JSON.parse(JSON.stringify(inner.meta.value.default));
|
||||||
|
}
|
||||||
|
|
||||||
|
function edit(model) {
|
||||||
|
single.value = JSON.parse(JSON.stringify(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submit() {
|
||||||
|
single.value.id ? await axios.patch(single.value.links.update, single.value) : await axios.post(inner.meta.value.links.store, single.value);
|
||||||
|
await reload();
|
||||||
|
single.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function remove(model) {
|
||||||
|
await axios.delete(model.links.destroy);
|
||||||
|
await reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function can(permission) {
|
||||||
|
return inner.meta.value.can[permission];
|
||||||
|
}
|
||||||
|
|
||||||
|
function requestCallback(successMessage, failureMessage) {
|
||||||
|
return {
|
||||||
|
onSuccess: () => {
|
||||||
|
this.$success(successMessage);
|
||||||
|
reload(false);
|
||||||
|
},
|
||||||
|
onFailure: () => {
|
||||||
|
this.$error(failureMessage);
|
||||||
|
reload(false);
|
||||||
|
},
|
||||||
|
preserveState: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancel() {
|
||||||
|
single.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
startListener();
|
||||||
|
onBeforeUnmount(() => stopListener());
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: inner.data,
|
||||||
|
meta: inner.meta,
|
||||||
|
single,
|
||||||
|
create,
|
||||||
|
edit,
|
||||||
|
reload,
|
||||||
|
can,
|
||||||
|
requestCallback,
|
||||||
|
router,
|
||||||
|
submit,
|
||||||
|
remove,
|
||||||
|
cancel,
|
||||||
|
axios,
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,27 +1,10 @@
|
||||||
import {useToast} from 'vue-toastification';
|
|
||||||
const toast = useToast();
|
|
||||||
|
|
||||||
function handleJobEvent(event, type = 'success', reloadCallback) {
|
|
||||||
if (event.message) {
|
|
||||||
toast[type](event.message);
|
|
||||||
}
|
|
||||||
if (event.reload) {
|
|
||||||
reloadCallback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function (siteName, reloadCallback) {
|
export default function (siteName, reloadCallback) {
|
||||||
return {
|
return {
|
||||||
startListener: function () {
|
startListener: function () {
|
||||||
window.Echo.channel('jobs').listen('\\App\\Lib\\Events\\ClientMessage', (e) => handleJobEvent(e, 'success', reloadCallback));
|
window.Echo.channel(siteName).listen('\\App\\Lib\\Events\\ReloadTriggered', () => reloadCallback());
|
||||||
window.Echo.channel(siteName)
|
|
||||||
.listen('\\App\\Lib\\Events\\JobStarted', (e) => handleJobEvent(e, 'success', reloadCallback))
|
|
||||||
.listen('\\App\\Lib\\Events\\JobFinished', (e) => handleJobEvent(e, 'success', reloadCallback))
|
|
||||||
.listen('\\App\\Lib\\Events\\JobFailed', (e) => handleJobEvent(e, 'error', reloadCallback));
|
|
||||||
},
|
},
|
||||||
stopListener() {
|
stopListener() {
|
||||||
window.Echo.leave(siteName);
|
window.Echo.leave(siteName);
|
||||||
window.Echo.leave('jobs');
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
import Pusher from 'pusher-js';
|
import Pusher from 'pusher-js';
|
||||||
import Echo from 'laravel-echo';
|
import Echo from 'laravel-echo';
|
||||||
|
import {useToast} from 'vue-toastification';
|
||||||
|
|
||||||
|
const toast = useToast();
|
||||||
|
|
||||||
window.Pusher = Pusher;
|
window.Pusher = Pusher;
|
||||||
export default new Echo({
|
|
||||||
|
function handleJobEvent(event, type = 'success') {
|
||||||
|
if (event.message) {
|
||||||
|
toast[type](event.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var echo = new Echo({
|
||||||
broadcaster: 'pusher',
|
broadcaster: 'pusher',
|
||||||
key: 'adremakey',
|
key: 'adremakey',
|
||||||
wsHost: window.location.hostname,
|
wsHost: window.location.hostname,
|
||||||
|
@ -13,3 +23,10 @@ export default new Echo({
|
||||||
cluster: 'adrema',
|
cluster: 'adrema',
|
||||||
enabledTransports: ['ws', 'wss'],
|
enabledTransports: ['ws', 'wss'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
echo.channel('jobs')
|
||||||
|
.listen('\\App\\Lib\\Events\\JobStarted', (e) => handleJobEvent(e, 'success'))
|
||||||
|
.listen('\\App\\Lib\\Events\\JobFinished', (e) => handleJobEvent(e, 'success'))
|
||||||
|
.listen('\\App\\Lib\\Events\\JobFailed', (e) => handleJobEvent(e, 'error'));
|
||||||
|
|
||||||
|
export default echo;
|
||||||
|
|
|
@ -1,21 +1,24 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="sidebar flex flex-col group is-bright">
|
<div class="sidebar flex flex-col group is-bright">
|
||||||
<page-header @close="$emit('close')" title="Ausbildungen">
|
<page-header title="Ausbildungen" @close="$emit('close')">
|
||||||
<template #toolbar>
|
<template #toolbar>
|
||||||
<page-toolbar-button @click.prevent="create" color="primary" icon="plus" v-if="single === null">Neue Ausbildung</page-toolbar-button>
|
<page-toolbar-button v-if="single === null" color="primary" icon="plus" @click.prevent="create">Neue
|
||||||
<page-toolbar-button @click.prevent="cancel" color="primary" icon="undo" v-if="single !== null">Zurück</page-toolbar-button>
|
Ausbildung</page-toolbar-button>
|
||||||
|
<page-toolbar-button v-if="single !== null" color="primary" icon="undo"
|
||||||
|
@click.prevent="cancel">Zurück</page-toolbar-button>
|
||||||
</template>
|
</template>
|
||||||
</page-header>
|
</page-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="completed_at" type="date" v-model="single.completed_at" label="Datum" required></f-text>
|
<f-text id="completed_at" v-model="single.completed_at" type="date" label="Datum" required></f-text>
|
||||||
<f-select id="course_id" name="course_id" :options="courses" v-model="single.course_id" label="Baustein" required></f-select>
|
<f-select id="course_id" v-model="single.course_id" name="course_id" :options="meta.courses" label="Baustein"
|
||||||
|
required></f-select>
|
||||||
<f-text id="event_name" v-model="single.event_name" label="Veranstaltung" required></f-text>
|
<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>
|
<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>
|
||||||
|
|
||||||
<div class="grow" v-else>
|
<div v-else class="grow">
|
||||||
<table class="custom-table custom-table-light custom-table-sm text-sm grow">
|
<table class="custom-table custom-table-light custom-table-sm text-sm grow">
|
||||||
<thead>
|
<thead>
|
||||||
<th>Baustein</th>
|
<th>Baustein</th>
|
||||||
|
@ -25,22 +28,16 @@
|
||||||
<th></th>
|
<th></th>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tr v-for="(course, index) in value.courses" :key="index">
|
<tr v-for="(course, index) in data" :key="index">
|
||||||
<td v-text="course.course_name"></td>
|
<td v-text="course.course_name"></td>
|
||||||
<td v-text="course.event_name"></td>
|
<td v-text="course.event_name"></td>
|
||||||
<td v-text="course.organizer"></td>
|
<td v-text="course.organizer"></td>
|
||||||
<td v-text="course.completed_at_human"></td>
|
<td v-text="course.completed_at_human"></td>
|
||||||
<td class="flex">
|
<td class="flex">
|
||||||
<a
|
<a href="#" class="inline-flex btn btn-warning btn-sm" @click.prevent="edit(course)"><ui-sprite
|
||||||
href="#"
|
src="pencil"></ui-sprite></a>
|
||||||
@click.prevent="
|
<a href="#" class="inline-flex btn btn-danger btn-sm" @click.prevent="remove(course)"><ui-sprite
|
||||||
single = course;
|
src="trash"></ui-sprite></a>
|
||||||
mode = 'edit';
|
|
||||||
"
|
|
||||||
class="inline-flex btn btn-warning btn-sm"
|
|
||||||
><ui-sprite src="pencil"></ui-sprite
|
|
||||||
></a>
|
|
||||||
<i-link href="#" @click.prevent="remove(course)" class="inline-flex btn btn-danger btn-sm"><ui-sprite src="trash"></ui-sprite></i-link>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -48,55 +45,18 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
export default {
|
defineEmits(['close']);
|
||||||
data: function () {
|
import { useApiIndex } from '../../composables/useApiIndex.js';
|
||||||
return {
|
|
||||||
mode: null,
|
|
||||||
single: null,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
props: {
|
const props = defineProps({
|
||||||
courses: {},
|
url: {
|
||||||
value: {},
|
type: String,
|
||||||
},
|
required: true,
|
||||||
|
|
||||||
methods: {
|
|
||||||
create() {
|
|
||||||
this.mode = 'create';
|
|
||||||
this.single = {};
|
|
||||||
},
|
|
||||||
cancel() {
|
|
||||||
this.mode = this.single = null;
|
|
||||||
},
|
|
||||||
remove(payment) {
|
|
||||||
this.$inertia.delete(`/member/${this.value.id}/course/${payment.id}`);
|
|
||||||
},
|
|
||||||
|
|
||||||
openLink(link) {
|
|
||||||
if (link.disabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.open(link.href);
|
|
||||||
},
|
|
||||||
|
|
||||||
submit() {
|
|
||||||
var _self = this;
|
|
||||||
|
|
||||||
this.mode === 'create'
|
|
||||||
? this.$inertia.post(`/member/${this.value.id}/course`, this.single, {
|
|
||||||
onFinish() {
|
|
||||||
_self.single = null;
|
|
||||||
},
|
|
||||||
})
|
|
||||||
: this.$inertia.patch(`/member/${this.value.id}/course/${this.single.id}`, this.single, {
|
|
||||||
onFinish() {
|
|
||||||
_self.single = null;
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
|
||||||
},
|
const { data, meta, reload, cancel, single, create, edit, submit, remove } = useApiIndex(props.url, 'course');
|
||||||
};
|
|
||||||
|
await reload();
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="sidebar flex flex-col group is-bright">
|
|
||||||
<page-header title="Mitgliedschaften" @close="$emit('close')">
|
<page-header title="Mitgliedschaften" @close="$emit('close')">
|
||||||
<template #toolbar>
|
<template #toolbar>
|
||||||
<page-toolbar-button v-if="single === null" color="primary" icon="plus" @click.prevent="create">Neue Mitgliedschaft</page-toolbar-button>
|
<page-toolbar-button v-if="single === null" color="primary" icon="plus" @click.prevent="create">Neue Mitgliedschaft</page-toolbar-button>
|
||||||
|
@ -8,14 +7,14 @@
|
||||||
</page-header>
|
</page-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-select id="group_id" v-model="single.group_id" name="group_id" :options="data.meta.groups" label="Gruppierung" required></f-select>
|
<f-select id="group_id" v-model="single.group_id" name="group_id" :options="meta.groups" label="Gruppierung" required></f-select>
|
||||||
<f-select id="activity_id" v-model="single.activity_id" name="activity_id" :options="data.meta.activities" label="Tätigkeit" required></f-select>
|
<f-select id="activity_id" v-model="single.activity_id" name="activity_id" :options="meta.activities" label="Tätigkeit" required></f-select>
|
||||||
<f-select
|
<f-select
|
||||||
v-if="single.activity_id"
|
v-if="single.activity_id"
|
||||||
id="subactivity_id"
|
id="subactivity_id"
|
||||||
v-model="single.subactivity_id"
|
v-model="single.subactivity_id"
|
||||||
name="subactivity_id"
|
name="subactivity_id"
|
||||||
:options="data.meta.subactivities[single.activity_id]"
|
:options="meta.subactivities[single.activity_id]"
|
||||||
label="Untertätigkeit"
|
label="Untertätigkeit"
|
||||||
></f-select>
|
></f-select>
|
||||||
<f-switch id="has_promise" :model-value="single.promised_at !== null" label="Hat Versprechen" @update:modelValue="single.promised_at = $event ? '2000-02-02' : null"></f-switch>
|
<f-switch id="has_promise" :model-value="single.promised_at !== null" label="Hat Versprechen" @update:modelValue="single.promised_at = $event ? '2000-02-02' : null"></f-switch>
|
||||||
|
@ -33,7 +32,7 @@
|
||||||
<th></th>
|
<th></th>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tr v-for="(membership, index) in data.data" :key="index">
|
<tr v-for="(membership, index) in data" :key="index">
|
||||||
<td v-text="membership.activity_name"></td>
|
<td v-text="membership.activity_name"></td>
|
||||||
<td v-text="membership.subactivity_name"></td>
|
<td v-text="membership.subactivity_name"></td>
|
||||||
<td v-text="membership.human_date"></td>
|
<td v-text="membership.human_date"></td>
|
||||||
|
@ -45,50 +44,19 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {ref, inject, onBeforeMount} from 'vue';
|
defineEmits(['close']);
|
||||||
const axios = inject('axios');
|
import {useApiIndex} from '../../composables/useApiIndex.js';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
value: {
|
url: {
|
||||||
type: Object,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const {data, meta, reload, single, create, edit, submit, remove} = useApiIndex(props.url, 'membership');
|
||||||
|
|
||||||
const single = ref(null);
|
|
||||||
const data = ref({
|
|
||||||
meta: {},
|
|
||||||
data: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
async function reload() {
|
|
||||||
data.value = (await axios.post(props.value.links.membership_index)).data;
|
|
||||||
}
|
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
|
||||||
await reload();
|
await reload();
|
||||||
});
|
|
||||||
|
|
||||||
function create() {
|
|
||||||
single.value = JSON.parse(JSON.stringify(data.value.meta.default));
|
|
||||||
}
|
|
||||||
|
|
||||||
function edit(membership) {
|
|
||||||
single.value = JSON.parse(JSON.stringify(membership));
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submit() {
|
|
||||||
single.value.id ? await axios.patch(single.value.links.update, single.value) : await axios.post(data.value.meta.links.store, single.value);
|
|
||||||
await reload();
|
|
||||||
single.value = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function remove(membership) {
|
|
||||||
await axios.delete(membership.links.destroy);
|
|
||||||
await reload();
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="sidebar flex flex-col group is-bright">
|
|
||||||
<page-header title="Zahlungen" @close="$emit('close')">
|
<page-header title="Zahlungen" @close="$emit('close')">
|
||||||
<template #toolbar>
|
<template #toolbar>
|
||||||
<page-toolbar-button v-if="single === null" color="primary" icon="plus" @click.prevent="create">Neue Zahlung</page-toolbar-button>
|
<page-toolbar-button v-if="single === null" color="primary" icon="plus" @click.prevent="create">Neue
|
||||||
<page-toolbar-button v-if="single !== null" color="primary" icon="undo" @click.prevent="cancel">Zurück</page-toolbar-button>
|
Zahlung</page-toolbar-button>
|
||||||
|
<page-toolbar-button v-if="single !== null" color="primary" icon="undo"
|
||||||
|
@click.prevent="cancel">Zurück</page-toolbar-button>
|
||||||
</template>
|
</template>
|
||||||
</page-header>
|
</page-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="nr" v-model="single.nr" label="Jahr" required></f-text>
|
||||||
<f-select id="subscription_id" v-model="single.subscription_id" name="subscription_id" :options="subscriptions" label="Beitrag" required></f-select>
|
<f-select id="subscription_id" v-model="single.subscription_id" name="subscription_id" :options="meta.subscriptions"
|
||||||
<f-select id="status_id" v-model="single.status_id" name="status_id" :options="statuses" label="Status" required></f-select>
|
label="Beitrag" required></f-select>
|
||||||
|
<f-select id="status_id" v-model="single.status_id" name="status_id" :options="meta.statuses" label="Status"
|
||||||
|
required></f-select>
|
||||||
<button type="submit" class="btn btn-primary">Absenden</button>
|
<button type="submit" class="btn btn-primary">Absenden</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@ -23,95 +26,41 @@
|
||||||
<th></th>
|
<th></th>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tr v-for="(payment, index) in value.payments" :key="index">
|
<tr v-for="(payment, index) in data" :key="index">
|
||||||
<td v-text="payment.nr"></td>
|
<td v-text="payment.nr"></td>
|
||||||
<td v-text="payment.status_name"></td>
|
<td v-text="payment.status_name"></td>
|
||||||
<td v-text="payment.subscription.name"></td>
|
<td v-text="payment.subscription.name"></td>
|
||||||
<td class="flex">
|
<td class="flex">
|
||||||
<a
|
<a href="#" class="inline-flex btn btn-warning btn-sm" @click.prevent="edit(payment)"><ui-sprite
|
||||||
href="#"
|
src="pencil"></ui-sprite></a>
|
||||||
class="inline-flex btn btn-warning btn-sm"
|
<button v-show="!payment.is_accepted" href="#" class="inline-flex btn btn-success btn-sm"
|
||||||
@click.prevent="
|
@click.prevent="accept(payment)"><ui-sprite src="check"></ui-sprite></button>
|
||||||
single = payment;
|
<button class="inline-flex btn btn-danger btn-sm" @click.prevent="remove(payment)"><ui-sprite
|
||||||
mode = 'edit';
|
src="trash"></ui-sprite></button>
|
||||||
"
|
|
||||||
><ui-sprite src="pencil"></ui-sprite
|
|
||||||
></a>
|
|
||||||
<i-link v-show="!payment.is_accepted" href="#" class="inline-flex btn btn-success btn-sm" @click.prevent="accept(payment)"><ui-sprite src="check"></ui-sprite></i-link>
|
|
||||||
<i-link href="#" class="inline-flex btn btn-danger btn-sm" @click.prevent="remove(payment)"><ui-sprite src="trash"></ui-sprite></i-link>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col pb-6 px-6">
|
|
||||||
<a
|
|
||||||
v-for="(link, index) in value.payment_links"
|
|
||||||
:key="index"
|
|
||||||
href="#"
|
|
||||||
:class="{disabled: link.disabled}"
|
|
||||||
target="_BLANK"
|
|
||||||
class="mt-1 text-center btn btn-primary"
|
|
||||||
@click.prevent="openLink(link)"
|
|
||||||
v-text="link.label"
|
|
||||||
></a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
export default {
|
defineEmits(['close']);
|
||||||
|
import { useApiIndex } from '../../composables/useApiIndex.js';
|
||||||
|
|
||||||
props: {
|
const props = defineProps({
|
||||||
value: {},
|
url: {
|
||||||
subscriptions: {},
|
type: String,
|
||||||
statuses: {},
|
required: true,
|
||||||
},
|
|
||||||
data: function () {
|
|
||||||
return {
|
|
||||||
mode: null,
|
|
||||||
single: null,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
create() {
|
|
||||||
this.mode = 'create';
|
|
||||||
this.single = {};
|
|
||||||
},
|
|
||||||
cancel() {
|
|
||||||
this.mode = this.single = null;
|
|
||||||
},
|
|
||||||
remove(payment) {
|
|
||||||
this.$inertia.delete(`/member/${this.value.id}/payment/${payment.id}`);
|
|
||||||
},
|
|
||||||
|
|
||||||
accept(payment) {
|
|
||||||
this.$inertia.patch(`/member/${this.value.id}/payment/${payment.id}`, {...payment, status_id: 3});
|
|
||||||
},
|
|
||||||
|
|
||||||
openLink(link) {
|
|
||||||
if (link.disabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.open(link.href);
|
|
||||||
},
|
|
||||||
|
|
||||||
submit() {
|
|
||||||
var _self = this;
|
|
||||||
|
|
||||||
this.mode === 'create'
|
|
||||||
? this.$inertia.post(`/member/${this.value.id}/payment`, this.single, {
|
|
||||||
onFinish() {
|
|
||||||
_self.single = null;
|
|
||||||
},
|
|
||||||
})
|
|
||||||
: this.$inertia.patch(`/member/${this.value.id}/payment/${this.single.id}`, this.single, {
|
|
||||||
onFinish() {
|
|
||||||
_self.single = null;
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
|
||||||
},
|
const { axios, data, meta, reload, cancel, single, create, edit, submit, remove } = useApiIndex(props.url, 'payment');
|
||||||
};
|
|
||||||
|
async function accept(payment) {
|
||||||
|
await axios.patch(payment.links.update, { ...payment, status_id: 3 });
|
||||||
|
|
||||||
|
await reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
await reload();
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -106,12 +106,14 @@
|
||||||
<ui-pagination class="mt-4" :value="meta" :only="['data']"></ui-pagination>
|
<ui-pagination class="mt-4" :value="meta" :only="['data']"></ui-pagination>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<member-payments v-if="single !== null && single.type === 'payment'" :subscriptions="meta.subscriptions"
|
<ui-sidebar v-if="single !== null" @close="closeSidebar">
|
||||||
:statuses="meta.statuses" :value="single.model" @close="closeSidebar"></member-payments>
|
<member-payments v-if="single.type === 'payment'" :url="single.model.links.payment_index"
|
||||||
<member-memberships v-if="single !== null && single.type === 'membership'" :activities="meta.formActivities"
|
@close="closeSidebar"></member-payments>
|
||||||
:subactivities="meta.formSubactivities" :value="single.model" @close="closeSidebar"></member-memberships>
|
<member-memberships v-if="single.type === 'membership'" :url="single.model.links.membership_index"
|
||||||
<member-courses v-if="single !== null && single.type === 'courses'" :courses="meta.courses" :value="single.model"
|
@close="closeSidebar"></member-memberships>
|
||||||
|
<member-courses v-if="single.type === 'courses'" :url="single.model.links.course_index"
|
||||||
@close="closeSidebar"></member-courses>
|
@close="closeSidebar"></member-courses>
|
||||||
|
</ui-sidebar>
|
||||||
</page-layout>
|
</page-layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="flex space-x-1">
|
<div class="flex space-x-1">
|
||||||
<i-link v-tooltip="`Details`" :href="member.links.show" class="inline-flex btn btn-primary btn-sm"><ui-sprite src="eye"></ui-sprite></i-link>
|
<i-link v-tooltip="`Details`" :href="member.links.show" class="inline-flex btn btn-primary btn-sm"><ui-sprite src="eye"></ui-sprite></i-link>
|
||||||
<i-link v-tooltip="`Bearbeiten`" :href="`/member/${member.id}/edit`" class="inline-flex btn btn-warning btn-sm"><ui-sprite src="pencil"></ui-sprite></i-link>
|
<i-link v-tooltip="`Bearbeiten`" :href="member.links.edit" class="inline-flex btn btn-warning btn-sm"><ui-sprite src="pencil"></ui-sprite></i-link>
|
||||||
<a v-show="hasModule('bill')" v-tooltip="`Zahlungen`" href="#" class="inline-flex btn btn-info btn-sm" @click.prevent="$emit('sidebar', 'payment')"><ui-sprite src="money"></ui-sprite></a>
|
<a v-show="hasModule('bill')" v-tooltip="`Zahlungen`" href="#" class="inline-flex btn btn-info btn-sm" @click.prevent="$emit('sidebar', 'payment')"><ui-sprite src="money"></ui-sprite></a>
|
||||||
<a v-show="hasModule('courses')" v-tooltip="`Ausbildungen`" href="#" class="inline-flex btn btn-info btn-sm" @click.prevent="$emit('sidebar', 'courses')"
|
<a v-show="hasModule('courses')" v-tooltip="`Ausbildungen`" href="#" class="inline-flex btn btn-info btn-sm" @click.prevent="$emit('sidebar', 'courses')"
|
||||||
><ui-sprite src="course"></ui-sprite
|
><ui-sprite src="course"></ui-sprite
|
||||||
|
@ -12,10 +12,11 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
export default {
|
defineProps({
|
||||||
props: {
|
member: {
|
||||||
member: {},
|
type: Object,
|
||||||
},
|
required: true,
|
||||||
};
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -12,7 +12,10 @@ use App\Activity\Api\SubactivityUpdateAction;
|
||||||
use App\Contribution\Actions\FormAction as ContributionFormAction;
|
use App\Contribution\Actions\FormAction as ContributionFormAction;
|
||||||
use App\Contribution\Actions\GenerateAction as ContributionGenerateAction;
|
use App\Contribution\Actions\GenerateAction as ContributionGenerateAction;
|
||||||
use App\Contribution\Actions\ValidateAction as ContributionValidateAction;
|
use App\Contribution\Actions\ValidateAction as ContributionValidateAction;
|
||||||
use App\Course\Controllers\CourseController;
|
use App\Course\Actions\CourseDestroyAction;
|
||||||
|
use App\Course\Actions\CourseIndexAction;
|
||||||
|
use App\Course\Actions\CourseStoreAction;
|
||||||
|
use App\Course\Actions\CourseUpdateAction;
|
||||||
use App\Dashboard\Actions\IndexAction as DashboardIndexAction;
|
use App\Dashboard\Actions\IndexAction as DashboardIndexAction;
|
||||||
use App\Efz\ShowEfzDocumentAction;
|
use App\Efz\ShowEfzDocumentAction;
|
||||||
use App\Group\Actions\ListAction;
|
use App\Group\Actions\ListAction;
|
||||||
|
@ -35,15 +38,18 @@ use App\Member\Actions\MemberResyncAction;
|
||||||
use App\Member\Actions\MemberShowAction;
|
use App\Member\Actions\MemberShowAction;
|
||||||
use App\Member\Actions\SearchAction;
|
use App\Member\Actions\SearchAction;
|
||||||
use App\Member\MemberController;
|
use App\Member\MemberController;
|
||||||
use App\Membership\Actions\ApiIndexAction;
|
use App\Membership\Actions\IndexAction as MembershipIndexAction;
|
||||||
use App\Membership\Actions\ApiListAction;
|
use App\Membership\Actions\ListForGroupAction;
|
||||||
use App\Membership\Actions\MembershipDestroyAction;
|
use App\Membership\Actions\MembershipDestroyAction;
|
||||||
use App\Membership\Actions\MembershipStoreAction;
|
use App\Membership\Actions\MembershipStoreAction;
|
||||||
use App\Membership\Actions\MembershipUpdateAction;
|
use App\Membership\Actions\MembershipUpdateAction;
|
||||||
use App\Membership\Actions\SyncAction;
|
use App\Membership\Actions\StoreForGroupAction;
|
||||||
use App\Payment\Actions\AllpaymentPageAction;
|
use App\Payment\Actions\AllpaymentPageAction;
|
||||||
use App\Payment\Actions\AllpaymentStoreAction;
|
use App\Payment\Actions\AllpaymentStoreAction;
|
||||||
use App\Payment\PaymentController;
|
use App\Payment\Actions\IndexAction as PaymentIndexAction;
|
||||||
|
use App\Payment\Actions\PaymentDestroyAction;
|
||||||
|
use App\Payment\Actions\PaymentStoreAction;
|
||||||
|
use App\Payment\Actions\PaymentUpdateAction;
|
||||||
use App\Payment\SendpaymentController;
|
use App\Payment\SendpaymentController;
|
||||||
use App\Payment\SubscriptionController;
|
use App\Payment\SubscriptionController;
|
||||||
use App\Pdf\MemberPdfController;
|
use App\Pdf\MemberPdfController;
|
||||||
|
@ -57,16 +63,11 @@ Route::group(['middleware' => 'auth:web'], function (): void {
|
||||||
Route::post('/nami/login-check', NamiLoginCheckAction::class)->name('nami.login-check');
|
Route::post('/nami/login-check', NamiLoginCheckAction::class)->name('nami.login-check');
|
||||||
Route::post('/nami/get-search-layer', NamiGetSearchLayerAction::class)->name('nami.get-search-layer');
|
Route::post('/nami/get-search-layer', NamiGetSearchLayerAction::class)->name('nami.get-search-layer');
|
||||||
Route::post('/nami/search', NamiSearchAction::class)->name('nami.search');
|
Route::post('/nami/search', NamiSearchAction::class)->name('nami.search');
|
||||||
Route::post('/api/member/search', SearchAction::class)->name('member.search');
|
|
||||||
Route::post('/api/membership/member-list', ApiListAction::class)->name('membership.member-list');
|
|
||||||
Route::post('/api/membership/sync', SyncAction::class)->name('membership.sync');
|
|
||||||
Route::post('/api/member/{member}/membership', ApiIndexAction::class)->name('member.membership.index');
|
|
||||||
Route::get('/initialize', InitializeFormAction::class)->name('initialize.form');
|
Route::get('/initialize', InitializeFormAction::class)->name('initialize.form');
|
||||||
Route::post('/initialize', InitializeAction::class)->name('initialize.store');
|
Route::post('/initialize', InitializeAction::class)->name('initialize.store');
|
||||||
Route::resource('member', MemberController::class)->except('show', 'destroy');
|
Route::resource('member', MemberController::class)->except('show', 'destroy');
|
||||||
Route::delete('/member/{member}', MemberDeleteAction::class);
|
Route::delete('/member/{member}', MemberDeleteAction::class);
|
||||||
Route::get('/member/{member}', MemberShowAction::class)->name('member.show');
|
Route::get('/member/{member}', MemberShowAction::class)->name('member.show');
|
||||||
Route::apiResource('member.payment', PaymentController::class);
|
|
||||||
Route::get('allpayment', AllpaymentPageAction::class)->name('allpayment.page');
|
Route::get('allpayment', AllpaymentPageAction::class)->name('allpayment.page');
|
||||||
Route::post('allpayment', AllpaymentStoreAction::class)->name('allpayment.store');
|
Route::post('allpayment', AllpaymentStoreAction::class)->name('allpayment.store');
|
||||||
Route::resource('subscription', SubscriptionController::class);
|
Route::resource('subscription', SubscriptionController::class);
|
||||||
|
@ -74,10 +75,6 @@ Route::group(['middleware' => 'auth:web'], function (): void {
|
||||||
->name('member.singlepdf');
|
->name('member.singlepdf');
|
||||||
Route::get('/sendpayment', [SendpaymentController::class, 'create'])->name('sendpayment.create');
|
Route::get('/sendpayment', [SendpaymentController::class, 'create'])->name('sendpayment.create');
|
||||||
Route::get('/sendpayment/pdf', [SendpaymentController::class, 'send'])->name('sendpayment.pdf');
|
Route::get('/sendpayment/pdf', [SendpaymentController::class, 'send'])->name('sendpayment.pdf');
|
||||||
Route::post('/member/{member}/membership', MembershipStoreAction::class)->name('member.membership.store');
|
|
||||||
Route::patch('/membership/{membership}', MembershipUpdateAction::class)->name('membership.update');
|
|
||||||
Route::delete('/membership/{membership}', MembershipDestroyAction::class)->name('membership.destroy');
|
|
||||||
Route::resource('member.course', CourseController::class);
|
|
||||||
Route::get('/member/{member}/efz', ShowEfzDocumentAction::class)->name('efz');
|
Route::get('/member/{member}/efz', ShowEfzDocumentAction::class)->name('efz');
|
||||||
Route::get('/member/{member}/resync', MemberResyncAction::class)->name('member.resync');
|
Route::get('/member/{member}/resync', MemberResyncAction::class)->name('member.resync');
|
||||||
Route::get('member-export', ExportAction::class)->name('member-export');
|
Route::get('member-export', ExportAction::class)->name('member-export');
|
||||||
|
@ -90,6 +87,7 @@ Route::group(['middleware' => 'auth:web'], function (): void {
|
||||||
Route::post('/subactivity', SubactivityStoreAction::class)->name('api.subactivity.store');
|
Route::post('/subactivity', SubactivityStoreAction::class)->name('api.subactivity.store');
|
||||||
Route::patch('/subactivity/{subactivity}', SubactivityUpdateAction::class)->name('api.subactivity.update');
|
Route::patch('/subactivity/{subactivity}', SubactivityUpdateAction::class)->name('api.subactivity.update');
|
||||||
Route::get('/subactivity/{subactivity}', SubactivityShowAction::class)->name('api.subactivity.show');
|
Route::get('/subactivity/{subactivity}', SubactivityShowAction::class)->name('api.subactivity.show');
|
||||||
|
Route::post('/api/member/search', SearchAction::class)->name('member.search');
|
||||||
|
|
||||||
// ------------------------------- Contributions -------------------------------
|
// ------------------------------- Contributions -------------------------------
|
||||||
Route::get('/contribution', ContributionFormAction::class)->name('contribution.form');
|
Route::get('/contribution', ContributionFormAction::class)->name('contribution.form');
|
||||||
|
@ -108,4 +106,24 @@ Route::group(['middleware' => 'auth:web'], function (): void {
|
||||||
|
|
||||||
// ----------------------------------- group -----------------------------------
|
// ----------------------------------- group -----------------------------------
|
||||||
Route::get('/group', ListAction::class)->name('group.index');
|
Route::get('/group', ListAction::class)->name('group.index');
|
||||||
|
|
||||||
|
// ---------------------------------- payment ----------------------------------
|
||||||
|
Route::get('/member/{member}/payment', PaymentIndexAction::class)->name('member.payment.index');
|
||||||
|
Route::post('/member/{member}/payment', PaymentStoreAction::class)->name('member.payment.store');
|
||||||
|
Route::patch('/payment/{payment}', PaymentUpdateAction::class)->name('payment.update');
|
||||||
|
Route::delete('/payment/{payment}', PaymentDestroyAction::class)->name('payment.destroy');
|
||||||
|
|
||||||
|
// --------------------------------- membership --------------------------------
|
||||||
|
Route::get('/member/{member}/membership', MembershipIndexAction::class)->name('member.membership.index');
|
||||||
|
Route::post('/member/{member}/membership', MembershipStoreAction::class)->name('member.membership.store');
|
||||||
|
Route::patch('/membership/{membership}', MembershipUpdateAction::class)->name('membership.update');
|
||||||
|
Route::delete('/membership/{membership}', MembershipDestroyAction::class)->name('membership.destroy');
|
||||||
|
Route::post('/api/membership/member-list', ListForGroupAction::class)->name('membership.member-list');
|
||||||
|
Route::post('/api/membership/sync', StoreForGroupAction::class)->name('membership.sync');
|
||||||
|
|
||||||
|
// ----------------------------------- course ----------------------------------
|
||||||
|
Route::get('/member/{member}/course', CourseIndexAction::class)->name('member.course.index');
|
||||||
|
Route::post('/member/{member}/course', CourseStoreAction::class)->name('member.course.store');
|
||||||
|
Route::patch('/course/{course}', CourseUpdateAction::class)->name('course.update');
|
||||||
|
Route::delete('/course/{course}', CourseDestroyAction::class)->name('course.destroy');
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,7 @@ use App\Member\Member;
|
||||||
use App\Member\Membership;
|
use App\Member\Membership;
|
||||||
use App\Membership\Actions\MembershipDestroyAction;
|
use App\Membership\Actions\MembershipDestroyAction;
|
||||||
use App\Membership\Actions\MembershipStoreAction;
|
use App\Membership\Actions\MembershipStoreAction;
|
||||||
use App\Membership\Actions\SyncAction;
|
use App\Membership\Actions\StoreForGroupAction;
|
||||||
use App\Subactivity;
|
use App\Subactivity;
|
||||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
use Illuminate\Support\Facades\Queue;
|
use Illuminate\Support\Facades\Queue;
|
||||||
|
@ -37,7 +37,7 @@ class SyncActionTest extends TestCase
|
||||||
'subactivity_id' => $subactivity->id,
|
'subactivity_id' => $subactivity->id,
|
||||||
'group_id' => $group->id,
|
'group_id' => $group->id,
|
||||||
]);
|
]);
|
||||||
SyncAction::assertPushed(fn ($action, $params) => $params[0]->is($group) && $params[1]->is($activity) && $params[2]->is($subactivity) && $params[3][0] === $member->id);
|
StoreForGroupAction::assertPushed(fn ($action, $params) => $params[0]->is($group) && $params[1]->is($activity) && $params[2]->is($subactivity) && $params[3][0] === $member->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItCreatesAMembership(): void
|
public function testItCreatesAMembership(): void
|
||||||
|
@ -49,7 +49,7 @@ class SyncActionTest extends TestCase
|
||||||
$subactivity = Subactivity::factory()->create();
|
$subactivity = Subactivity::factory()->create();
|
||||||
$group = Group::factory()->create();
|
$group = Group::factory()->create();
|
||||||
|
|
||||||
SyncAction::run($group, $activity, $subactivity, [$member->id]);
|
StoreForGroupAction::run($group, $activity, $subactivity, [$member->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItDeletesAMembership(): void
|
public function testItDeletesAMembership(): void
|
||||||
|
@ -60,7 +60,7 @@ class SyncActionTest extends TestCase
|
||||||
|
|
||||||
$member = Member::factory()->defaults()->has(Membership::factory()->inLocal('Leiter*in', 'Rover'))->create();
|
$member = Member::factory()->defaults()->has(Membership::factory()->inLocal('Leiter*in', 'Rover'))->create();
|
||||||
|
|
||||||
SyncAction::run($member->memberships->first()->group, $member->memberships->first()->activity, $member->memberships->first()->subactivity, []);
|
StoreForGroupAction::run($member->memberships->first()->group, $member->memberships->first()->activity, $member->memberships->first()->subactivity, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItRollsbackWhenDeletionFails(): void
|
public function testItRollsbackWhenDeletionFails(): void
|
||||||
|
@ -78,7 +78,7 @@ class SyncActionTest extends TestCase
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SyncAction::run($member->memberships->first()->group, $member->memberships->first()->activity, $member->memberships->first()->subactivity, []);
|
StoreForGroupAction::run($member->memberships->first()->group, $member->memberships->first()->activity, $member->memberships->first()->subactivity, []);
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
}
|
}
|
||||||
$this->assertDatabaseCount('memberships', 2);
|
$this->assertDatabaseCount('memberships', 2);
|
||||||
|
|
|
@ -19,7 +19,7 @@ class DeleteTest extends TestCase
|
||||||
app(CourseFake::class)->deletesSuccessfully(123, 999);
|
app(CourseFake::class)->deletesSuccessfully(123, 999);
|
||||||
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->inNami(999)->for(Course::factory()), 'courses')->createOne();
|
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->inNami(999)->for(Course::factory()), 'courses')->createOne();
|
||||||
|
|
||||||
$this->delete("/member/{$member->id}/course/{$member->courses->first()->id}");
|
$this->delete("//course/{$member->courses->first()->id}");
|
||||||
|
|
||||||
$this->assertDatabaseCount('course_members', 0);
|
$this->assertDatabaseCount('course_members', 0);
|
||||||
app(CourseFake::class)->assertDeleted(123, 999);
|
app(CourseFake::class)->assertDeleted(123, 999);
|
||||||
|
@ -31,7 +31,7 @@ class DeleteTest extends TestCase
|
||||||
app(CourseFake::class)->failsDeleting(123, 999);
|
app(CourseFake::class)->failsDeleting(123, 999);
|
||||||
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->inNami(999)->for(Course::factory()), 'courses')->createOne();
|
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->inNami(999)->for(Course::factory()), 'courses')->createOne();
|
||||||
|
|
||||||
$response = $this->delete("/member/{$member->id}/course/{$member->courses->first()->id}");
|
$response = $this->delete("/course/{$member->courses->first()->id}");
|
||||||
|
|
||||||
$this->assertDatabaseCount('course_members', 1);
|
$this->assertDatabaseCount('course_members', 1);
|
||||||
$response->assertSessionHasErrors(['id' => 'Unbekannter Fehler']);
|
$response->assertSessionHasErrors(['id' => 'Unbekannter Fehler']);
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Course;
|
||||||
|
|
||||||
|
use App\Course\Models\Course;
|
||||||
|
use App\Course\Models\CourseMember;
|
||||||
|
use App\Member\Member;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class IndexTest extends TestCase
|
||||||
|
{
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
public function testItShowsCourses(): void
|
||||||
|
{
|
||||||
|
$this->login()->withNamiSettings();
|
||||||
|
$member = Member::factory()->defaults()->has(CourseMember::factory()->for(Course::factory()->state(['name' => '2a']))->state(['event_name' => 'WE', 'organizer' => 'DPSG', 'completed_at' => now()->subDays(2)]), 'courses')->create();
|
||||||
|
|
||||||
|
$this->get("/member/{$member->id}/course")
|
||||||
|
->assertJsonPath('data.0.course_name', '2a')
|
||||||
|
->assertJsonPath('data.0.event_name', 'WE')
|
||||||
|
->assertJsonPath('data.0.organizer', 'DPSG')
|
||||||
|
->assertJsonPath('data.0.links.update', route('course.update', ['course' => $member->courses->first()->id]))
|
||||||
|
->assertJsonPath('data.0.links.destroy', route('course.destroy', ['course' => $member->courses->first()->id]))
|
||||||
|
->assertJsonPath('data.0.completed_at_human', now()->subDays(2)->format('d.m.Y'))
|
||||||
|
->assertJsonPath('meta.links.store', route('member.course.store', ['member' => $member]))
|
||||||
|
->assertJsonPath('meta.default.completed_at', null)
|
||||||
|
->assertJsonPath('meta.default.course_id', null)
|
||||||
|
->assertJsonPath('meta.default.event_name', '')
|
||||||
|
->assertJsonPath('meta.default.organizer', '')
|
||||||
|
->assertJsonPath('meta.courses.0.name', '2a')
|
||||||
|
->assertJsonPath('meta.courses.0.id', Course::first()->id);
|
||||||
|
}
|
||||||
|
}
|
|
@ -57,7 +57,7 @@ class UpdateTest extends TestCase
|
||||||
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->for(Course::factory()), 'courses')->createOne();
|
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->for(Course::factory()), 'courses')->createOne();
|
||||||
$newCourse = Course::factory()->inNami(789)->create();
|
$newCourse = Course::factory()->inNami(789)->create();
|
||||||
|
|
||||||
$response = $this->patch("/member/{$member->id}/course/{$member->courses->first()->id}", array_merge([
|
$response = $this->patch("/course/{$member->courses->first()->id}", array_merge([
|
||||||
'course_id' => $newCourse->id,
|
'course_id' => $newCourse->id,
|
||||||
'completed_at' => '1999-02-03',
|
'completed_at' => '1999-02-03',
|
||||||
'event_name' => '::newevent::',
|
'event_name' => '::newevent::',
|
||||||
|
@ -75,7 +75,7 @@ class UpdateTest extends TestCase
|
||||||
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->inNami(999)->for(Course::factory()), 'courses')->createOne();
|
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->inNami(999)->for(Course::factory()), 'courses')->createOne();
|
||||||
$newCourse = Course::factory()->inNami(789)->create();
|
$newCourse = Course::factory()->inNami(789)->create();
|
||||||
|
|
||||||
$this->patch("/member/{$member->id}/course/{$member->courses->first()->id}", array_merge([
|
$this->patch("/course/{$member->courses->first()->id}", array_merge([
|
||||||
'course_id' => $newCourse->id,
|
'course_id' => $newCourse->id,
|
||||||
'completed_at' => '1999-02-03',
|
'completed_at' => '1999-02-03',
|
||||||
'event_name' => '::newevent::',
|
'event_name' => '::newevent::',
|
||||||
|
@ -104,7 +104,7 @@ class UpdateTest extends TestCase
|
||||||
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->inNami(999)->for(Course::factory()), 'courses')->createOne();
|
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->inNami(999)->for(Course::factory()), 'courses')->createOne();
|
||||||
$newCourse = Course::factory()->inNami(789)->create();
|
$newCourse = Course::factory()->inNami(789)->create();
|
||||||
|
|
||||||
$response = $this->patch("/member/{$member->id}/course/{$member->courses->first()->id}", array_merge([
|
$response = $this->patch("/course/{$member->courses->first()->id}", array_merge([
|
||||||
'course_id' => $newCourse->id,
|
'course_id' => $newCourse->id,
|
||||||
'completed_at' => '1999-02-03',
|
'completed_at' => '1999-02-03',
|
||||||
'event_name' => '::newevent::',
|
'event_name' => '::newevent::',
|
||||||
|
@ -121,7 +121,7 @@ class UpdateTest extends TestCase
|
||||||
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->inNami(999)->for(Course::factory()), 'courses')->createOne();
|
$member = Member::factory()->defaults()->inNami(123)->has(CourseMember::factory()->inNami(999)->for(Course::factory()), 'courses')->createOne();
|
||||||
$newCourse = Course::factory()->inNami(789)->create();
|
$newCourse = Course::factory()->inNami(789)->create();
|
||||||
|
|
||||||
$response = $this->patch("/member/{$member->id}/course/{$member->courses->first()->id}", [
|
$response = $this->patch("/course/{$member->courses->first()->id}", [
|
||||||
'course_id' => $newCourse->id,
|
'course_id' => $newCourse->id,
|
||||||
'completed_at' => '2021-01-02',
|
'completed_at' => '2021-01-02',
|
||||||
'event_name' => '::event::',
|
'event_name' => '::event::',
|
||||||
|
|
|
@ -85,7 +85,7 @@ class DeleteTest extends TestCase
|
||||||
MemberDeleteAction::dispatch($member->id, $uuid);
|
MemberDeleteAction::dispatch($member->id, $uuid);
|
||||||
|
|
||||||
Event::assertNotDispatched(JobStarted::class);
|
Event::assertNotDispatched(JobStarted::class);
|
||||||
Event::assertDispatched(JobFinished::class, fn ($event) => $event->message === 'Mitglied Max Muster gelöscht' && $event->reload === true && $event->jobId->serialize() === $uuid->serialize());
|
Event::assertDispatched(JobFinished::class, fn ($event) => $event->message === 'Mitglied Max Muster gelöscht' && $event->jobId->serialize() === $uuid->serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItFiresEventWhenDeletingFailed(): void
|
public function testItFiresEventWhenDeletingFailed(): void
|
||||||
|
@ -102,7 +102,7 @@ class DeleteTest extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
Event::assertNotDispatched(JobStarted::class);
|
Event::assertNotDispatched(JobStarted::class);
|
||||||
Event::assertDispatched(JobFailed::class, fn ($event) => $event->message === 'Löschen von Max Muster fehlgeschlagen.' && $event->reload === true && $event->jobId->serialize() === $uuid->serialize());
|
Event::assertDispatched(JobFailed::class, fn ($event) => $event->message === 'Löschen von Max Muster fehlgeschlagen.' && $event->jobId->serialize() === $uuid->serialize());
|
||||||
Event::assertNotDispatched(JobFinished::class);
|
Event::assertNotDispatched(JobFinished::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,8 @@ class IndexTest extends TestCase
|
||||||
{
|
{
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
$group = Group::factory()->create();
|
$group = Group::factory()->create();
|
||||||
$member = Member::factory()->defaults()->for($group)->create([
|
$member = Member::factory()->defaults()->for($group)
|
||||||
|
->create([
|
||||||
'firstname' => '::firstname::',
|
'firstname' => '::firstname::',
|
||||||
'address' => 'Kölner Str 3',
|
'address' => 'Kölner Str 3',
|
||||||
'zip' => 33333,
|
'zip' => 33333,
|
||||||
|
@ -35,7 +36,13 @@ class IndexTest extends TestCase
|
||||||
$this->assertInertiaHas('Kölner Str 3, 33333 Hilden', $response, 'data.data.0.full_address');
|
$this->assertInertiaHas('Kölner Str 3, 33333 Hilden', $response, 'data.data.0.full_address');
|
||||||
$this->assertInertiaHas($group->id, $response, 'data.data.0.group_id');
|
$this->assertInertiaHas($group->id, $response, 'data.data.0.group_id');
|
||||||
$this->assertInertiaHas(null, $response, 'data.data.0.memberships');
|
$this->assertInertiaHas(null, $response, 'data.data.0.memberships');
|
||||||
$this->assertInertiaHas(route('member.membership.index', ['member' => $member]), $response, 'data.data.0.links.membership_index');
|
$this->assertInertiaHas(url("/member/{$member->id}/membership"), $response, 'data.data.0.links.membership_index');
|
||||||
|
$this->assertInertiaHas(url("/member/{$member->id}/payment"), $response, 'data.data.0.links.payment_index');
|
||||||
|
$this->assertInertiaHas(url("/member/{$member->id}/course"), $response, 'data.data.0.links.course_index');
|
||||||
|
$this->assertInertiaHas([
|
||||||
|
'id' => $member->subscription->id,
|
||||||
|
'name' => $member->subscription->name,
|
||||||
|
], $response, 'data.data.0.subscription');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFieldsCanBeNull(): void
|
public function testFieldsCanBeNull(): void
|
||||||
|
@ -132,34 +139,6 @@ class IndexTest extends TestCase
|
||||||
$this->assertInertiaHas('€ Mitglied', $response, "data.meta.formActivities.{$activity->id}");
|
$this->assertInertiaHas('€ Mitglied', $response, "data.meta.formActivities.{$activity->id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItReturnsPayments(): void
|
|
||||||
{
|
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
|
||||||
$member = Member::factory()
|
|
||||||
->has(Payment::factory()->notPaid()->nr('2019')->subscription('Free', [
|
|
||||||
new Child('a', 1000),
|
|
||||||
new Child('b', 50),
|
|
||||||
]))
|
|
||||||
->defaults()->create();
|
|
||||||
|
|
||||||
$response = $this->get('/member');
|
|
||||||
|
|
||||||
$this->assertInertiaHas([
|
|
||||||
'subscription' => [
|
|
||||||
'name' => 'Free',
|
|
||||||
'id' => $member->payments->first()->subscription->id,
|
|
||||||
'amount' => 1050,
|
|
||||||
],
|
|
||||||
'subscription_id' => $member->payments->first()->subscription->id,
|
|
||||||
'status_name' => 'Nicht bezahlt',
|
|
||||||
'nr' => '2019',
|
|
||||||
], $response, 'data.data.0.payments.0');
|
|
||||||
$this->assertInertiaHas([
|
|
||||||
'id' => $member->subscription->id,
|
|
||||||
'name' => $member->subscription->name,
|
|
||||||
], $response, 'data.data.0.subscription');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItCanFilterForBillKinds(): void
|
public function testItCanFilterForBillKinds(): void
|
||||||
{
|
{
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
|
|
|
@ -26,7 +26,7 @@ class IndexTest extends TestCase
|
||||||
->create();
|
->create();
|
||||||
$membership = $member->memberships->first();
|
$membership = $member->memberships->first();
|
||||||
|
|
||||||
$this->postJson("/api/member/{$member->id}/membership")
|
$this->get("/member/{$member->id}/membership")
|
||||||
->assertJsonPath('data.0.activity_id', $membership->activity_id)
|
->assertJsonPath('data.0.activity_id', $membership->activity_id)
|
||||||
->assertJsonPath('data.0.subactivity_id', $membership->subactivity_id)
|
->assertJsonPath('data.0.subactivity_id', $membership->subactivity_id)
|
||||||
->assertJsonPath('data.0.activity_name', '€ Mitglied')
|
->assertJsonPath('data.0.activity_name', '€ Mitglied')
|
||||||
|
@ -62,7 +62,7 @@ class IndexTest extends TestCase
|
||||||
->has(Membership::factory()->in('€ LeiterIn', 455, 'Pfadfinder', 15)->state(['from' => $from, 'to' => $to]))
|
->has(Membership::factory()->in('€ LeiterIn', 455, 'Pfadfinder', 15)->state(['from' => $from, 'to' => $to]))
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->postJson("/api/member/{$member->id}/membership")
|
$this->get("/member/{$member->id}/membership")
|
||||||
->assertJsonPath('data.0.is_active', $isActive);
|
->assertJsonPath('data.0.is_active', $isActive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,14 @@ namespace Tests\Feature\Membership;
|
||||||
|
|
||||||
use App\Activity;
|
use App\Activity;
|
||||||
use App\Group;
|
use App\Group;
|
||||||
|
use App\Lib\Events\JobFinished;
|
||||||
|
use App\Lib\Events\JobStarted;
|
||||||
|
use App\Lib\Events\ReloadTriggered;
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use App\Subactivity;
|
use App\Subactivity;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
use Tests\RequestFactories\MembershipRequestFactory;
|
use Tests\RequestFactories\MembershipRequestFactory;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Zoomyboy\LaravelNami\Fakes\MemberFake;
|
use Zoomyboy\LaravelNami\Fakes\MemberFake;
|
||||||
|
@ -45,7 +49,7 @@ class StoreTest extends TestCase
|
||||||
MembershipRequestFactory::new()->promise(now())->in($activity, $activity->subactivities->first())->group($member->group)->create()
|
MembershipRequestFactory::new()->promise(now())->in($activity, $activity->subactivities->first())->group($member->group)->create()
|
||||||
);
|
);
|
||||||
|
|
||||||
$response->assertRedirect('/member');
|
$response->assertOk();
|
||||||
$this->assertEquals(1506, $member->fresh()->version);
|
$this->assertEquals(1506, $member->fresh()->version);
|
||||||
$this->assertDatabaseHas('memberships', [
|
$this->assertDatabaseHas('memberships', [
|
||||||
'member_id' => $member->id,
|
'member_id' => $member->id,
|
||||||
|
@ -64,6 +68,23 @@ class StoreTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testItFiresJobEvents(): void
|
||||||
|
{
|
||||||
|
Event::fake([JobStarted::class, JobFinished::class, ReloadTriggered::class]);
|
||||||
|
$this->withoutExceptionHandling();
|
||||||
|
$member = Member::factory()->defaults()->for(Group::factory())->createOne();
|
||||||
|
$activity = Activity::factory()->hasAttached(Subactivity::factory())->createOne();
|
||||||
|
|
||||||
|
$this->from('/member')->post(
|
||||||
|
"/member/{$member->id}/membership",
|
||||||
|
MembershipRequestFactory::new()->in($activity, $activity->subactivities->first())->group($member->group)->create()
|
||||||
|
);
|
||||||
|
|
||||||
|
Event::assertDispatched(JobStarted::class, fn ($event) => $event->broadcastOn()[0]->name === 'jobs' && $event->message !== null);
|
||||||
|
Event::assertDispatched(JobFinished::class, fn ($event) => $event->broadcastOn()[0]->name === 'jobs' && $event->message !== null);
|
||||||
|
Event::assertDispatched(ReloadTriggered::class, fn ($event) => ['member', 'membership'] === $event->channels->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
public function testItDoesntFireNamiWhenMembershipIsLocal(): void
|
public function testItDoesntFireNamiWhenMembershipIsLocal(): void
|
||||||
{
|
{
|
||||||
$this->withoutExceptionHandling();
|
$this->withoutExceptionHandling();
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Payment;
|
||||||
|
|
||||||
|
use App\Member\Member;
|
||||||
|
use App\Payment\Payment;
|
||||||
|
use App\Payment\Subscription;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Tests\RequestFactories\Child;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class IndexTest extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
public function testItShowsPayments(): void
|
||||||
|
{
|
||||||
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
|
$member = Member::factory()
|
||||||
|
->has(Payment::factory()->notPaid()->nr('2019')->subscription('Free', [
|
||||||
|
new Child('a', 1000),
|
||||||
|
new Child('b', 50),
|
||||||
|
]))
|
||||||
|
->defaults()->create();
|
||||||
|
$payment = $member->payments->first();
|
||||||
|
|
||||||
|
$this->get("/member/{$member->id}/payment")
|
||||||
|
->assertJsonPath('data.0.subscription.name', 'Free')
|
||||||
|
->assertJsonPath('data.0.subscription.id', $payment->subscription->id)
|
||||||
|
->assertJsonPath('data.0.subscription.amount', 1050)
|
||||||
|
->assertJsonPath('data.0.subscription_id', $payment->subscription->id)
|
||||||
|
->assertJsonPath('data.0.status_name', 'Nicht bezahlt')
|
||||||
|
->assertJsonPath('data.0.nr', '2019')
|
||||||
|
->assertJsonPath('data.0.links.update', url("/payment/{$payment->id}"))
|
||||||
|
->assertJsonPath('data.0.links.destroy', url("/payment/{$payment->id}"))
|
||||||
|
->assertJsonPath('meta.statuses.0.name', 'Nicht bezahlt')
|
||||||
|
->assertJsonPath('meta.statuses.0.id', $payment->status->id)
|
||||||
|
->assertJsonPath('meta.subscriptions.0.id', Subscription::first()->id)
|
||||||
|
->assertJsonPath('meta.subscriptions.0.name', Subscription::first()->name)
|
||||||
|
->assertJsonPath('meta.links.store', url("/member/{$member->id}/payment"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Payment;
|
||||||
|
|
||||||
|
use App\Lib\Events\JobFinished;
|
||||||
|
use App\Lib\Events\JobStarted;
|
||||||
|
use App\Lib\Events\ReloadTriggered;
|
||||||
|
use App\Member\Member;
|
||||||
|
use App\Payment\Status;
|
||||||
|
use App\Payment\Subscription;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class StoreTest extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
public function testItStoresAPayment(): void
|
||||||
|
{
|
||||||
|
Event::fake([JobStarted::class, JobFinished::class, ReloadTriggered::class]);
|
||||||
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
|
$subscription = Subscription::factory()->create();
|
||||||
|
$member = Member::factory()->defaults()->create();
|
||||||
|
$status = Status::factory()->create();
|
||||||
|
|
||||||
|
$this->post("/member/{$member->id}/payment", [
|
||||||
|
'status_id' => $status->id,
|
||||||
|
'subscription_id' => $subscription->id,
|
||||||
|
'nr' => '2019',
|
||||||
|
])->assertOk();
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('payments', [
|
||||||
|
'member_id' => $member->id,
|
||||||
|
'status_id' => $status->id,
|
||||||
|
'subscription_id' => $subscription->id,
|
||||||
|
'nr' => '2019',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Event::assertDispatched(JobStarted::class, fn ($event) => $event->broadcastOn()[0]->name === 'jobs' && $event->message !== null);
|
||||||
|
Event::assertDispatched(JobFinished::class, fn ($event) => $event->broadcastOn()[0]->name === 'jobs' && $event->message !== null);
|
||||||
|
Event::assertDispatched(ReloadTriggered::class, fn ($event) => ['member', 'payment'] === $event->channels->toArray());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue