Skip to content

Commit 52b21df

Browse files
committed
reupload update tenancy for models
2 parents f4dd1eb + 63119c3 commit 52b21df

File tree

74 files changed

+1181
-148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1181
-148
lines changed

app/Jobs/ImportGedcom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function handle(): int
4949
]);
5050
$parser = new GedcomParser();
5151

52-
$parser->parse($job->getConnectionName(), $this->filePath, $slug, true);
52+
$parser->parse($job->getConnectionName(), $this->filePath, $slug, false);
5353
// with(new GedcomParser())->parse($tenant->connectionName(), $this->filePath, $slug, true);
5454

5555
File::delete($this->filePath);

app/Models/Addr.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace App\Models;
44

5+
use App\Traits\BelongsToTenant;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67
use Illuminate\Database\Eloquent\Model;
78
use Illuminate\Database\Eloquent\Relations\BelongsTo;
89

910
class Addr extends Model
1011
{
11-
use HasFactory;
12+
use HasFactory, BelongsToTenant;
1213

1314
protected $fillable = [
1415
'adr1',
@@ -24,9 +25,5 @@ public function user(): BelongsTo
2425
return $this->belongsTo(User::class, 'user_id', 'id');
2526
}
2627

27-
28-
public function team()
29-
{
30-
return $this->belongsTo(Team::class);
31-
}
28+
3229
}

app/Models/Author.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace App\Models;
44

5+
use App\Traits\BelongsToTenant;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67
use Illuminate\Database\Eloquent\Model;
78
use Illuminate\Database\Eloquent\Relations\BelongsTo;
89

910
class Author extends Model
1011
{
11-
use HasFactory;
12+
use HasFactory, BelongsToTenant;
1213

1314
protected $fillable = ['description', 'is_active', 'name'];
1415

@@ -22,8 +23,4 @@ public function user(): BelongsTo
2223
}
2324

2425

25-
public function team()
26-
{
27-
return $this->belongsTo(Team::class);
28-
}
2926
}

app/Models/BatchData.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Filament\Facades\Filament;
6+
use Illuminate\Database\Eloquent\Factories\HasFactory;
7+
use Illuminate\Database\Eloquent\Model;
8+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
9+
10+
class BatchData extends \FamilyTree365\LaravelGedcom\Utils\BatchData
11+
{
12+
public static function upsert($modelClass, $conn, array $values, array $uniqueBy, array $update = [])
13+
{
14+
// error_log("modi upsert");
15+
$teamId = auth()->check() ? Filament::getTenant()->id : null;
16+
17+
// Add team_id to each data item
18+
foreach ($values as &$value) {
19+
$value['team_id'] = $teamId;
20+
}
21+
22+
return parent::upsert($modelClass, $conn, $values, $uniqueBy, $update);
23+
}
24+
}

app/Models/Chan.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace App\Models;
44

5+
use App\Traits\BelongsToTenant;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67
use Illuminate\Database\Eloquent\Model;
78
use Illuminate\Database\Eloquent\Relations\BelongsTo;
89

910
class Chan extends Model
1011
{
11-
use HasFactory;
12+
use HasFactory, BelongsToTenant;
1213

1314

1415

@@ -31,8 +32,4 @@ public function user(): BelongsTo
3132
}
3233

3334

34-
public function team()
35-
{
36-
return $this->belongsTo(Team::class);
37-
}
3835
}

app/Models/Citation.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace App\Models;
44

5+
use App\Traits\BelongsToTenant;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67
use Illuminate\Database\Eloquent\Model;
78
use Illuminate\Database\Eloquent\Relations\BelongsTo;
89

910
class Citation extends Model
1011
{
11-
use HasFactory;
12+
use HasFactory, BelongsToTenant;
1213

1314
protected $fillable = ['name', 'description', 'repository_id', 'volume', 'page', 'is_active', 'confidence', 'source_id'];
1415

@@ -28,8 +29,4 @@ public function user(): BelongsTo
2829
}
2930

3031

31-
public function team()
32-
{
33-
return $this->belongsTo(Team::class);
34-
}
3532
}

app/Models/Dna.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace App\Models;
44

5+
use App\Traits\BelongsToTenant;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67
use Illuminate\Database\Eloquent\Model;
78
use Illuminate\Database\Eloquent\Relations\BelongsTo;
89

910
class Dna extends Model
1011
{
11-
use HasFactory;
12+
use HasFactory, BelongsToTenant;
1213

1314

1415
protected $fillable = [
@@ -23,11 +24,4 @@ public function user(): BelongsTo
2324
return $this->belongsTo(User::class, 'user_id', 'id');
2425
}
2526

26-
27-
public function team()
28-
{
29-
return $this->belongsTo(Team::class);
30-
}
31-
32-
3327
}

app/Models/DnaMatching.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ public function user(): BelongsTo
2525
return $this->belongsTo(User::class, 'user_id', 'id');
2626
}
2727

28+
2829
}

app/Models/Family.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@
22

33
namespace App\Models;
44

5+
use App\Traits\BelongsToTenant;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67
use Illuminate\Database\Eloquent\Relations\BelongsTo;
78

89
class Family extends \FamilyTree365\LaravelGedcom\Models\Family
910
{
10-
use HasFactory;
11+
use HasFactory, BelongsToTenant;
1112

1213
public function user(): BelongsTo
1314
{
1415
return $this->belongsTo(User::class, 'user_id', 'id');
1516
}
1617

17-
public function team()
18-
{
19-
return $this->belongsTo(Team::class);
20-
}
2118
}

