Coder Social home page Coder Social logo

andrewdwallo / filament-companies Goto Github PK

View Code? Open in Web Editor NEW
202.0 5.0 50.0 781 KB

A comprehensive Laravel authentication and authorization system designed for Filament, focusing on multi-tenant company management.

License: MIT License

PHP 85.73% Blade 14.27%
authentication authorization filament laravel management multitenancy socialite

filament-companies's Introduction

Andrew's GitHub stats-Dark Andrew's GitHub stats-Light

filament-companies's People

Contributors

andrewdwallo avatar ciebrant avatar corean avatar dependabot[bot] avatar grafst avatar margarizaldi avatar maxime9446 avatar mstfkhazaal avatar pawooo avatar realslimsutton avatar riclep avatar rjbh1971 avatar thecrazybob avatar vincentlahaye avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

filament-companies's Issues

Error thrown: Route [filament.company.oauth.redirect] not defined when changing company panel ID

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:

  1. Navigate to FilamentCompaniesServiceProvider.

  2. 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
}
  1. Attempt to access the user profile.

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.

Company Settings

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]

`currentCompany` null on deletion of previous company

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.

Cannot assign null to property Wallo\FilamentCompanies\Http\Controllers\OAuthController::$registrationUrl of type string

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() ?? '';

Additional fields ?

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

Navigation error on user with zero companies (Attempt to read property "name" on null)

image
image

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);
    }
}

Undefined property: Wallo\FilamentCompanies\Console\InstallCommand::$components

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▕

Dynamically change the word Company?

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
  • and so on

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]

Duplicate named routes after scaffold generation

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

userMenuItems

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'))), ])

Adding users to company

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.

  • The invitation email links to /dashboard/register
  • After the invited user has made an account there is an error, it will try to redirect to dashboard/new
  • Missing required parameter for [Route: filament.company.pages.dashboard] [URI: dashboard/{tenant}] [Missing parameter: tenant].
  • From what I can see the "tenant" is null, and is trying to make a new company.
  • Ideally they would not create a new company, and instead be directed to the company dashboard they were invited to.

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.

cant install package

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 ?

does not work correctly inconjuction with Filament v3 tenancy enabled

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) {

Current company name problem after the first registration

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>

Ability to change naming

For example instead of /companies/1 we could have a like teams or ogranization - would be helpful :)

Migration v3

Hey,

I start migrating this package thought v3, still not finish but i'm in progress,

did you start something or not yet ?

Error on creating new company from the browser.

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].

image

Error thrown: Route [filament.wedding.wedding-invitations.accept] not defined when adding user with custom panel ID

Description:

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

Reproduction Steps:

  1. Navigate to FilamentCompaniesServiceProvider.
  2. Modify the panel ID
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
}
  1. Navigate to settings and attempt to invite new user

Expected Behavior:

The user is invited and email is sent.

Additional Roles?

Hello,

maybe i didnt see that but how can i add roles / permissions?

Cannot login with socialite

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

Method Filament\Panel::getDomains does not exist.

@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))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.