nowendwell / laravel-terms
A tool for adding terms and conditions to your project
Installs: 14 010
Dependents: 0
Suggesters: 0
Security: 0
Stars: 23
Watchers: 2
Forks: 8
Open Issues: 4
Requires
- php: ^7.4|^8.0|^8.1
- illuminate/support: 7.*|8.*|9.*|10.*|11.*
- spatie/laravel-package-tools: ^1.0
Requires (Dev)
- orchestra/testbench: ^5.0|^6.0|^7.0|^8.0
- phpunit/phpunit: ^7.0|^8.0|^9.0|^10.0
README
Keep users up to date with your terms and conditions changes. This package provides middleware to intercept requests and redirect to the latest terms.
Installation
You can install the package via composer:
composer require nowendwell/laravel-terms
php artisan vendor:publish --provider="Nowendwell\LaravelTerms\LaravelTermsServiceProvider"
php artisan migrate
Usage
Add the AcceptsTerms trait to your user model and you're good to go!
<?php use Nowendwell\LaravelTerms\Traits\AcceptsTerms; class User { use AcceptsTerms; }
Middleware
This package comes with middleware pre-configured for the happy path. It is up to you how your app should determine who needs to go through the middleware check. Below is an example of a User who requires Terms.
<?php namespace App\Http\Middleware; use Closure; use Illuminate\Http\Request; class AcceptedTerms { public function handle(Request $request, Closure $next) { if ( auth()->check() && ! auth()->user()->hasAcceptedTerms() && ! in_array($request->path(), config('terms.excluded_paths')) ) { session(['url.intended' => $request->url()]); return redirect()->route('terms.show'); } return $next($request); } }
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email nowendwell@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.