Skip to content

Commit

Permalink
Merge branch 'main' of github.com:stephenjude/filament-jetstream
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenjude committed Feb 25, 2024
2 parents 224ffa9 + 4829dfe commit aeaa9da
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 47 deletions.
10 changes: 5 additions & 5 deletions config/jetstream.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
'navigation_items' => [
'profile' => [
'display' => false,
'sort' => 1
'sort' => 1,
],
'team' => [
'display' => false,
'sort' => 2
'sort' => 2,
],
'api_tokens' => [
'display' => false,
'sort' => 3
]
]
'sort' => 3,
],
],
];
57 changes: 28 additions & 29 deletions src/Commands/FilamentJetstreamCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function handle(): int
{
$this->callSilently(
sprintf(
"jetstream:install livewire %s %s %s %s",
'jetstream:install livewire %s %s %s %s',
$this->option('team') ? '--team' : '',
$this->option('api') ? '--api' : '',
$this->option('verification') ? '--verification' : '',
Expand All @@ -30,7 +30,6 @@ public function handle(): int
$this->configureTeam();
}


$this->configureAssets();

$this->comment('All done');
Expand All @@ -42,9 +41,9 @@ public function configureUser(): void
{
$this->replaceInFile(
search: 'use Laravel\Sanctum\HasApiTokens;',
replace: 'use Filament\Panel;'.PHP_EOL.
'use Filament\Models\Contracts\FilamentUser;'.PHP_EOL.
'use Laravel\Sanctum\HasApiTokens;'.PHP_EOL,
replace: 'use Filament\Panel;' . PHP_EOL .
'use Filament\Models\Contracts\FilamentUser;' . PHP_EOL .
'use Laravel\Sanctum\HasApiTokens;' . PHP_EOL,
path: app_path('Models/User.php'),
);

Expand All @@ -55,9 +54,9 @@ public function configureUser(): void
);

$this->replaceInFile(
search: '}'.PHP_EOL,
replace: 'public function canAccessPanel(Panel $panel): bool'.PHP_EOL.'{'.PHP_EOL.
' return;'.PHP_EOL.'}'.PHP_EOL.'}'.PHP_EOL,
search: '}' . PHP_EOL,
replace: 'public function canAccessPanel(Panel $panel): bool' . PHP_EOL . '{' . PHP_EOL .
' return;' . PHP_EOL . '}' . PHP_EOL . '}' . PHP_EOL,
path: app_path('Models/User.php'),
);

Expand All @@ -74,10 +73,10 @@ public function configureTeam(): void
{
$this->replaceInFile(
search: 'use Laravel\Sanctum\HasApiTokens;',
replace: 'use Illuminate\Support\Collection;'.PHP_EOL.
'use Illuminate\Database\Eloquent\Model;'.PHP_EOL.
'use Filament\Models\Contracts\HasTenants;'.PHP_EOL.
'use Laravel\Sanctum\HasApiTokens;'.PHP_EOL,
replace: 'use Illuminate\Support\Collection;' . PHP_EOL .
'use Illuminate\Database\Eloquent\Model;' . PHP_EOL .
'use Filament\Models\Contracts\HasTenants;' . PHP_EOL .
'use Laravel\Sanctum\HasApiTokens;' . PHP_EOL,
path: app_path('Models/User.php'),
);

Expand All @@ -88,28 +87,28 @@ public function configureTeam(): void
);

$this->replaceInFile(
search: '}'.PHP_EOL.'}'.PHP_EOL,
replace: 'public function canAccessTenant(Model $tenant): bool'.PHP_EOL.'{'.PHP_EOL.
' return $this->belongsToTeam($tenant);'.PHP_EOL.'}'.PHP_EOL.'}'.PHP_EOL,
search: '}' . PHP_EOL . '}' . PHP_EOL,
replace: 'public function canAccessTenant(Model $tenant): bool' . PHP_EOL . '{' . PHP_EOL .
' return $this->belongsToTeam($tenant);' . PHP_EOL . '}' . PHP_EOL . '}' . PHP_EOL,
path: app_path('Models/User.php'),
);

$this->replaceInFile(
search: '}'.PHP_EOL.'}'.PHP_EOL,
replace: 'public function getTenants(Panel $panel): Collection'.PHP_EOL.'{'.PHP_EOL.
' return $this->allTeams();'.PHP_EOL.'}'.PHP_EOL.'}'.PHP_EOL,
search: '}' . PHP_EOL . '}' . PHP_EOL,
replace: 'public function getTenants(Panel $panel): Collection' . PHP_EOL . '{' . PHP_EOL .
' return $this->allTeams();' . PHP_EOL . '}' . PHP_EOL . '}' . PHP_EOL,
path: app_path('Models/User.php'),
);
}

public function configureAssets(): void
{
$this->replaceInFile(
search: 'content: ['.PHP_EOL,
replace: 'content: ['.PHP_EOL.
'./app/Filament/**/*.php'.PHP_EOL.
'./resources/views/filament/**/*.blade.php'.PHP_EOL.
'./vendor/filament/**/*.blade.php'.PHP_EOL,
search: 'content: [' . PHP_EOL,
replace: 'content: [' . PHP_EOL .
'./app/Filament/**/*.php' . PHP_EOL .
'./resources/views/filament/**/*.blade.php' . PHP_EOL .
'./vendor/filament/**/*.blade.php' . PHP_EOL,
path: base_path('Models/User.php'),
);

Expand All @@ -120,16 +119,16 @@ public function configureAssets(): void
);

$this->replaceInFile(
search: '}'.PHP_EOL.'}'.PHP_EOL,
replace: 'public function canAccessTenant(Model $tenant): bool'.PHP_EOL.'{'.PHP_EOL.
' return $this->belongsToTeam($tenant);'.PHP_EOL.'}'.PHP_EOL.'}'.PHP_EOL,
search: '}' . PHP_EOL . '}' . PHP_EOL,
replace: 'public function canAccessTenant(Model $tenant): bool' . PHP_EOL . '{' . PHP_EOL .
' return $this->belongsToTeam($tenant);' . PHP_EOL . '}' . PHP_EOL . '}' . PHP_EOL,
path: app_path('Models/User.php'),
);

$this->replaceInFile(
search: '}'.PHP_EOL.'}'.PHP_EOL,
replace: 'public function getTenants(Panel $panel): Collection'.PHP_EOL.'{'.PHP_EOL.
' return $this->allTeams();'.PHP_EOL.'}'.PHP_EOL.'}'.PHP_EOL,
search: '}' . PHP_EOL . '}' . PHP_EOL,
replace: 'public function getTenants(Panel $panel): Collection' . PHP_EOL . '{' . PHP_EOL .
' return $this->allTeams();' . PHP_EOL . '}' . PHP_EOL . '}' . PHP_EOL,
path: app_path('tailwind.config.js'),
);
}
Expand Down
7 changes: 3 additions & 4 deletions src/FilamentJetstreamPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use FilamentJetstream\FilamentJetstream\Pages\CreateTeam;
use FilamentJetstream\FilamentJetstream\Pages\EditTeam;
use Laravel\Jetstream\Features;
use Laravel\Jetstream\Http\Livewire\ApiTokenManager;

