Skip to content

Commit

Permalink
Use facade instead
Browse files Browse the repository at this point in the history
  • Loading branch information
go-vehikl committed Oct 24, 2024
1 parent 0d9d11b commit b0934a7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/Models/WebhookConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\File;

class WebhookConfiguration extends Model
{
Expand Down Expand Up @@ -70,7 +70,7 @@ public static function transformClassName(string $event): string
->toString();
}

public static function allModelEvents()
public static function allModelEvents(): array
{
$eventTypes = ['created', 'updated', 'deleted'];
$models = static::discoverModels();
Expand All @@ -89,10 +89,9 @@ public static function discoverModels(): array
{
$namespace = 'App\\Models\\';
$directory = app_path('Models');
$filesystem = app(Filesystem::class);

$models = [];
foreach ($filesystem->allFiles($directory) as $file) {
foreach (File::allFiles($directory) as $file) {
$models[] = $namespace . str($file->getFilename())
->replace([DIRECTORY_SEPARATOR, '.php'], ['\\', '']);
}
Expand All @@ -103,10 +102,9 @@ public static function discoverModels(): array
public static function discoverCustomEvents(): array
{
$directory = app_path('Events');
$filesystem = app(Filesystem::class);

$events = [];
foreach ($filesystem->allFiles($directory) as $file) {
foreach (File::allFiles($directory) as $file) {
$namespace = str($file->getPath())
->after(base_path())
->replace(DIRECTORY_SEPARATOR, '\\')
Expand Down

0 comments on commit b0934a7

Please sign in to comment.