@@ -19,7 +19,6 @@ composer require dentro/laravel-patcher
19
19
``` json
20
20
{
21
21
"require" : {
22
- ...
23
22
"dentro/laravel-patcher" : " ^1.0"
24
23
}
25
24
}
@@ -43,16 +42,10 @@ Those file will be like:
43
42
``` php
44
43
<?php
45
44
46
- use Jalameta \Patcher\Patch;
45
+ use Dentro \Patcher\Patch;
47
46
48
47
class WhatDoYouWantToPatch extends Patch
49
48
{
50
- /**
51
- * Run patch script.
52
- *
53
- * @return void
54
- * @throws \Exception
55
- */
56
49
public function patch()
57
50
{
58
51
//
@@ -116,3 +109,37 @@ Patching: 2020_10_09_124616_add_attachment_beep
116
109
Patched: 2020_10_09_124616_add_attachment_beep (0.06 seconds)
117
110
```
118
111
112
+ #### SKIPPING THE PATCH
113
+ You might need to skip single patch when run ``` php artisan patcher:run ``` .
114
+ Due to patch is unnecessary or patch is not eligible to run in your environment.
115
+ Here you can add the ``` eligible ``` method to your patch class to evaluate the condition
116
+ before running the ``` patch ``` method.
117
+
118
+ ``` php
119
+ <?php
120
+
121
+ use Dentro\Patcher\Patch;
122
+ use App\Models\User;
123
+
124
+ class WhatDoYouWantToPatch extends Patch
125
+ {
126
+ public function eligible(): bool
127
+ {
128
+ return User::query()->where('id', 331)->exists();
129
+ }
130
+
131
+ public function patch()
132
+ {
133
+ $user = User::query()->find(331);
134
+ // do something with user.
135
+ }
136
+ }
137
+ ```
138
+ then the output of ``` php artisan patcher:run ``` will be:
139
+ ``` shell script
140
+ ➜ php artisan patcher:run
141
+ Patching: 2020_09_29_190531_fix_double_sections
142
+ Skipped: 2020_09_29_190531_fix_double_sections is not eligible to run in current condition.
143
+ Patching: 2020_10_09_124616_add_attachment_beep
144
+ Patched: 2020_10_09_124616_add_attachment_beep (0.06 seconds)
145
+ ```
0 commit comments