Skip to content

Commit

Permalink
Merge pull request #7 from YazeedAlsaif/main
Browse files Browse the repository at this point in the history
Add scopeBannedByType in Bannable.php to allow scoping banned models by type
  • Loading branch information
mchev authored Jun 10, 2023
2 parents 228e925 + d4085a4 commit 4250c2e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Traits/Bannable.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,18 @@ public function scopeWhereBansMeta(Builder $query, string $key, $value): void
$query->where('metas->'.$key, $value)->notExpired();
});
}

/**
*
* @param Builder $query
* @param string $className
* @return void
*/
public function scopeBannedByType(Builder $query, string $className) : void
{
$query->whereHas('bans', function ($query) use ($className) {
$query->where('created_by_type', $className)->notExpired();
});
}

}

0 comments on commit 4250c2e

Please sign in to comment.