mirror of
https://github.com/anna-sara/vbytes_lan.git
synced 2026-09-03 10:25: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',
|
||||
'besök' => 'Besök',
|
||||
]),
|
||||
TextInput::make('ssn')
|
||||
->label('SSN')
|
||||
->default(null)
|
||||
->length(12)
|
||||
->columnSpan('full'),
|
||||
TextInput::make('first_name')
|
||||
->required(),
|
||||
TextInput::make('surname')
|
||||
|
|
|
|||
|
|
@ -20,8 +20,11 @@ use Filament\Support\Icons\Heroicon;
|
|||
use App\Filament\Exports\ParticipantExporter;
|
||||
use Filament\Actions\ExportAction;
|
||||
use Filament\Tables\Columns\TextInputColumn;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Grouping\Group;
|
||||
use Filament\Tables\Columns\Summarizers\Count;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
|
||||
class ParticipantsTable
|
||||
{
|
||||
|
|
@ -45,7 +48,14 @@ class ParticipantsTable
|
|||
TextInputColumn::make('lan_id')
|
||||
->label('ID')
|
||||
->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')
|
||||
->label('Status')
|
||||
->badge()
|
||||
|
|
@ -56,12 +66,11 @@ class ParticipantsTable
|
|||
'besök' => 'gray'
|
||||
})
|
||||
->formatStateUsing(fn (string $state): string => __(ucfirst($state))),
|
||||
IconColumn::make('paid')
|
||||
->boolean()
|
||||
->sortable(),
|
||||
IconColumn::make('emailed')
|
||||
->boolean()
|
||||
->sortable(),
|
||||
TextColumn::make('ssn')
|
||||
->label('SSN')
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('first_name')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
|
@ -99,11 +108,13 @@ class ParticipantsTable
|
|||
->badge()
|
||||
->color('gray')
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
IconColumn::make('member')
|
||||
ToggleColumn::make('paid')
|
||||
->sortable(),
|
||||
ToggleColumn::make('member')
|
||||
->sortable(),
|
||||
IconColumn::make('emailed')
|
||||
->boolean()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
->sortable(),
|
||||
TextColumn::make('comment')
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
|
@ -129,7 +140,13 @@ class ParticipantsTable
|
|||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
SelectFilter::make('status')
|
||||
->options([
|
||||
'lan' => 'Ordinarie',
|
||||
'reserv' => 'Reserv',
|
||||
'besök' => 'Besök',
|
||||
])
|
||||
->multiple(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class ParticipantController extends Controller
|
|||
if ($permission === "key_5") {
|
||||
|
||||
$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();
|
||||
$volunteers = Volunteer::whereNotNull('lan_id')
|
||||
->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") {
|
||||
|
||||
$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();
|
||||
|
||||
return $dataArr = [
|
||||
|
|
@ -96,6 +96,7 @@ class ParticipantController extends Controller
|
|||
$request->validate([
|
||||
'member' => 'required',
|
||||
'first_name' => 'required',
|
||||
'ssn' => 'nullable',
|
||||
'surname' => 'required',
|
||||
'grade' => 'required',
|
||||
'phone' => 'nullable',
|
||||
|
|
@ -116,7 +117,7 @@ class ParticipantController extends Controller
|
|||
$status = "lan";
|
||||
}
|
||||
|
||||
else if (! $request->is_visiting) {
|
||||
else if ($request->is_visiting) {
|
||||
$status = "besök";
|
||||
}
|
||||
|
||||
|
|
@ -126,6 +127,7 @@ class ParticipantController extends Controller
|
|||
|
||||
Participant::create([
|
||||
'member' => $request->member,
|
||||
'ssn' => $request->ssn,
|
||||
'first_name' => $request->first_name,
|
||||
'surname' => $request->surname,
|
||||
'grade' => $request->grade,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ class Participant extends Model
|
|||
'status',
|
||||
'emailed',
|
||||
'comment',
|
||||
'paid'
|
||||
'paid',
|
||||
'ssn'
|
||||
];
|
||||
|
||||
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