Skip to content

Commit 105f14a

Browse files
eidng8barryvdh
authored andcommitted
Add Fluent helpers (using config option) (#404)
* add fluent option to Generator * add fluent to helper output * add fluent option to config * typo
1 parent 5fad258 commit 105f14a

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

config/ide-helper.php

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
'filename' => '_ide_helper',
1515
'format' => 'php',
1616

17+
/*
18+
|--------------------------------------------------------------------------
19+
| Fluent helpers
20+
|--------------------------------------------------------------------------
21+
|
22+
| Set to true to generate commonly used Fluent methods
23+
|
24+
*/
25+
26+
'include_fluent' => false,
27+
1728
/*
1829
|--------------------------------------------------------------------------
1930
| Helper files to include

resources/views/helper.php

+27
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,30 @@ public static function <?= $method->getName() ?>(<?= $method->getParamsWithDefau
3737
}
3838

3939
<?php endforeach; ?>
40+
41+
42+
<?php if($include_fluent): ?>
43+
namespace Illuminate\Support {
44+
/**
45+
* Methods commonly used in migrations
46+
*
47+
* @method Fluent after(string $column) Add the after modifier
48+
* @method Fluent charset(string $charset) Add the character set modifier
49+
* @method Fluent collation(string $collation) Add the collation modifier
50+
* @method Fluent comment(string $comment) Add comment
51+
* @method Fluent default(mixed $value) Add the default modifier
52+
* @method Fluent first() Select first row
53+
* @method Fluent index(string $name = null) Add the in dex clause
54+
* @method Fluent on(string $column) `on` of a foreign key
55+
* @method Fluent onDelete(string $action) `on delete` of a foreign key
56+
* @method Fluent onUpdate(string $action) `on update` of a foreign key
57+
* @method Fluent primary() Add the primary key modifier
58+
* @method Fluent references(string $table) `references` of a foreign key
59+
* @method Fluent nullable() Add the nullable modifier
60+
* @method Fluent unique(string $name = null) Add unique index clause
61+
* @method Fluent unsigned() Add the unsigned modifier
62+
* @method Fluent useCurrent() Add the default timestamp value
63+
*/
64+
class Fluent {}
65+
}
66+
<?php endif ?>

src/Generator.php

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public function generatePhpHelper()
8484
->with('namespaces', $this->getNamespaces())
8585
->with('helpers', $this->helpers)
8686
->with('version', $app->version())
87+
->with('include_fluent', $this->config->get('ide-helper.include_fluent', false))
8788
->render();
8889
}
8990

0 commit comments

Comments
 (0)