Add member confirmation
This commit is contained in:
parent
5c72f4219e
commit
43f05294c3
|
@ -19,7 +19,7 @@ class Member extends Model
|
|||
use Notifiable;
|
||||
use HasFactory;
|
||||
|
||||
public $fillable = ['firstname', 'lastname', 'nickname', 'other_country', 'birthday', 'joined_at', 'send_newspaper', 'address', 'further_address', 'zip', 'location', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'nami_id', 'group_id', 'letter_address', 'country_id', 'way_id', 'nationality_id', 'fee_id', 'region_id', 'gender_id', 'confession_id', 'letter_address', 'bill_kind_id', 'version', 'first_subactivity_id', 'first_activity_id'];
|
||||
public $fillable = ['firstname', 'lastname', 'nickname', 'other_country', 'birthday', 'joined_at', 'send_newspaper', 'address', 'further_address', 'zip', 'location', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'nami_id', 'group_id', 'letter_address', 'country_id', 'way_id', 'nationality_id', 'fee_id', 'region_id', 'gender_id', 'confession_id', 'letter_address', 'bill_kind_id', 'version', 'first_subactivity_id', 'first_activity_id', 'confirmed_at'];
|
||||
|
||||
public $dates = ['joined_at', 'birthday'];
|
||||
|
||||
|
@ -31,6 +31,7 @@ class Member extends Model
|
|||
'region_id' => 'integer',
|
||||
'confession_id' => 'integer',
|
||||
'nami_id' => 'integer',
|
||||
'is_confirmed' => 'boolean',
|
||||
];
|
||||
|
||||
public function scopeSearch($q, $text) {
|
||||
|
@ -51,6 +52,10 @@ class Member extends Model
|
|||
return $this->nami_id !== null;
|
||||
}
|
||||
|
||||
public function getNamiMemberships($api) {
|
||||
return $api->group($this->group->nami_id)->member($this->nami_id)->memberships()->toArray();
|
||||
}
|
||||
|
||||
//---------------------------------- Relations ----------------------------------
|
||||
public function country()
|
||||
{
|
||||
|
@ -121,8 +126,9 @@ class Member extends Model
|
|||
});
|
||||
}
|
||||
|
||||
public function getNamiMemberships($api) {
|
||||
return $api->group($this->group->nami_id)->member($this->nami_id)->memberships()->toArray();
|
||||
// ---------------------------------- Scopes -----------------------------------
|
||||
public function scopeWithIsConfirmed($q) {
|
||||
$q->selectSub('DATEDIFF(NOW(), IFNULL(confirmed_at, DATE_SUB(NOW(), INTERVAL 3 YEAR))) < 712', 'is_confirmed');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace App\Member;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MemberConfirmController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, Member $member) {
|
||||
$member->update(['confirmed_at' => now()]);
|
||||
|
||||
return redirect()->route('member.index');
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ class MemberController extends Controller
|
|||
session()->put('title', 'Mitglieder');
|
||||
|
||||
return \Inertia::render('member/Index', [
|
||||
'data' => MemberResource::collection(Member::search($request->query('search', null))->with('billKind')->paginate(15)),
|
||||
'data' => MemberResource::collection(Member::select('*')->search($request->query('search', null))->with('billKind')->withIsConfirmed()->paginate(15)),
|
||||
'toolbar' => [ ['href' => route('member.create'), 'label' => 'Mitglied anlegen', 'color' => 'primary', 'icon' => 'plus'] ],
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ class MemberResource extends JsonResource
|
|||
'bill_kind_id' => $this->bill_kind_id,
|
||||
'bill_kind_name' => optional($this->billKind)->name,
|
||||
'has_nami' => $this->nami_id !== null,
|
||||
'is_confirmed' => $this->is_confirmed,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateMembersConfirmedAtColumn extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('members', function (Blueprint $table) {
|
||||
$table->datetime('confirmed_at')->nullable()->after('version');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('members', function (Blueprint $table) {
|
||||
$table->dropColumn('confirmed_at');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -6,7 +6,8 @@
|
|||
<a v-for="item, index in menu" :key="index" href="#" @click.prevent="openMenu(index)" class="rounded py-1 px-3 text-gray-400" :class="index == active ? `bg-gray-600` : ''" v-text="item.title"></a>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" class="btn block w-full btn-primary">Speichern</button>
|
||||
<button type="button" v-show="mode !== 'create'" @click.prevent="confirm" class="btn block w-full btn-primary">Daten bestätigen</button>
|
||||
<button type="submit" class="mt-3 btn block w-full btn-primary">Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -85,6 +86,9 @@ export default {
|
|||
},
|
||||
|
||||
methods: {
|
||||
confirm() {
|
||||
this.$inertia.post(`/member/${this.inner.id}/confirm`);
|
||||
},
|
||||
openMenu(index) {
|
||||
this.active = index;
|
||||
},
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<div class="px-6 text-gray-200 font-semibold py-3 border-gray-600 border-b">Ort</div>
|
||||
<div class="px-6 text-gray-200 font-semibold py-3 border-gray-600 border-b">Mittendrin</div>
|
||||
<div class="px-6 text-gray-200 font-semibold py-3 border-gray-600 border-b">Nami</div>
|
||||
<div class="px-6 text-gray-200 font-semibold py-3 border-gray-600 border-b">Check</div>
|
||||
<div class="px-6 text-gray-200 font-semibold py-3 border-gray-600 border-b">Rechnung</div>
|
||||
<div class="px-6 text-gray-200 font-semibold py-3 border-gray-600 border-b">Geburtstag</div>
|
||||
<div class="px-6 text-gray-200 font-semibold py-3 border-gray-600 border-b">Eintritt</div>
|
||||
|
@ -26,6 +27,9 @@
|
|||
<div class="py-1 px-6">
|
||||
<v-bool v-model="member.has_nami"></v-bool>
|
||||
</div>
|
||||
<div class="py-1 px-6">
|
||||
<v-bool v-model="member.is_confirmed"></v-bool>
|
||||
</div>
|
||||
<div class="py-1 px-6">
|
||||
<div class="py-1 rounded-full flex text-xs items-center justify-center leading-none bg-primary-900" v-text="member.bill_kind_name" v-if="member.bill_kind_name"></div>
|
||||
<div class="py-1 rounded-full flex text-xs items-center justify-center leading-none" v-else>Kein</div>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use App\Member\MemberController;
|
||||
use App\Member\MemberConfirmController;
|
||||
use App\Http\Controllers\HomeController;
|
||||
use App\Initialize\InitializeController;
|
||||
|
||||
|
@ -12,5 +13,6 @@ Route::group(['middleware' => 'auth:web'], function () {
|
|||
Route::get('/', HomeController::class)->name('home');
|
||||
Route::resource('initialize', InitializeController::class);
|
||||
Route::resource('member', MemberController::class);
|
||||
Route::post('/member/{member}/confirm', MemberConfirmController::class);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue