diff --git a/app/Activity.php b/app/Activity.php index f469bb10..1c998efb 100644 --- a/app/Activity.php +++ b/app/Activity.php @@ -11,7 +11,7 @@ class Activity extends Model use HasNamiField; - public $fillable = ['name', 'nami_id']; + public $fillable = ['name', 'is_filterable', 'nami_id']; public $timestamps = false; public $casts = [ diff --git a/app/Http/Views/MemberView.php b/app/Http/Views/MemberView.php index 26a2cea6..0b7c8736 100644 --- a/app/Http/Views/MemberView.php +++ b/app/Http/Views/MemberView.php @@ -9,6 +9,7 @@ use App\Payment\ActionFactory; use App\Payment\PaymentResource; use App\Payment\Status; use App\Payment\Subscription; +use App\Subactivity; use Illuminate\Http\Request; class MemberView { @@ -23,6 +24,8 @@ class MemberView { ->orderByRaw('lastname, firstname') ->paginate(15) ), + 'filterActivities' => Activity::where('is_filterable', true)->get()->pluck('name', 'id'), + 'filterSubactivities' => Subactivity::where('is_filterable', true)->get()->pluck('name', 'id'), 'toolbar' => [ ['href' => route('member.index'), 'label' => 'Zurück', 'color' => 'primary', 'icon' => 'plus'] ], 'paymentDefaults' => ['nr' => date('Y')], 'subscriptions' => Subscription::get()->pluck('name', 'id'), diff --git a/app/Member/Member.php b/app/Member/Member.php index eac57b19..02e1356f 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -204,6 +204,16 @@ class Member extends Model if (data_get($filter, 'bill_kind', false)) { $q->where('bill_kind_id', $filter['bill_kind']); } + if (data_get($filter, 'subactivity_id', false) || data_get($filter, 'activity_id', false)) { + $q->whereHas('memberships', function ($q) use ($filter) { + if (data_get($filter, 'subactivity_id', false)) { + $q->where('subactivity_id', $filter['subactivity_id']); + } + if (data_get($filter, 'activity_id', false)) { + $q->where('activity_id', $filter['activity_id']); + } + }); + } return $q; } diff --git a/app/Member/MemberController.php b/app/Member/MemberController.php index 624d31ec..6f34bb80 100644 --- a/app/Member/MemberController.php +++ b/app/Member/MemberController.php @@ -23,6 +23,8 @@ class MemberController extends Controller public $filter = [ 'ausstand' => false, 'bill_kind' => null, + 'activity_id' => null, + 'subactivity_id' => null, ]; public function index(Request $request): Response { diff --git a/app/Subactivity.php b/app/Subactivity.php index c146246a..171af4b1 100644 --- a/app/Subactivity.php +++ b/app/Subactivity.php @@ -15,7 +15,7 @@ class Subactivity extends Model use HasNamiField; use Sluggable; - public $fillable = ['is_age_group', 'slug', 'name', 'nami_id']; + public $fillable = ['is_age_group', 'is_filterable', 'slug', 'name', 'nami_id']; public $timestamps = false; diff --git a/database/migrations/2021_08_22_223227_create_activities_is_leader_column.php b/database/migrations/2021_08_22_223227_create_activities_is_leader_column.php new file mode 100644 index 00000000..cfdd3e72 --- /dev/null +++ b/database/migrations/2021_08_22_223227_create_activities_is_leader_column.php @@ -0,0 +1,41 @@ +boolean('is_filterable')->after('name')->default(false); + }); + Schema::table('subactivities', function (Blueprint $table) { + $table->boolean('is_filterable')->after('slug')->default(false); + }); + Activity::whereIn('name', ['€ Mitglied', '€ passive Mitgliedschaft', 'Schnuppermitgliedschaft', '€ LeiterIn', '€ KassiererIn', '€ KassenprüferIn']) + ->update(['is_filterable' => true]); + SubActivity::whereIn('name', ['Biber', 'Wölfling', 'Jungpfadfinder', 'Pfadfinder', 'Rover', 'Vorstand', 'Sonstige']) + ->update(['is_filterable' => true]); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('activities', function (Blueprint $table) { + // + }); + } +} diff --git a/resources/js/views/member/Filt.vue b/resources/js/views/member/Filt.vue index da531b90..f9e8a359 100644 --- a/resources/js/views/member/Filt.vue +++ b/resources/js/views/member/Filt.vue @@ -2,6 +2,8 @@