app/Models/FamilyEvent.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,18 @@
22

33
namespace App\Models;
44

5+
use App\Traits\BelongsToTenant;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67
use Illuminate\Database\Eloquent\Relations\BelongsTo;
78

89
class FamilyEvent extends \FamilyTree365\LaravelGedcom\Models\FamilyEvent
910
{
1011
//
11-
use HasFactory;
12+
use HasFactory, BelongsToTenant;
1213

1314
public function user(): BelongsTo
1415
{
1516
return $this->belongsTo(User::class, 'user_id', 'id');
1617
}
1718

18-
public function team()
19-
{
20-
return $this->belongsTo(Team::class);
21-
}
2219
}

app/Models/FamilySlgs.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,18 @@
22

33
namespace App\Models;
44

5+
use App\Traits\BelongsToTenant;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67
use Illuminate\Database\Eloquent\Relations\BelongsTo;
78

89
class FamilySlgs extends \FamilyTree365\LaravelGedcom\Models\FamilySlgs
910
{
1011
//
11-
use HasFactory;
12+
use HasFactory, BelongsToTenant;
1213

1314
public function user(): BelongsTo
1415
{
1516
return $this->belongsTo(User::class, 'user_id', 'id');
1617
}
1718

18-
19-
public function team()
20-
{
21-
return $this->belongsTo(Team::class);
22-
}
2319
}

app/Models/MediaObject.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22

33
namespace App\Models;
44

5+
use App\Traits\BelongsToTenant;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67

78
class MediaObject extends \FamilyTree365\LaravelGedcom\Models\MediaObject
89
{
9-
use HasFactory;
10+
use HasFactory, BelongsToTenant;
1011

11-
public function team()
12-
{
13-
return $this->belongsTo(Team::class);
14-
}
1512
}

app/Models/Note.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22

33
namespace App\Models;
44

5+
use App\Traits\BelongsToTenant;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67

78
class Note extends \FamilyTree365\LaravelGedcom\Models\Note
89
{
9-
use HasFactory;
10-
11-
public function team()
12-
{
13-
return $this->belongsTo(Team::class);
14-
}
10+
use HasFactory, BelongsToTenant;
1511
}

app/Models/Person.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
//use App\Traits\ConnectionTrait;
66

7+
use App\Traits\BelongsToTenant;
78
use Illuminate\Database\Eloquent\Factories\HasFactory;
89
use Illuminate\Database\Eloquent\Model;
910

@@ -12,7 +13,7 @@
1213

1314
class Person extends Model
1415
{
15-
use HasFactory;
16+
use HasFactory, BelongsToTenant;
1617

1718
protected $fillable = [
1819
'gid',
@@ -179,8 +180,4 @@ public function death()
179180
return $this->events->where('title', '=', 'DEAT')->first();
180181
}
181182

182-
public function team()
183-
{
184-
return $this->belongsTo(Team::class);
185-
}
186183
}

app/Models/PersonAlia.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22

33
namespace App\Models;
44

5+
use App\Traits\BelongsToTenant;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67

78
class PersonAlia extends \FamilyTree365\LaravelGedcom\Models\PersonAlia
89
{
9-
use HasFactory;
10+
use HasFactory, BelongsToTenant;
1011

11-
public function team()
12-
{
13-
return $this->belongsTo(Team::class);
14-
}
1512
}

app/Models/PersonAnci.php

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,12 @@
22

33
namespace App\Models;
44

5+
use App\Traits\BelongsToTenant;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67
use Illuminate\Database\Eloquent\Model;
78

8-
class PersonAnci extends Model
9+
class PersonAnci extends \FamilyTree365\LaravelGedcom\Models\PersonAnci
910
{
10-
use HasFactory;
11-
12-
/**
13-
* The table associated with the model.
14-
*
15-
* @var string
16-
*/
17-
protected $table = 'person_anci';
18-
19-
/**
20-
* The "type" of the auto-incrementing ID.
21-
*
22-
* @var string
23-
*/
24-
protected $keyType = 'integer';
25-
26-
/**
27-
* @var array
28-
*/
29-
protected $fillable = ['group', 'gid', 'anci', 'created_at', 'updated_at'];
30-
31-
public function team()
32-
{
33-
return $this->belongsTo(Team::class);
34-
}
11+
use HasFactory, BelongsToTenant;
3512

3613
}

app/Models/PersonAsso.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22

33
namespace App\Models;
44

5+
use App\Traits\BelongsToTenant;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67

78
class PersonAsso extends \FamilyTree365\LaravelGedcom\Models\PersonAsso
89
{
9-
use HasFactory;
10-
11-
public function team()
12-
{
13-
return $this->belongsTo(Team::class);
14-
}
10+
use HasFactory, BelongsToTenant;
1511
}

app/Models/PersonEvent.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace App\Models;
44

5+
use App\Traits\BelongsToTenant;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67

78
class PersonEvent extends \FamilyTree365\LaravelGedcom\Models\PersonEvent
89
{
9-
use HasFactory;
10+
use HasFactory, BelongsToTenant;
1011
}

app/Models/PersonLds.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace App\Models;
44

5+
use App\Traits\BelongsToTenant;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67

78
class PersonLds extends \FamilyTree365\LaravelGedcom\Models\PersonLds
89
{
9-
use HasFactory;
10+
use HasFactory, BelongsToTenant;
1011
}

0 commit comments

Comments
 (0)