class FilamentJetstreamPlugin implements Plugin
{
Expand All @@ -33,7 +32,7 @@ public function register(Panel $panel): void
MenuItem::make()
->label('Profile')
->icon('heroicon-o-user-circle')
->url(static fn() => Filament::getTenant()
->url(static fn () => Filament::getTenant()
? url(EditProfile::getUrl())
: url('/app')),
]);
Expand All @@ -44,7 +43,7 @@ public function register(Panel $panel): void
MenuItem::make()
->label('API Tokens')
->icon('heroicon-o-key')
->url(static fn() => Filament::getTenant()
->url(static fn () => Filament::getTenant()
? url(ApiTokens::getUrl())
: url('/app')),
]);
Expand All @@ -58,7 +57,7 @@ public function register(Panel $panel): void
MenuItem::make()
->label('Team Settings')
->icon('heroicon-o-cog-6-tooth')
->url(static fn() => Filament::getTenant()
->url(static fn () => Filament::getTenant()
? url(\App\Filament\App\Pages\EditTeam::getUrl())
: url('/app')),
]);
Expand Down
5 changes: 2 additions & 3 deletions src/FilamentJetstreamServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use FilamentJetstream\FilamentJetstream\Commands\FilamentJetstreamCommand;
use FilamentJetstream\FilamentJetstream\Listeners\CreatePersonalTeam;
use FilamentJetstream\FilamentJetstream\Testing\TestsFilamentJetstream;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Event;
use Livewire\Features\SupportTesting\Testable;
use Spatie\LaravelPackageTools\Commands\InstallCommand;
Expand Down Expand Up @@ -95,8 +94,8 @@ protected function getAssets(): array
{
return [
// AlpineComponent::make('filament-jetstream', __DIR__ . '/../resources/dist/components/filament-jetstream.js'),
Css::make('filament-jetstream-styles', __DIR__.'/../resources/dist/filament-jetstream.css'),
Js::make('filament-jetstream-scripts', __DIR__.'/../resources/dist/filament-jetstream.js'),
Css::make('filament-jetstream-styles', __DIR__ . '/../resources/dist/filament-jetstream.css'),
Js::make('filament-jetstream-scripts', __DIR__ . '/../resources/dist/filament-jetstream.js'),
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Listeners/CreatePersonalTeam.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function handle(Registered $event): void

$team = Team::forceCreate([
'user_id' => $user->id,
'name' => explode(' ', $user->name, 2)[0]."'s Team",
'name' => explode(' ', $user->name, 2)[0] . "'s Team",
'personal_team' => true,
]);

Expand Down
2 changes: 1 addition & 1 deletion src/Pages/ApiTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ApiTokens extends Page

public static function shouldRegisterNavigation(): bool
{
return config('filament-jetstream.navigation_items.api_token.display');;
return config('filament-jetstream.navigation_items.api_token.display');
}

public static function getNavigationSort(): ?int
Expand Down
3 changes: 1 addition & 2 deletions src/Pages/CreateTeam.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
use Filament\Forms\Form;
use Filament\Pages\Tenancy\RegisterTenant;


class CreateTeam extends RegisterTenant
{
public static function getLabel(): string
{
return "Create Team";
return 'Create Team';
}

public function form(Form $form): Form
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/EditProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class EditProfile extends Page

public static function shouldRegisterNavigation(): bool
{
return config('filament-jetstream.navigation_items.profile.display');;
return config('filament-jetstream.navigation_items.profile.display');
}

public static function getNavigationSort(): ?int
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/EditTeam.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function getViewData(): array

public static function shouldRegisterNavigation(): bool
{
return config('filament-jetstream.navigation_items.team.display');;
return config('filament-jetstream.navigation_items.team.display');
}

public static function getNavigationSort(): ?int
Expand Down

0 comments on commit aeaa9da

Please sign in to comment.