mirror of
https://github.com/anna-sara/vbytes_lan.git
synced 2026-09-03 11:55:22 +02:00
Added SSN to participant table and added toggles for paid and memeber in particpant table
This commit is contained in:
parent
8b082f5bd8
commit
5c773a684c
5 changed files with 65 additions and 16 deletions
|
|
@ -68,6 +68,11 @@ class ParticipantForm
|
||||||
'reserv' => 'Reserv',
|
'reserv' => 'Reserv',
|
||||||
'besök' => 'Besök',
|
'besök' => 'Besök',
|
||||||
]),
|
]),
|
||||||
|
TextInput::make('ssn')
|
||||||
|
->label('SSN')
|
||||||
|
->default(null)
|
||||||
|
->length(12)
|
||||||
|
->columnSpan('full'),
|
||||||
TextInput::make('first_name')
|
TextInput::make('first_name')
|
||||||
->required(),
|
->required(),
|
||||||
TextInput::make('surname')
|
TextInput::make('surname')
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,11 @@ use Filament\Support\Icons\Heroicon;
|
||||||
use App\Filament\Exports\ParticipantExporter;
|
use App\Filament\Exports\ParticipantExporter;
|
||||||
use Filament\Actions\ExportAction;
|
use Filament\Actions\ExportAction;
|
||||||
use Filament\Tables\Columns\TextInputColumn;
|
use Filament\Tables\Columns\TextInputColumn;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
use Filament\Tables\Grouping\Group;
|
use Filament\Tables\Grouping\Group;
|
||||||
use Filament\Tables\Columns\Summarizers\Count;
|
use Filament\Tables\Columns\Summarizers\Count;
|
||||||
|
use Filament\Tables\Columns\ToggleColumn;
|
||||||
|
|
||||||
class ParticipantsTable
|
class ParticipantsTable
|
||||||
{
|
{
|
||||||
|
|
@ -45,7 +48,14 @@ class ParticipantsTable
|
||||||
TextInputColumn::make('lan_id')
|
TextInputColumn::make('lan_id')
|
||||||
->label('ID')
|
->label('ID')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true)
|
||||||
|
->rules(fn ($record) => [
|
||||||
|
Rule::unique('participants', 'lan_id')->ignore($record->id),
|
||||||
|
])
|
||||||
|
->validationMessages([
|
||||||
|
'unique' => 'LAN ID is already assigned to another participant.',
|
||||||
|
]),
|
||||||
TextColumn::make('status')
|
TextColumn::make('status')
|
||||||
->label('Status')
|
->label('Status')
|
||||||
->badge()
|
->badge()
|
||||||
|
|
@ -56,12 +66,11 @@ class ParticipantsTable
|
||||||
'besök' => 'gray'
|
'besök' => 'gray'
|
||||||
})
|
})
|
||||||
->formatStateUsing(fn (string $state): string => __(ucfirst($state))),
|
->formatStateUsing(fn (string $state): string => __(ucfirst($state))),
|
||||||
IconColumn::make('paid')
|
TextColumn::make('ssn')
|
||||||
->boolean()
|
->label('SSN')
|
||||||
->sortable(),
|
->searchable()
|
||||||
IconColumn::make('emailed')
|
->sortable()
|
||||||
->boolean()
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
->sortable(),
|
|
||||||
TextColumn::make('first_name')
|
TextColumn::make('first_name')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
|
@ -99,11 +108,13 @@ class ParticipantsTable
|
||||||
->badge()
|
->badge()
|
||||||
->color('gray')
|
->color('gray')
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
ToggleColumn::make('paid')
|
||||||
IconColumn::make('member')
|
->sortable(),
|
||||||
|
ToggleColumn::make('member')
|
||||||
|
->sortable(),
|
||||||
|
IconColumn::make('emailed')
|
||||||
->boolean()
|
->boolean()
|
||||||
->sortable()
|
->sortable(),
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
TextColumn::make('comment')
|
TextColumn::make('comment')
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
|
@ -129,7 +140,13 @@ class ParticipantsTable
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
//
|
SelectFilter::make('status')
|
||||||
|
->options([
|
||||||
|
'lan' => 'Ordinarie',
|
||||||
|
'reserv' => 'Reserv',
|
||||||
|
'besök' => 'Besök',
|
||||||
|
])
|
||||||
|
->multiple(),
|
||||||
])
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
EditAction::make()
|
EditAction::make()
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class ParticipantController extends Controller
|
||||||
if ($permission === "key_5") {
|
if ($permission === "key_5") {
|
||||||
|
|
||||||
$participants = Participant::whereNotNull('lan_id')
|
$participants = Participant::whereNotNull('lan_id')
|
||||||
->select('id','lan_id', 'first_name', 'surname','grade','phone','email', 'guardian_name', 'guardian_phone', 'guardian_email', 'is_visiting','friends', 'special_diet', 'status','created_at', 'updated_at')
|
->select('id','lan_id', 'ssn','first_name', 'surname','grade','phone','email', 'guardian_name', 'guardian_phone', 'guardian_email', 'is_visiting','friends', 'special_diet', 'status','created_at', 'updated_at')
|
||||||
->get();
|
->get();
|
||||||
$volunteers = Volunteer::whereNotNull('lan_id')
|
$volunteers = Volunteer::whereNotNull('lan_id')
|
||||||
->select('id','lan_id', 'first_name', 'surname','phone','email', 'areas', 'created_at', 'updated_at')
|
->select('id','lan_id', 'first_name', 'surname','phone','email', 'areas', 'created_at', 'updated_at')
|
||||||
|
|
@ -51,7 +51,7 @@ class ParticipantController extends Controller
|
||||||
if ($permission === "key_3") {
|
if ($permission === "key_3") {
|
||||||
|
|
||||||
$participants = Participant::whereNotNull('lan_id')
|
$participants = Participant::whereNotNull('lan_id')
|
||||||
->select('id','lan_id', 'first_name', 'surname','grade','phone','email', 'guardian_name', 'guardian_phone', 'guardian_email', 'is_visiting','friends', 'special_diet', 'status','created_at', 'updated_at')
|
->select('id','lan_id', 'ssn', 'first_name', 'surname','grade','phone','email', 'guardian_name', 'guardian_phone', 'guardian_email', 'is_visiting','friends', 'special_diet', 'status','created_at', 'updated_at')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return $dataArr = [
|
return $dataArr = [
|
||||||
|
|
@ -96,6 +96,7 @@ class ParticipantController extends Controller
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'member' => 'required',
|
'member' => 'required',
|
||||||
'first_name' => 'required',
|
'first_name' => 'required',
|
||||||
|
'ssn' => 'nullable',
|
||||||
'surname' => 'required',
|
'surname' => 'required',
|
||||||
'grade' => 'required',
|
'grade' => 'required',
|
||||||
'phone' => 'nullable',
|
'phone' => 'nullable',
|
||||||
|
|
@ -116,7 +117,7 @@ class ParticipantController extends Controller
|
||||||
$status = "lan";
|
$status = "lan";
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (! $request->is_visiting) {
|
else if ($request->is_visiting) {
|
||||||
$status = "besök";
|
$status = "besök";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -126,6 +127,7 @@ class ParticipantController extends Controller
|
||||||
|
|
||||||
Participant::create([
|
Participant::create([
|
||||||
'member' => $request->member,
|
'member' => $request->member,
|
||||||
|
'ssn' => $request->ssn,
|
||||||
'first_name' => $request->first_name,
|
'first_name' => $request->first_name,
|
||||||
'surname' => $request->surname,
|
'surname' => $request->surname,
|
||||||
'grade' => $request->grade,
|
'grade' => $request->grade,
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ class Participant extends Model
|
||||||
'status',
|
'status',
|
||||||
'emailed',
|
'emailed',
|
||||||
'comment',
|
'comment',
|
||||||
'paid'
|
'paid',
|
||||||
|
'ssn'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected static function booted()
|
protected static function booted()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('participants', function (Blueprint $table) {
|
||||||
|
$table->string('ssn')->nullable()->after('status');
|
||||||
|
$table->unique('lan_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('participants', function (Blueprint $table) {
|
||||||
|
$table->dropUnique(['lan_id']);
|
||||||
|
$table->dropColumn('ssn');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue