- About
- Services
- Experiences
- Blog
- Portfolio
- Contact
Filament Terms Guard Plugin
Get PluginContents
- Documentation
- Key Features
- Usage
- Installation
- Settings
- Usage
- Authorization
- Tips
- Changelog
- Security Vulnerabilities / Support
- License Options
- Screenshots
- Credits
Documentation
This plugin provides a comprehensive solution for managing the terms and conditions on your panels.
With this plugin, you can easily create, update, publish, and duplicate terms and conditions, ensuring your users are always up-to-date with the latest policies.
This plugin is also compatible with multi-tenant panels and multi auth guards.
Key Features
- Create Terms and Conditions: Effortlessly draft new terms and conditions using the intuitive interface.
- Publish Terms and Conditions: Seamlessly publish the newly created Terms and Conditions to keep your users informed.
- Duplicate Terms and Conditions: Easily duplicate existing terms and conditions to be updating and publishing.
- User Redirection: If the plugin is activated on a panel and a new Terms and Conditions is published for this one, all users connected to this panel will be redirected to a validation page for the new terms.
Usage
- Navigate to the Terms and Conditions management section in your admin panel.
- Create a new Terms and Conditions or duplicate an existing one for one selected panel.
- Publish the Terms and Conditions to make it live.
- Upon publishing a new Terms and Conditions, connected users will be redirected to validate the updated terms and conditions od used / services.
- This plugin ensures that all users agree to the most recent terms and conditions od used / services, maintaining compliance and clarity for your site's policies.
Installation
Before use composer
to install this package you need to add this package to your composer.json
file :
{
"repositories": [
{
"type": "composer",
"url": "https://filament-terms-guard.composer.sh"
}
],
}
Once the repository has been added to your composer.json
file, you can install this package via composer require
command:
composer require yebor974/filament-terms-guard
You will be prompted to provide your username and password:
Loading composer repositories with package information
Authentication required (filament-terms-guard.composer.sh):
Username: [licensee-email]
Password: [license-key]
The username will be your email address and the password will be equal to your license key, followed by a colon (:), followed by the domain you are activating. For example:
Loading composer repositories with package information
Authentication required (filament-terms-guard.composer.sh):
Username: your_email@domain.tld
Password: 8c21df8f-6273-4932-b4ba-8bcc723ef500:domain.tld
Settings
You can publish and run the migrations with:
php artisan vendor:publish --tag="filament-terms-guard-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="filament-terms-guard-config"
Optionally, you can publish translations files with:
php artisan vendor:publish --tag="filament-terms-guard-translations"
Optionally, you can publish the views using
php artisan vendor:publish --tag="filament-terms-guard-views"
Next, define in your .env
file, which panels need to include user consents with key TERMS_GUARD_PANELS separated by coma:
For panels with id 'admin' and 'customer', you have to declare this line:
TERMS_GUARD_PANELS=admin,customer
If your panel id is not in this config, no consent is asked to users. So, you can disable consent by remove your id panel here.
Usage
- Register plugin on your(s) panel(s) :
On panel where you want user consents of new terms and conditions :
use Yebor974\FilamentTermsGuard\TermsGuardPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
TermsGuardPlugin::make()
])
}
On panel where you want to manage terms and conditions too :
use Yebor974\FilamentTermsGuard\TermsGuardPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
TermsGuardPlugin::make()
->termsResource()
])
}
- Implement the
TermsGuardContract
on your Authentication Model (User by default) and implements methods.
use Illuminate\Foundation\Auth\User as Authenticatable;
use Yebor974\FilamentTermsGuard\Contracts\TermsGuardContract;
class User extends Authenticatable implements TermsGuardContract
{
...
}
You can use default HasTermsGuard
trait on your Authentication Model;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Yebor974\FilamentTermsGuard\Contracts\TermsGuardContract;
use Yebor974\FilamentTermsGuard\Traits\HasTermsGuard;
class User extends Authenticatable implements TermsGuardContract
{
use HasTermsGuard;
}
Or you can define your own criteria for prompting consent form in the needAcceptNewTerms
function:
On this case, you need to implement the terms function too.
use Illuminate\Foundation\Auth\User as Authenticatable;
use Yebor974\FilamentTermsGuard\Contracts\TermsGuardContract;
use Yebor974\FilamentTermsGuard\Traits\HasTermsGuard;
class User extends Authenticatable implements TermsGuardContract
{
public function terms(): MorphToMany
{
return $this->morphToMany(Term::class, 'model', TermConsent::class)
->withTimestamps();
}
public function needAcceptNewTerms(): bool
{
$panel ??= Filament::getCurrentPanel();
$currentTerm = Term::getCurrentTerm($panel->getId());
return $currentTerm && !$this->terms()->find($currentTerm);
}
}
Authorization
To secure access for your TermResource backend, you can create a policy TermPolicy.php
.
For help, you have a stub file with default policy that can be customized.
Next, it's recommended explicitly register it in AuthServiceProvider.php
file:
use App\Policies\TermPolicy;
use Yebor974\FilamentTermsGuard\Models\Term;
protected $policies = [
Term::class => TermPolicy::class,
];
Tips
You can translate you panel id values for select inputs and labels with the translations file of plugin.
After publish translations files, you can define them in panels
array :
'panels' => [
'admin' => 'Admin Panel',
'super-admin' => 'Super Admin Panel',
],
If you dont want group navigation for your TermResource you can put it translation to empty string like this:
'terms' => [
[...]
'navigation' => [
'group' => '',
[...]
]
]
You can retrieve the current active terms and conditions for a panel.
use Filament\Facades\Filament;
use Yebor974\FilamentTermsGuard\Models\Term;
$panel ??= Filament::getCurrentPanel();
$currentTerm = Term::getCurrentTerm($panel->getId());
If panel id is not registered on
.env
file, null is return.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities / Support
If you discover any security related issues or need support, please email me at contact@julienboyer.re
License Options
We offer three types of licenses for our plugin:
- Annual Single Project License: Access to all features, updates, and support for one year, activatable on three environments (local, staging, production).
- Annual Unlimited Projects License: Access to all features, updates, and support for one year, with unlimited environment activations.
- Lifetime Unlimited Projects License: Lifetime access to all features, updates, and support, with unlimited environment activations.
For detailed terms and conditions, please see License Options.
Screenshots
-
User consent view for new terms and conditions:
-
Form to create new terms and conditions:
-
Listing of all terms and conditions:
-
View of a terms and conditions and associated consents:
Credits
associated posts
Other plugins
To contact me
If you have an idea to bring to life, a problem to solve, or a significant technical challenge to tackle, don't waste any more time. Contact me now and let me help you turn your ambitions into reality. My expertise is at your disposal to successfully materialize your projects.
My mail
Geographic location
Paris & Reunion Island (France - UTC+4)