@@ -10,12 +10,48 @@ function! g:projectionist_transformations.namespace(input, o) abort
1010endfunction
1111
1212function ! laravel#projectionist#append () abort
13+ let templates = {
14+ \ ' generic' : [
15+ \ ' <?php' ,
16+ \ ],
17+ \ ' array' : [
18+ \ ' <?php' ,
19+ \ ' ' ,
20+ \ ' return [' ,
21+ \ ' //' ,
22+ \ ' ];' ,
23+ \ ],
24+ \ ' class' : [
25+ \ ' <?php' ,
26+ \ ' ' ,
27+ \ ' namespace {namespace};' ,
28+ \ ' ' ,
29+ \ ' class {basename}' ,
30+ \ ' {open}' ,
31+ \ ' //' ,
32+ \ ' {close}' ,
33+ \ ],
34+ \ ' trait' : [
35+ \ ' <?php' ,
36+ \ ' ' ,
37+ \ ' namespace {namespace};' ,
38+ \ ' ' ,
39+ \ ' trait {basename}' ,
40+ \ ' {open}' ,
41+ \ ' //' ,
42+ \ ' {close}' ,
43+ \ ],
44+ \ }
45+
1346 let projections = {
1447 \ ' *' : {
1548 \ ' start' : ' homestead ssh' ,
1649 \ ' console' : [laravel#app ().makeprg (), ' tinker' ],
1750 \ ' framework' : ' laravel' ,
1851 \ },
52+ \ ' *.php' : {
53+ \ ' template' : templates.generic,
54+ \ },
1955 \ ' bootstrap/*.php' : {
2056 \ ' type' : ' bootstrap' ,
2157 \ },
@@ -24,94 +60,32 @@ function! laravel#projectionist#append() abort
2460 \ },
2561 \ ' config/*.php' : {
2662 \ ' type' : ' config' ,
27- \ ' template' : [
28- \ ' <?php' ,
29- \ ' ' ,
30- \ ' return [' ,
31- \ ' //' ,
32- \ ' ];' ,
33- \ ],
63+ \ ' template' : templates.array,
3464 \ },
3565 \ ' config/app.php' : {
3666 \ ' type' : ' config' ,
3767 \ },
3868 \ ' app/*.php' : {
3969 \ ' type' : ' lib' ,
40- \ ' template' : [
41- \ ' <?php' ,
42- \ ' ' ,
43- \ ' namespace {namespace};' ,
44- \ ' ' ,
45- \ ' class {basename}' ,
46- \ ' {open}' ,
47- \ ' //' ,
48- \ ' {close}' ,
49- \ ],
70+ \ ' template' : templates.class ,
5071 \ },
5172 \ ' app/Broadcasting/*.php' : {
5273 \ ' type' : ' channel' ,
5374 \ },
5475 \ ' app/Casts/*.php' : {
5576 \ ' type' : ' cast' ,
56- \ ' template' : [
57- \ ' <?php' ,
58- \ ' ' ,
59- \ ' namespace {namespace};' ,
60- \ ' ' ,
61- \ ' use Illuminate\Contracts\Database\Eloquent\CastsAttributes;' ,
62- \ ' ' ,
63- \ ' class {basename} extends CastsAttributes' ,
64- \ ' {open}' ,
65- \ ' //' ,
66- \ ' {close}' ,
67- \ ],
6877 \ },
6978 \ ' app/View/Components/*.php' : {
7079 \ ' type' : ' component' ,
7180 \ },
7281 \ ' app/Http/Controllers/*.php' : {
7382 \ ' type' : ' controller' ,
74- \ ' template' : [
75- \ ' <?php' ,
76- \ ' ' ,
77- \ ' namespace {namespace};' ,
78- \ ' ' ,
79- \ ' class {basename} extends Controller' ,
80- \ ' {open}' ,
81- \ ' //' ,
82- \ ' {close}' ,
83- \ ],
8483 \ },
8584 \ ' app/Http/Controllers/Controller.php' : {
8685 \ ' type' : ' controller' ,
8786 \ },
8887 \ ' app/Mail/*.php' : {
8988 \ ' type' : ' mail' ,
90- \ ' template' : [
91- \ ' <?php' ,
92- \ ' ' ,
93- \ ' namespace {namespace};' ,
94- \ ' ' ,
95- \ ' use Illuminate\Bus\Queueable;' ,
96- \ ' use Illuminate\Mail\Mailable;' ,
97- \ ' use Illuminate\Queue\SerializesModels;' ,
98- \ ' use Illuminate\Contracts\Queue\ShouldQueue;' ,
99- \ ' ' ,
100- \ ' class {basename} extends Mailable' ,
101- \ ' {open}' ,
102- \ ' use Queueable, SerializesModels;' ,
103- \ ' ' ,
104- \ ' /**' ,
105- \ ' * Build the message.' ,
106- \ ' *' ,
107- \ ' * @return $this' ,
108- \ ' */' ,
109- \ ' public function build()' ,
110- \ ' {open}' ,
111- \ ' //' ,
112- \ ' {close}' ,
113- \ ' {close}' ,
114- \ ],
11589 \ },
11690 \ ' app/Http/Middleware/*.php' : {
11791 \ ' type' : ' middleware' ,
@@ -121,36 +95,12 @@ function! laravel#projectionist#append() abort
12195 \ },
12296 \ ' app/Http/Requests/*.php' : {
12397 \ ' type' : ' request' ,
124- \ ' template' : [
125- \ ' <?php' ,
126- \ ' ' ,
127- \ ' namespace {namespace};' ,
128- \ ' ' ,
129- \ ' use Illuminate\Foundation\Http\FormRequest;' ,
130- \ ' ' ,
131- \ ' class {basename} extends FormRequest' ,
132- \ ' {open}' ,
133- \ ' //' ,
134- \ ' {close}' ,
135- \ ],
13698 \ },
13799 \ ' app/Http/Resources/*.php' : {
138100 \ ' type' : ' resource' ,
139101 \ },
140102 \ ' app/Rules/*.php' : {
141103 \ ' type' : ' rule' ,
142- \ ' template' : [
143- \ ' <?php' ,
144- \ ' ' ,
145- \ ' namespace {namespace};' ,
146- \ ' ' ,
147- \ ' use Illuminate\Contracts\Validation\Rule;' ,
148- \ ' ' ,
149- \ ' class {basename} implements Rule' ,
150- \ ' {open}' ,
151- \ ' //' ,
152- \ ' {close}' ,
153- \ ],
154104 \ },
155105 \ ' app/Events/*.php' : {
156106 \ ' type' : ' event' ,
@@ -178,6 +128,9 @@ function! laravel#projectionist#append() abort
178128 \ ' app/Providers/*.php' : {
179129 \ ' type' : ' provider' ,
180130 \ },
131+ \ ' database/*.php' : {
132+ \ ' template' : templates.class ,
133+ \ },
181134 \ ' database/factories/*Factory.php' : {
182135 \ ' type' : ' factory' ,
183136 \ },
@@ -186,15 +139,11 @@ function! laravel#projectionist#append() abort
186139 \ },
187140 \ ' database/migrations/*.php' : {
188141 \ ' type' : ' migration' ,
189- \ },
190- \ ' database/seeds/*.php' : {
191- \ ' type' : ' seeder' ,
192- \ },
193- \ ' database/seeds/DatabaseSeeder.php' : {
194- \ ' type' : ' seeder' ,
142+ \ ' template' : templates.generic,
195143 \ },
196144 \ ' tests/*.php' : {
197145 \ ' type' : ' test' ,
146+ \ ' template' : templates.class ,
198147 \ },
199148 \ ' tests/TestCase.php' : {
200149 \ ' type' : ' test' ,
@@ -205,13 +154,7 @@ function! laravel#projectionist#append() abort
205154 \ },
206155 \ ' resources/lang/*.php' : {
207156 \ ' type' : ' language' ,
208- \ ' template' : [
209- \ ' <?php' ,
210- \ ' ' ,
211- \ ' return [' ,
212- \ ' //' ,
213- \ ' ];' ,
214- \ ],
157+ \ ' template' : templates.array,
215158 \ },
216159 \ ' resources/assets/*' : {
217160 \ ' type' : ' asset' ,
@@ -286,18 +229,23 @@ function! laravel#projectionist#append() abort
286229 if laravel#app ().has (' models' )
287230 let projections[' app/Models/*.php' ] = {
288231 \ ' type' : ' model' ,
289- \ ' template' : [
290- \ ' <?php' ,
291- \ ' ' ,
292- \ ' namespace {namespace};' ,
293- \ ' ' ,
294- \ ' use Illuminate\Database\Eloquent\Model;' ,
295- \ ' ' ,
296- \ ' class {basename} extends Model' ,
297- \ ' {open}' ,
298- \ ' //' ,
299- \ ' {close}' ,
300- \ ],
232+ \ }
233+ endif
234+
235+ " In Laravel 8, the seeds/ directory was renamed to seeders/.
236+ if laravel#app ().has (' database/seeds/' )
237+ let projections[' database/seeds/*.php' ] = {
238+ \ ' type' : ' seeder' ,
239+ \ }
240+ let projections[' database/seeds/DatabaseSeeder.php' ] = {
241+ \ ' type' : ' seeder' ,
242+ \ }
243+ else
244+ let projections[' database/seeders/*.php' ] = {
245+ \ ' type' : ' seeder' ,
246+ \ }
247+ let projections[' database/seeders/DatabaseSeeder.php' ] = {
248+ \ ' type' : ' seeder' ,
301249 \ }
302250 endif
303251
@@ -346,16 +294,7 @@ function! laravel#projectionist#append() abort
346294 if laravel#app ().has (' traits' )
347295 let projections[' app/Traits/*.php' ] = {
348296 \ ' type' : ' trait' ,
349- \ ' template' : [
350- \ ' <?php' ,
351- \ ' ' ,
352- \ ' namespace {namespace};' ,
353- \ ' ' ,
354- \ ' trait {basename}' ,
355- \ ' {open}' ,
356- \ ' //' ,
357- \ ' {close}' ,
358- \ ],
297+ \ ' template' : templates.trait,
359298 \ }
360299 endif
361300
0 commit comments