Skip to content

Commit

Permalink
Installation
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Geurts committed Jan 22, 2024
1 parent edee984 commit 9f8126d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

GOD_MODE=true // this allow developers to see all persons in all teams
GOD_MODE=true // this allow developers to see ALL persons in ALL teams

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Couple.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ protected static function booted(): void
static::addGlobalScope('team', function (Builder $builder) {
if (! auth()) {
return;
} elseif (env('GOD_MODE', 'false') && auth()->user()->is_developer) {
return true;
} else {
$builder->where('couples.team_id', auth()->user()->current_team_id);
}
Expand Down
8 changes: 4 additions & 4 deletions app/Models/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Person extends Model
protected static function booted(): void
{
static::addGlobalScope('team', function (Builder $builder) {
if (!auth()) {
if (! auth()) {
return;
} elseif (env('GOD_MODE', 'false') && auth()->user()->is_developer) {
return true;
Expand Down Expand Up @@ -415,7 +415,7 @@ public function childrenNaturalAll(): Collection
/* --------------------------------------------------------------------------------- */
public function getPartnersAttribute(): Collection
{
if (!array_key_exists('partners', $this->relations)) {
if (! array_key_exists('partners', $this->relations)) {
$partners_1 = $this->belongsToMany(Person::class, 'couples', 'person1_id', 'person2_id')
->withPivot(['id', 'date_start', 'date_end', 'is_married', 'has_ended'])
->with('children')
Expand Down Expand Up @@ -499,7 +499,7 @@ public function updateMetadata(Collection $personMetadata)

public function siblings(): Collection
{
if (!$this->father_id && !$this->mother_id && !$this->parents_id) {
if (! $this->father_id && ! $this->mother_id && ! $this->parents_id) {
return collect([]);
} else {
$siblings_father = $this->father_id ? Person::where('id', '!=', $this->id)->where('father_id', $this->father_id)->get() : collect([]);
Expand Down Expand Up @@ -528,7 +528,7 @@ public function siblings(): Collection

public function siblings_with_children(): Collection // only used in family chart
{
if (!$this->father_id && !$this->mother_id && !$this->parents_id) {
if (! $this->father_id && ! $this->mother_id && ! $this->parents_id) {
return collect([]);
} else {
$siblings_father = $this->father_id ? Person::where('id', '!=', $this->id)->where('father_id', $this->father_id)->with('children')->get() : collect([]);
Expand Down
8 changes: 4 additions & 4 deletions database/seeders/DemoSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ protected function generateTestData(): void

'father_id' => 2,

'team_id' => 3,
'team_id' => 3, // BRITISH ROYALS Team
]);

Person::create([
Expand Down Expand Up @@ -306,9 +306,9 @@ protected function generateTestData(): void
'firstname' => 'John',
'surname' => 'DOE',
'sex' => 'm',
'dob' => '2000-01-01',
'dob' => '1960-01-01',

'team_id' => 5,
'team_id' => 5, // Editors Personal Team
]);

Person::create([
Expand All @@ -318,7 +318,7 @@ protected function generateTestData(): void
'sex' => 'm',
'dob' => '2000-01-01',

'team_id' => 5,
'team_id' => 5, // Editors Personal Team
]);
}
}

0 comments on commit 9f8126d

Please sign in to comment.