andrewdwallo / filament-companies Goto Github PK
View Code? Open in Web Editor NEWA comprehensive Laravel authentication and authorization system designed for Filament, focusing on multi-tenant company management.
License: MIT License
A comprehensive Laravel authentication and authorization system designed for Filament, focusing on multi-tenant company management.
License: MIT License
I invited a new user to a company and when I get the email confirmation and click the "Accept Invitation" button I get this exception
BadMethodCallException PHP 8.1.1 9.47.0 Call to undefined method Illuminate\Http\RedirectResponse::banner()
when using an php artisan console command i'm now gettting this error after upgrading to version v3.2.2
Cannot assign null to property Wallo\FilamentCompanies\Http\Controllers\OAuthController::$registrationUrl of type string
at vendor/andrewdwallo/filament-companies/src/Http/Controllers/OAuthController.php:58
54▕ $this->updatesConnectedAccounts = $updatesConnectedAccounts;
55▕ $this->invalidStateHandler = $invalidStateHandler;
56▕
57▕ $this->guard = Filament::auth();
➜ 58▕ $this->registrationUrl = Filament::getRegistrationUrl();
59▕ $this->loginUrl = Filament::getLoginUrl();
60▕ $this->userPanel = FilamentCompanies::getUserPanel();
61▕ }
62▕
When i dd(Filament::getCurrentPanel()); just above $this->guard = Filament::auth(); it returns a panel which does not have filamentCompanies plugin registered / enabled.
changing this line resolves the issue:
$this->registrationUrl = Filament::getRegistrationUrl() ?? '';
Problem 1
- andrewdwallo/filament-companies[dev-main, v1.0.0, ..., 1.x-dev, v2.0.0, ..., 2.x-dev] require filament/filament ^2.16 -> found filament/filament[v2.16.0, ..., 2.x-dev] but it conflicts with your root composer.json require (^3.0-dev).
- andrewdwallo/filament-companies[dev-dependabot/github_actions/stefanzweifel/git-auto-commit-action-5, v3.0.0, ..., 3.x-dev] require illuminate/support ^10.0 -> found illuminate/support[v10.0.0, ..., 10.x-dev] but these were not loaded, likely because it conflicts with another require.
- Root composer.json requires andrewdwallo/filament-companies * -> satisfiable by andrewdwallo/filament-companies[dev-dependabot/github_actions/stefanzweifel/git-auto-commit-action-5, dev-main, v1.0.0, ..., 1.x-dev, v2.0.0, ..., 2.x-dev, v3.0.0, ..., 3.x-dev].
You can also try re-running composer require with an explicit version constraint, e.g. "composer require andrewdwallo/filament-companies:*" to figure out if any version is installable, or "composer require andrewdwallo/filament-companies:^2.1" if you know which you need.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
hi , im still new in filament . im trying to install your package but seems not working because your package just support for only version 2. am i right ?
Hello,
i where faced to this issue will i wanted to setup:
/usr/bin/php8.1/php artisan filament-companies:install filament --companies
Migration created successfully!
Copied Directory [/vendor/laravel/sanctum/database/migrations] To [/database/migrations]
Copied File [/vendor/laravel/sanctum/config/sanctum.php] To [/config/sanctum.php]
Publishing complete.
ErrorException
Undefined property: Wallo\FilamentCompanies\Console\InstallCommand::$components
at vendor/andrewdwallo/filament-companies/src/Console/InstallCommand.php:190
186▕ $this->installFilamentCompanyStack();
187▕ }
188▕
189▕ $this->line('');
➜ 190▕ $this->components->info('Filament scaffolding installed successfully.');
191▕
192▕ return true;
193▕ }
194▕
On deleting a company, the current_company_id
keeps the id of the deleted company.
I resolved adding a Middleware to change it to another company id.
if (is_null($user->currentCompany)) {
$user->current_company_id = $user->ownedCompanies()->firstOr(fn () => $user->companies()->first())->id;
$user->save();
return redirect()->intended($request->path());
}
There should be an event on deleting to check if that's the current_company_id, and if it is, it should be changed.
Hi, thanks for making this plugin!
I mainly have three panels, admin, company (url as /dashboard) and user.
So far everything seems to be working okay, however when testing adding new users to the company in company settings I have an issue with them logging in and being able to see the company or user panel.
The invitation sends fine and I can see them in pending invitations.
/dashboard/register
Missing required parameter for [Route: filament.company.pages.dashboard] [URI: dashboard/{tenant}] [Missing parameter: tenant].
Is the company ID supposed to be assigned on account creation? Or somehow the company_user
is supposed to have the user ID associated to Company ID? I've reviewed again the setup guide however could have overlooked something simple.
For example instead of /companies/1 we could have a like teams or ogranization - would be helpful :)
After a clearly fresh Laravel, Filament install, saving Company Name, error will be shown:
Livewire \ Exceptions
ComponentNotFoundException
PHP 8.2.13
Laravel 10.34.2
Unable to find component: [wallo.filament-companies.http.livewire.update-company-name-form]
Same behaviour on saving user to company:
Unable to find component: [wallo.filament-companies.http.livewire.company-employee-manager]
@andrewdwallo Currently I am presenting an error with the tenancy part, when installing I am requiring that the pages and resources be reflected in the company module and from there manage the roles, permissions and authorizations part but when using php artisan make : filament-page or php artisan make:filament-resource allows me to choose the creation route (admin or company) when choosing company it reflects the module in the panel but when I enter it I get that the route "Route [filament.admin. tenant .profile] not defined. ", the same thing happens when installing the filament-shield plugin, which is what I use to handle the authorization issue.
Description:
When modifying the panel ID in the FilamentCompaniesServiceProvider
, a route-related exception occurs upon accessing the user profile. The issue stems from the hard-coded route reference in the resources/views/profile/connected-accounts-from.blade.php
file (line 50), specifically pointing to filament.company.oauth.redirect
.
Reproduction Steps:
Navigate to FilamentCompaniesServiceProvider
.
Modify the panel ID within the panel method.
public function panel(Panel $panel): Panel
{
return $panel
->id('custom')
->path('custom')
->homeUrl(static fn (): string => url(Pages\Dashboard::getUrl(panel: 'custom', tenant: Auth::user()?->personalCompany())))
// ... other configurations
}
Expected Behavior:
Routes in routes/web.php
are dynamically generated based on the panel ID. Therefore, the correct route in this case should be filament.custom.oauth.redirect
instead of the hard-coded filament.company.oauth.redirect
in connected-accounts-from.blade.php
.
File Reference:
Affected File: resources/views/profile/connected-accounts-from.blade.php
Line Number: 50
Proposed Solution:
Update the route reference in connected-accounts-from.blade.php
to use the dynamically generated route based on the panel ID, i.e., filament.custom.oauth.redirect
.
Hey,
I start migrating this package thought v3, still not finish but i'm in progress,
did you start something or not yet ?
Hi, thanks for this plugin!
After a clearly fresh Laravel, Filament install got this error:
Route [filament.admin.pages.profile] not defined.
It causes by /app/Providers/FilamentCompaniesServiceProvider.php
This part from line 92:
->userMenuItems([ 'profile' => MenuItem::make() ->label('Profile') ->icon('heroicon-o-user-circle') ->url(static fn () => route(Profile::getRouteName(panel: 'admin'))), ])
Right now, only default providers are supported, but there are a lot of providers at https://socialiteproviders.com, and you can also implement a custom provider. Is there any way to support other or custom providers? It seems coupled to the Provider
enum that can't be extended.
in web.php of filament-companies the prefix is composed of $panel->getPath(), but when you haven't specified a domain in tenancy of filament serviceprovider the generated route name is incorrect.
the official filament web.php does something like this:
$tenantRoutePrefix = $panel->getTenantRoutePrefix();
$tenantSlugAttribute = $panel->getTenantSlugAttribute();
Route::domain($domain)
->middleware($hasTenancy ? $panel->getMiddleware() : [])
->name("{$panelId}.")
->prefix($hasTenancy ? (($tenantRoutePrefix) ? "{$tenantRoutePrefix}/" : '') . ('{tenant' . (($tenantSlugAttribute) ? ":{$tenantSlugAttribute}" : '') . '}') : '')
->group(static function () use ($plugin, $hasTenancy, $tenantRoutePrefix, $tenantSlugAttribute) {
instead of in filament-companies web.php package file:
Route::domain($domain)
->middleware($panel->getMiddleware())
->name("{$panelId}.")
->prefix($panel->getPath())
->group(static function () use ($plugin, $hasTenancy) {
if you want to use it on multiple panels this should be changed...
Route::domain($domain)
->middleware($panel->getMiddleware())
->name("{$panelId}.")
->prefix($panel->getPath() . '/' . ($hasTenancy ? (($tenantRoutePrefix) ? "{$tenantRoutePrefix}/" : '') . ('{tenant' . (($tenantSlugAttribute) ? ":{$tenantSlugAttribute}" : '') . '}') : ''))
->group(static function () use ($plugin, $hasTenancy, $tenantRoutePrefix, $tenantSlugAttribute) {
@andrewdwallo
For command: php artisan filament-companies:install. I used the Base Package.
The error I'm facing after running migration command is:
BadMethodCallException
Method Filament\Panel::getDomains does not exist.
at vendor\filament\support\src\Concerns\Macroable.php:72
68▕ {
69▕ $macro = static::getMacro($method);
70▕
71▕ if ($macro === null) {
➜ 72▕ throw new BadMethodCallException(sprintf(
73▕ 'Method %s::%s does not exist.',
74▕ static::class,
75▕ $method,
76▕ ));
i Bad Method Call: Did you mean Filament\Panel::getDomain() ?
1 vendor\andrewdwallo\filament-companies\routes\web.php:22
Filament\Support\Components\Component::__call("getDomains", [])
2 vendor\laravel\framework\src\Illuminate\Routing\Router.php:502
Illuminate\Support\ServiceProvider::{closure}(Object(Illuminate\Routing\Router))
Thanks for your awesome plugin!
I have one minor issue:
When I register a new user I get redirected to the /company/{id}/profile page, which does not exist. When I try to go to the dashboard, I get an error saying Missing required parameter for [Route: filament.company.pages.dashboard] [URI: company/{tenant}] [Missing parameter: tenant].
This error gets thrown because the newly created user is not linked to a company yet. How do I create a new company when a new user is registered?
Thanks in advance!
Thanks for the great package.
I am getting the below error on registering a new company from the browser. It is a fresh installation on a local dev environment and I followed the installation instructions on the filament PHP website.
The error is:
Missing required parameter for [Route: filament.company.pages.dashboard] [URI: company/{tenant}] [Missing parameter: tenant].
Hello,
i freshly installed the lastest version of fillament and laravel
i setup fillament companies, but i got some issue with my first user
as i read on the previous issue it should be redirect to a page to create the company, but is not case for me
this is my app/Providers/Filament/AdminPanelProvider.php
use Filament\PanelProvider;
use Filament\Support\Colors\Color;
use Filament\Widgets;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Session\Middleware\AuthenticateSession;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\View\Middleware\ShareErrorsFromSession;
use Filament\Navigation\MenuItem;
use Filament\Navigation\NavigationItem;
use Illuminate\Support\Facades\Auth;
use Wallo\FilamentCompanies\Pages\User\PersonalAccessTokens;
use Wallo\FilamentCompanies\Pages\User\Profile;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
->login()
->colors([
'primary' => Color::Amber,
])
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
->pages([
Pages\Dashboard::class,
Profile::class,
PersonalAccessTokens::class,
])
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
->widgets([
Widgets\AccountWidget::class,
Widgets\FilamentInfoWidget::class,
])
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
])
->authMiddleware([
Authenticate::class,
])
->viteTheme('resources/css/filament/company/theme.css')
->userMenuItems([
'profile' => MenuItem::make()
->label('Profile')
->icon('heroicon-o-user-circle')
->url(static fn () => url(Profile::getUrl())),
MenuItem::make()
->label('Company')
->icon('heroicon-o-building-office')
->url(static fn () => url(Pages\Dashboard::getUrl(panel: 'company', tenant: Auth::user()->personalCompany()))),
])
->navigationItems([
NavigationItem::make('Personal Access Tokens')
->label(static fn (): string => __('filament-companies::default.navigation.links.tokens'))
->icon('heroicon-o-key')
->url(static fn () => url(PersonalAccessTokens::getUrl())),
])
;
}
}
I think i correctly setup, but i didn't see what i miss.
Hello,
maybe i didnt see that but how can i add roles / permissions?
Hello Guys,
I check the documentation but i didn't found any explaination for how to add new fields into the add/edit page of the company ?
Best
How do I auto create a Company when a User Joins? Currently I am redirected to the form to add a Company name, but I see in CreateNewUser
that a new Company should be auto created with $this->createCompany($user)
-- is there additional setup required for this fire?
In my FilamentCompaniesServiceProvider
I do have FilamentCompanies::createUsersUsing(CreateNewUser::class);
but adding a Log there seems as if it isnt being used
HI,
on a fresh laravel/filament/filament-companies installation I'm getting this error by running php artisan route:clear
Unable to prepare route [admin/create] for serialization. Another route has already been assigned name [filament.pages.create].
After some debugging I figured out this conflict depends on duplicate pages that exists in filament-companies package and my project after running php artisan filament-companies:install filament --companies
There is a TypeError in the redirectToWithError() method of the Wallo\FilamentCompanies\Http\Controllers\OAuthController class, where the $message
argument must be of type string
but is being passed as null
.
This occurs with Google OAuth when the user denies permissions. Here are more details from Sentry:
URL: /company/oauth/google/callback
Query strings:
error: access_denied
state: xxxxxxxx
From the logs:
TypeError: Wallo\FilamentCompanies\Http\Controllers\OAuthController::redirectToWithError(): Argument #1 ($message) must be of type string, null given, called in /home/remotedxb-web/www.remotedxb.com/vendor/andrewdwallo/filament-companies/src/Http/Controllers/OAuthController.php on line 148
Hi,
Feature request, would be nice if the URL was the company name (slugged) rather than the ID:
/1/profile
-> /acme-corp/profile
Using the ID way reveals to the user how many companies exist, which isn't the greatest.
I am making a clean setup and I get this error after entering http://localhost:8000/company/1
Route [filament.company.tenant.profile] not defined.
i am make new panel "company"
and added
->userMenuItems([
'profile' => MenuItem::make()
->label('Profile')
->icon('heroicon-o-user-circle')
->url(static fn () => url(Profile::getUrl())),
MenuItem::make()
->label('Company')
->icon('heroicon-o-building-office')
->url(static fn () => url(Pages\Dashboard::getUrl(panel: 'company', tenant: Auth::user()->personalCompany()))),
])
->navigationItems([
NavigationItem::make('Personal Access Tokens')
->label(static fn (): string => __('filament-companies::default.navigation.links.tokens'))
->icon('heroicon-o-key')
->url(static fn () => url(PersonalAccessTokens::getUrl())),
])
and in "FilamentCompaniesServiceProvider"
change panel name to company
why next step "Route [filament.company.pages.profile] not defined." why?
A middleware to redirect users to create a company would be appreciated.
Example:
class HasCompany
{
const PATH = 'admin/companies/create';
public function handle(Request $request, Closure $next)
{
/** @var User */
$user = auth()->user();
if (
!$user->ownedCompanies()->exists() &&
!$user->companies()->exists() &&
!$request->is(self::PATH)
) {
return redirect(self::PATH);
}
return $next($request);
}
}
Hi !
You've made a very nice piece of work here ! Good job 👍
There is only one little thing I can't make to work : I'm unable to login with Socialite.
I'm successfully beeing redirected to /oauth/callback, finishing with a correct auth()->user().
Still, I'm redirected to the login page. Like if the session wasn't correctly set.
Reproductible on a stock install, eather with Github and Google providers.
I'll keep you updated whn I find a solution.
Vincent
Hello,
With a fresh install of Laravel (v11), everything is looking well, but the artisan command for creating a user is not showing up.
Maybe there is a quick fix?
Gr.
Virgil
should be $this->user->hasVerifiedEmail()
?
Hi,
I am wondering if it is possible to change the word company to Event
, Team
, etc..
So it would be like:
Create New Event
Switch Event
I tried extending the the CreateCompany
class
->tenantRegistration(CustomCreateCompany::class)
FilamentCompanies::createCompaniesUsing(CustomCreateCompany::class);
class CustomCreateCompany extends CreateCompany
{
public static function getLabel(): string
{
return __('Create Organization');
}
public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
->label(__('Organization Name'))
->autofocus()
->maxLength(255)
->required(),
])
->model(FilamentCompanies::companyModel())
->statePath('data');
}
}
And when submitting the form I get this error:
Unable to find component: [app.services.company.custom-create-company]
Hi,
I am getting the current company name null problem after the first registration.
Attempt to read property "name" on null
resources/ views / navigation-menu.blade.php:9
<div class="flex justify-end">
@if (Wallo\FilamentCompanies\FilamentCompanies::hasCompanyFeatures())
<x-filament::dropdown placement="bottom-end">
<x-slot name="trigger" class="ml-4">
<button @class([
'inline-flex items-center px-3 py-2 border border-transparent text-sm text-gray-800 hover:text-primary-500 leading-4 font-medium rounded-md bg-white hover:bg-gray-50 focus:outline-none focus:bg-gray-50 active:bg-gray-50 transition
'dark:bg-gray-800 dark:hover:bg-gray-700 dark:border-white dark:hover:border-primary-400 dark:text-white dark:hover:text-primary-400' => config('filament.dark_mode'),
])>
**{{ Auth::user()->currentCompany->name }}**
<svg class="ml-2 -mr-0.5 h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" />
</svg>
</button>
</x-slot>
When adding a user in the settings and having a custom panel ID the user is added but an exception is thrown when trying to send an email: Mail::to($email)->send(new CompanyInvitation($invitation));
.
Could be related to: #105
FilamentCompaniesServiceProvider
.public function panel(Panel $panel): Panel
{
return $panel
->id('custom')
->path('custom')
->homeUrl(static fn (): string => url(Pages\Dashboard::getUrl(panel: 'custom', tenant: Auth::user()?->personalCompany())))
// ... other configurations
}
The user is invited and email is sent.
I think it's a bug? Occurs when attempting to update the user name.
Wallo\FilamentCompanies\Http\Livewire\UpdateProfileInformationForm::updateProfileInformation(): Return value must be of type Livewire\Redirector|Illuminate\Http\RedirectResponse, none returned
https://github.com/andrewdwallo/filament-companies/blob/1.x/src/Http/Livewire/UpdateProfileInformationForm.php#L58-L80
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.