PHP code example of stats4sd / filament-team-management
1. Go to this page and download the library: Download stats4sd/filament-team-management library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
stats4sd / filament-team-management example snippets
namespace App\Models;
use Stats4sd\FilamentTeamManagement\Models\Team as BaseTeam;
class Team extends BaseTeam
{
// Add your customizations and overrides here
}
return $panel
...
// Make sure this is the default panel
->default()
// Add the authentication pages from the package
->login(Stats4sd\FilamentTeamManagement\Filament\Auth\Login::class)
->registration(Stats4sd\FilamentTeamManagement\Filament\Auth\Register::class)
// Add multitenancy (using your 'team' model) and the profile + registration pages
->tenant(App\Models\Team::class) // your team model
->tenantProfile(Stats4sd\FilamentTeamManagement\Filament\App\Pages\ManageTeam\ManageTeam::class)
->tenantRegistration(Stats4sd\FilamentTeamManagement\Filament\App\Pages\RegisterTeam::class)
// Add the resources and pages from the App namespace
->discoverPages(
in: base_path('vendor/stats4sd/filament-team-management/src/Filament/App/Pages'),
for: 'Stats4sd\FilamentTeamManagement\Filament\App\Pages'
)
// optionally, add a link to the admin panel
->navigationItems([
NavigationItem::make('admin')
->url('/admin')
->label('Admin Panel')
->icon('heroicon-o-cog')
->visible(fn () => auth()->user()->can('viewAdminPanel')),
]);
namespace App\Filament\Pages\ManageTeam;
use Stats4sd\FilamentTeamManagement\Filament\App\Pages\ManageTeam\ManageTeam as BaseManageTeam;
class ManageTeam extends BaseManageTeam
{
// Add your customizations and overrides here
}
return $panel
...
// Add multitenancy (using your 'program' model)
->tenant(App\Models\Program::class) // your program model
->tenantProfile(Stats4sd\FilamentTeamManagement\Filament\Program\Pages\ManageProgram\ManageProgram::class)
->tenantRegistration(Stats4sd\FilamentTeamManagement\Filament\Program\Pages\RegisterProgram::class)
// Add the resources and pages from the Program namespace
->discoverPages(
in: base_path('vendor/stats4sd/filament-team-management/src/Filament/Program/Pages'),
for: 'Stats4sd\FilamentTeamManagement\Filament\Program\Pages'
)
// the package assumes that all users will register and log in via the 'App' (default) panel, so this panel should not have a `login()` or `registration()` method. To ensure users are redirected to the correct login page, add _replace_ the `Authenticate::class` in authMiddleware with the following:
->authMiddleware([
\Stats4sd\FilamentTeamManagement\Http\Middleware\AuthenticateThroughDefaultPanel::class,
])
// optionally, add links to the other panels
->navigationItems([
NavigationItem::make('admin')
->url('/admin')
->label('Admin Panel')
->icon('heroicon-o-cog')
->visible(fn() => auth()->user()->can('viewAdminPanel')),
NavigationItem::make('app')
->url('/')
->icon('heroicon-o-arrow-left')
->label('Back to Front End'),
]);
return $panel
...
// Add the resources and pages from the Admin namespace
->discoverPages(
in: base_path('vendor/stats4sd/filament-team-management/src/Filament/Admin/Pages'),
for: 'Stats4sd\FilamentTeamManagement\Filament\Admin\Pages'
)
->discoverResources(
in: base_path('vendor/stats4sd/filament-team-management/src/Filament/Admin/Resources'),
for: 'Stats4sd\FilamentTeamManagement\Filament\Admin\Resources'
)
// the package assumes that all users will register and log in via the 'App' (default) panel, so this panel should not have a `login()` or `registration()` method. To ensure users are redirected to the correct login page, add _replace_ the `Authenticate::class` in authMiddleware with the following:
->authMiddleware([
\Stats4sd\FilamentTeamManagement\Http\Middleware\AuthenticateThroughDefaultPanel::class,
])
// optionally, add links to the other panels
->navigationItems([
NavigationItem::make('program')
->url('/program')
->label('Go to program panel')
->icon('heroicon-o-cog')
->visible(fn() => auth()->user()->can('viewAdminPanel')),
NavigationItem::make('app')
->url('/')
->icon('heroicon-o-arrow-left')
->label('Back to Front End'),
]);
bash
php artisan filament-team-management:install
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.