Skip to content

Commit 9e5d216

Browse files
committed
gedcom
1 parent 751aebc commit 9e5d216

File tree

6 files changed

+76
-14
lines changed

6 files changed

+76
-14
lines changed

app/Filament/App/Resources/GedcomResource.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Filament\Tables;
1616
use Filament\Tables\Table;
1717
use Illuminate\Support\Facades\Auth;
18+
use Illuminate\Support\Facades\Log;
1819
use Illuminate\Support\Facades\Storage;
1920

2021
class GedcomResource extends Resource
@@ -44,18 +45,21 @@ public static function form(Schema $form): Schema
4445
{
4546
return $form
4647
->schema([
47-
FileUpload::make('attachment')
48-
->required()
48+
FileUpload::make('filename')
49+
->multiple(false)
50+
// ->required()
4951
->maxSize(100000)
5052
->directory('gedcom-form-imports')
5153
->visibility('private')
52-
->afterStateUpdated(function ($state, $set, $livewire): void {
53-
if ($state === null) {
54-
return;
55-
}
56-
$path = $state->store('gedcom-form-imports', 'private');
57-
ImportGedcom::dispatch(Auth::user(), Storage::disk('private')->path($path));
58-
}),
54+
55+
// ->afterStateUpdated(function ($state, $set, $livewire): void {
56+
// if ($state === null) {
57+
// return;
58+
// }
59+
// $path = $state->store('gedcom-form-imports', 'private');
60+
// Log::info($path);
61+
// //ImportGedcom::dispatch(Auth::user(), Storage::disk('private')->path($path));
62+
// }),
5963
]);
6064
}
6165

@@ -66,7 +70,8 @@ public static function table(Table $table): Table
6670
->columns([
6771
Tables\Columns\TextColumn::make('name')
6872
->searchable(),
69-
Tables\Columns\TextColumn::make('file_name')
73+
Tables\Columns\TextColumn::make('filename')
74+
->label('File name')
7075
->searchable(),
7176
Tables\Columns\TextColumn::make('created_at')
7277
->dateTime()

app/Filament/App/Resources/GedcomResource/Pages/CreateGedcom.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,22 @@
44

55
use App\Filament\App\Resources\GedcomResource;
66
use Filament\Resources\Pages\CreateRecord;
7+
use App\Jobs\ImportGedcom;
8+
use Illuminate\Support\Facades\Log;
9+
use Illuminate\Support\Facades\Auth;
10+
use Illuminate\Support\Facades\Storage;
711

812
class CreateGedcom extends CreateRecord
913
{
1014
protected static string $resource = GedcomResource::class;
15+
16+
protected function beforeCreate(): void
17+
{
18+
// Runs before the form fields are saved to the database.
19+
// $path = $this->data['filename'];
20+
foreach ($this->data['filename'] as $key => $path) {
21+
Log::info($path);
22+
ImportGedcom::dispatch(Auth::user(), Storage::disk('private')->path($path));
23+
}
24+
}
1125
}

app/Models/Gedcom.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ class Gedcom extends Model
1616
// protected $connection = 'landlord';
1717

1818
protected $fillable = [
19-
'remote_id',
20-
'data',
21-
'area',
22-
'db_name',
19+
'filename',
2320
];
2421

2522
protected function casts(): array

app/Providers/AppServiceProvider.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ public function register(): void
2727
*/
2828
public function boot(): void
2929
{
30+
if (config('app.debug')) {
31+
// \DB::listen(function ($query): void {
32+
// \Log::info(
33+
// $query->sql,
34+
// $query->bindings,
35+
// $query->time
36+
// );
37+
// });
38+
}
39+
40+
// Register Livewire components here
41+
// Livewire::component('devilliers-report', DevilliersReport::class);
42+
// Livewire::component('descendant-chart-component', DescendantChartComponent::class);
43+
// Livewire::component('people-search', PeopleSearch::class);
44+
// Livewire::component('pedigree-chart', PedigreeChart::class);
45+
// Livewire::component('create-team', CreateTeam::class);
46+
// Livewire::component('edit-profile', EditProfile::class);
3047
// Enable default modules on first boot
3148
$this->enableDefaultModules();
3249
}

database/migrations/2024_03_28_221256_create_gedcoms_table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public function up(): void
1212
{
1313
Schema::create('gedcoms', function (Blueprint $table) {
1414
$table->id();
15+
$table->string('filename');
1516
$table->timestamps();
1617
});
1718
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('gedcoms', function (Blueprint $table) {
15+
$table->string('filename');
16+
});
17+
}
18+
19+
/**
20+
* Reverse the migrations.
21+
*/
22+
public function down(): void
23+
{
24+
Schema::table('gedcoms', function (Blueprint $table) {
25+
//
26+
});
27+
}
28+
};

0 commit comments

Comments
 (0)