Download the PHP package eugenefvdm/multi-tenancy-pwa without Composer
On this page you can find all versions of the php package eugenefvdm/multi-tenancy-pwa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download eugenefvdm/multi-tenancy-pwa
More information about eugenefvdm/multi-tenancy-pwa
Files in eugenefvdm/multi-tenancy-pwa
Package multi-tenancy-pwa
Short Description A Laravel package for Filament multi-tenancy & PWA
License MIT
Informations about the package multi-tenancy-pwa
Multi-tenancy PWA
A very opinionated setup script for Laravel and Filament PHP to quickly bootstrap a modern multi-tenant aware back office application.
It has PWA features for app installation and web push notifications.
It includes Google Socialite login (compliments of Povilas: https://laraveldaily.com/post/filament-sign-in-with-google-using-laravel-socialite)
General Features
- Works with Filament 4 for rapid application development
- Includes a
HasTenantRelationshiptrait that may be used to make models tenant aware - There is ocial login using Google making signing up of new users a breeze
PWA (Progressive App Features)
- An App installation button
- Web Push notifications
- PWA Diagnostics Screen
Prerequisites
- FilamentPHP version 4.x must be installed
Packages used
The following are presumed to be used and already included in composer:
- Laravel Socialite
- Spatie Eloquent Sortable
- Web push from Laravel Notification Channels
Installation
If Filament 4.x is still in beta:
If you're going to be sorting Filament resources any time soon
Setup
Spatie orderable column name
In config/eloquent-sortable.php, change order_column_name from order_colulmn to sort.
If you're using this in your code you'll need both Sortable and SortableTrait.
Database migrations for Tenancy
Every tenant aware table in your application should have this line:
To keep things tidy I like putting them after the main ID column.
Tenant Model
You'll need the base tenant model:
Model Trait
Add the following trait to your tenant aware models (but not to Tenant.php):
Filament Panel Service Provider
ApplyTenantScopes Middleware
Let's say you have todo and category tables and you want them to automatically get tenant_id. Use this middleware:
The security of your application is your responsbility. Be sure to read this part of the manual: https://filamentphp.com/docs/4.x/users/tenancy#tenancy-security
To automatically assign your tenant id column to every record creation and list view, add Tenant
Next, continue the Filament installation:
Open AdminPanelProvider.php and add this to the end, below the authMiddleware section:
Web Push Notifications
Composer will already be updated with laravel-notification-channels/webpush.
Add the config file:
Example notification:
Database notifications
Laravel 11 and higher:
User Model
Now you can migrate the database
Add Google oAuth credentials
First see: https://fwd.host/ Redirects to: https://herd.laravel.com/docs/macos/advanced-usage/social-auth
Then go to: https://console.cloud.google.com/apis/credentials?pli=1
At Google's URL above, carefully copy out your CLIENT_ID and CLIENT_SECRET top right.
Note: The callback route from Google needs to be wrapped in web for auth()->login to work.
For web push
See: https://laravel-news.com/fwd-host
Logging in
Sign up for a new account:
https://app.test/admin/register
Tenancy tips
Excluding resources from tenancy
As per the manual, you can exclude Filament resources from Tenancy by doing this:
Web push errors
You can simulate this error on the command line on a Mac
But this works:
Socialite Errors
Incorrect Client Secret
Client error: POST https://www.googleapis.com/oauth2/v4/token resulted in a 400 Bad Request response: { "error": "invalid_request", "error_description": "Missing required parameter: code" }
The Client secret is incorrect. It's the bottom value on Google's site.
PWA Images
If you have an SVG, you can resize it here: See: https://pwagenerator.test/
Application Icon Name on Android
short_name in manifest.json
All versions of multi-tenancy-pwa with dependencies
spatie/laravel-ray Version ^1.40
laravel/socialite Version ^5.21
spatie/eloquent-sortable Version ^4.5
laravel-notification-channels/webpush Version ^10.2