File tree Expand file tree Collapse file tree 4 files changed +62
-0
lines changed Expand file tree Collapse file tree 4 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Build Assets
2+
3+ on : pull_request
4+
5+ jobs :
6+ build :
7+ runs-on : ubuntu-latest
8+ steps :
9+ - uses : actions/checkout@v3
10+
11+ - run : composer update
12+
13+ - run : ./vendor/bin/pint
14+
15+ - run : |
16+ git config --global user.name 'Simon Hamp'
17+ git config --global user.email 'simon.hamp@me.com'
18+ if git add * ; then
19+ git commit -m "Code style fixes"
20+ git push
21+ fi
Original file line number Diff line number Diff line change 1+ {
2+ "preset" : " laravel" ,
3+ "rules" : {
4+ "statement_indentation" : true
5+ }
6+ }
Original file line number Diff line number Diff line change 66use Illuminate \Support \Str ;
77use SimonHamp \LaravelNovaCsvImport \Contracts \Modifier ;
88use SimonHamp \LaravelNovaCsvImport \Modifiers \Boolean ;
9+ use SimonHamp \LaravelNovaCsvImport \Modifiers \DefaultValue ;
910use SimonHamp \LaravelNovaCsvImport \Modifiers \ExcelDate ;
1011use SimonHamp \LaravelNovaCsvImport \Modifiers \Hash ;
1112use SimonHamp \LaravelNovaCsvImport \Modifiers \Prefix ;
@@ -23,6 +24,7 @@ protected function bootHasModifiers()
2324 // Register built-in modifiers
2425 static ::registerModifiers (
2526 new Boolean ,
27+ new DefaultValue ,
2628 new ExcelDate ,
2729 new StrModifier ,
2830 new Hash ,
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace SimonHamp \LaravelNovaCsvImport \Modifiers ;
4+
5+ use SimonHamp \LaravelNovaCsvImport \Contracts \Modifier ;
6+
7+ class DefaultValue implements Modifier
8+ {
9+ public function title (): string
10+ {
11+ return 'Default Value ' ;
12+ }
13+
14+ public function description (): string
15+ {
16+ return 'Set a default value for the field if the CSV column is empty or missing ' ;
17+ }
18+
19+ public function settings (): array
20+ {
21+ return [
22+ 'string ' => [
23+ 'type ' => 'string ' ,
24+ 'title ' => 'Default Value ' ,
25+ ],
26+ ];
27+ }
28+
29+ public function handle ($ value = null , array $ settings = []): string
30+ {
31+ return $ value === null ? $ settings ['string ' ] : $ value ;
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments