-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from teamairship/feature/default-values
Feature: Add modifier for Default Values
- Loading branch information
Showing
4 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Build Assets | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- run: composer update | ||
|
||
- run: ./vendor/bin/pint | ||
|
||
- run: | | ||
git config --global user.name 'Simon Hamp' | ||
git config --global user.email 'simon.hamp@me.com' | ||
if git add * ; then | ||
git commit -m "Code style fixes" | ||
git push | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"preset": "laravel", | ||
"rules": { | ||
"statement_indentation": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace SimonHamp\LaravelNovaCsvImport\Modifiers; | ||
|
||
use SimonHamp\LaravelNovaCsvImport\Contracts\Modifier; | ||
|
||
class DefaultValue implements Modifier | ||
{ | ||
public function title(): string | ||
{ | ||
return 'Default Value'; | ||
} | ||
|
||
public function description(): string | ||
{ | ||
return 'Set a default value for the field if the CSV column is empty or missing'; | ||
} | ||
|
||
public function settings(): array | ||
{ | ||
return [ | ||
'string' => [ | ||
'type' => 'string', | ||
'title' => 'Default Value', | ||
], | ||
]; | ||
} | ||
|
||
public function handle($value = null, array $settings = []): string | ||
{ | ||
return $value === null ? $settings['string'] : $value; | ||
} | ||
} |