File tree 2 files changed +46
-0
lines changed
2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,23 @@ php artisan make:doctrine:mapping MyValue --value
108
108
109
109
By default, this will create a new file in ` app/Database/Doctrine/Mappings/Values/ ` called ` MyValueMapping.php ` .
110
110
111
+ ### FlushEntityManager Middleware
112
+
113
+ Simplify the process of actually persisting your entities to the database using the included middleware.
114
+
115
+ Add the middleware to your ` app/Http/Kernel.php ` file like so:
116
+ ``` php
117
+ class Kernel extends HttpKernel
118
+ {
119
+ // ...
120
+
121
+ protected $middleware = [
122
+ // ...
123
+ \Zain\LaravelDoctrine\Jetpack\Middleware\FlushEntityManager::class,
124
+ ];
125
+ }
126
+ ```
127
+
111
128
### Helpers
112
129
113
130
#### Entity Serialization
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types=1 );
2
+
3
+ namespace Zain \LaravelDoctrine \Jetpack \Middleware ;
4
+
5
+ use Closure ;
6
+ use Doctrine \ORM \EntityManagerInterface as EntityManager ;
7
+ use Illuminate \Http \Request ;
8
+
9
+ class FlushEntityManager
10
+ {
11
+ private EntityManager $ em ;
12
+
13
+ public function __construct (EntityManager $ em )
14
+ {
15
+ $ this ->em = $ em ;
16
+ }
17
+
18
+ /**
19
+ * @return mixed
20
+ */
21
+ public function handle (Request $ request , Closure $ next )
22
+ {
23
+ $ response = $ next ($ request );
24
+
25
+ $ this ->em ->flush ();
26
+
27
+ return $ response ;
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments