File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 11# laravel-formrequest-singleton
22Use Laravel's excellent FormRequest as Singleton
3+
4+ ## Installation
5+
6+ * run ` composer require lextira/laravel-formrequest-singleton `
7+ * open ` config/app.php ` in your project
8+ * replace ` Illuminate\Foundation\Providers\FoundationServiceProvider::class `
9+ with ` Lextira\FormRequestSingleton\FoundationServiceProvider::class `
10+ * done!
11+
12+ ## Usage
13+
14+ All classes, which extend ` Illuminate\Foundation\Http\FormRequest ` are now instantiated as singleton.
15+
16+ This brings the following benefits:
17+ * Changes done to the request by ` prepareForValidation() ` are applied only once,
18+ even if the FormRequest is used multiple times.
19+ * The request validation is run only once, therefore especially database queries run only once.
You can’t perform that action at this time.
0 commit comments