Skip to content

Commit 121d57b

Browse files
committed
cs-fix
1 parent bda20f8 commit 121d57b

4 files changed

Lines changed: 38 additions & 41 deletions

File tree

.github/workflows/code-style.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
php-cs-fixer:
55
runs-on: ubuntu-latest
66
container:
7-
image: kirschbaumdevelopment/laravel-test-runner:7.3.0
7+
image: kirschbaumdevelopment/laravel-test-runner:8.0
88

99
steps:
1010
- uses: actions/checkout@v1

.php_cs renamed to .php-cs-fixer.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
->ignoreDotFiles(true)
1010
->ignoreVCS(true);
1111

12-
return PhpCsFixer\Config::create()
12+
return (new PhpCsFixer\Config())
1313
->setFinder($finder)
1414
->setRules([
1515
'@PSR2' => true,
@@ -20,9 +20,14 @@
2020
],
2121
'no_singleline_whitespace_before_semicolons' => true,
2222
'no_extra_blank_lines' => [
23-
'break', 'case', 'continue', 'curly_brace_block', 'default',
24-
'extra', 'parenthesis_brace_block', 'return',
25-
'square_brace_block', 'switch', 'throw', 'use', 'useTrait', 'use_trait',
23+
'tokens' => [
24+
'curly_brace_block',
25+
'extra',
26+
'parenthesis_brace_block',
27+
'square_brace_block',
28+
'throw',
29+
'use',
30+
]
2631
],
2732
'cast_spaces' => [
2833
'space' => 'single',
@@ -43,7 +48,7 @@
4348
// 'increment_style' => ['style' => 'post'],
4449
'short_scalar_cast' => true,
4550
'class_attributes_separation' => [
46-
'elements' => ['const', 'method', 'property'],
51+
'elements' => ['method' => 'one',],
4752
],
4853
'no_mixed_echo_print' => [
4954
'use' => 'echo',
@@ -54,7 +59,7 @@
5459
],
5560
'no_empty_statement' => true,
5661
'unary_operator_spaces' => true, // $number ++ becomes $number++
57-
'hash_to_slash_comment' => true, // # becomes //
62+
'single_line_comment_style' => true, // # becomes //
5863
'standardize_not_equals' => true, // <> becomes !=
5964
'native_function_casing' => true,
6065
'ternary_operator_spaces' => true,
@@ -64,16 +69,7 @@
6469
],
6570
'function_typehint_space' => true,
6671
'no_leading_import_slash' => true,
67-
'blank_line_before_statement' => [
68-
'statements' => [
69-
'break', 'case', 'continue',
70-
'declare', 'default', 'die',
71-
'do', 'exit', 'for', 'foreach',
72-
'goto', 'if', 'include',
73-
'include_once', 'require', 'require_once',
74-
'return', 'switch', 'throw', 'try', 'while', 'yield',
75-
],
76-
],
72+
'blank_line_before_statement' => true,
7773
'combine_consecutive_unsets' => true,
7874
'method_chaining_indentation' => true,
7975
'no_whitespace_in_blank_line' => true,
@@ -84,7 +80,7 @@
8480
'compact_nullable_typehint' => true,
8581
'explicit_string_variable' => true,
8682
'no_leading_namespace_whitespace' => true,
87-
'trailing_comma_in_multiline_array' => true,
83+
'trailing_comma_in_multiline' => true,
8884
'not_operator_with_successor_space' => true,
8985
'object_operator_without_whitespace' => true,
9086
'single_blank_line_before_namespace' => true,
@@ -113,7 +109,7 @@
113109
'protected',
114110
'private',
115111
],
116-
'sortAlgorithm' => 'none',
112+
'sort_algorithm' => 'none',
117113
],
118114
'return_type_declaration' => [
119115
'space_before' => 'none',

src/NovaInlineRelationship.php

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
use Illuminate\Database\Eloquent\Relations\Concerns\SupportsDefaultModels;
2424
use KirschbaumDevelopment\NovaInlineRelationship\Traits\RequireRelationship;
2525
use KirschbaumDevelopment\NovaInlineRelationship\Observers\NovaInlineRelationshipObserver;
26-
use Laravel\Nova\Fields\Select;
26+
2727
class NovaInlineRelationship extends Field
2828
{
2929
use RequireRelationship;
@@ -258,6 +258,27 @@ public function getValueFromField(Field $field, NovaInlineRelationshipRequest $r
258258
return $temp->{$attribute} ?? null;
259259
}
260260

261+
/**
262+
* Serialize options for the field.
263+
*
264+
* @param bool $searchable
265+
* @param mixed $optionsCallback
266+
*
267+
* @return array<int, array<string, mixed>>
268+
*/
269+
public function serializeOptions($optionsCallback)
270+
{
271+
$options = value($optionsCallback);
272+
273+
if (is_callable($options)) {
274+
$options = $options();
275+
}
276+
277+
return collect($options ?? [])->map(function ($label, $value) {
278+
return is_array($label) ? $label + ['value' => $value] : ['label' => $label, 'value' => $value];
279+
})->values()->all();
280+
}
281+
261282
/**
262283
* Resolve the fields for the resource.
263284
*
@@ -431,7 +452,7 @@ protected function getRelationshipRule($attribute, Collection $properties): Rela
431452
protected function getPropertiesFromResource($model, $attribute): Collection
432453
{
433454
$fields = $this->getFieldsFromResource($model, $attribute);
434-
455+
435456
return $this->getPropertiesFromFields($fields)
436457
->keyBy('attribute');
437458
}
@@ -563,23 +584,4 @@ protected function setModelAttributeValue(Model $model, $attribute, array $value
563584

564585
static::$observedModels[$modelClass][$attribute] = $this->isNullValue($value) ? null : $value;
565586
}
566-
567-
/**
568-
* Serialize options for the field.
569-
*
570-
* @param bool $searchable
571-
* @return array<int, array<string, mixed>>
572-
*/
573-
public function serializeOptions($optionsCallback)
574-
{
575-
$options = value($optionsCallback);
576-
577-
if (is_callable($options)) {
578-
$options = $options();
579-
}
580-
581-
return collect($options ?? [])->map(function ($label, $value) {
582-
return is_array($label) ? $label + ['value' => $value] : ['label' => $label, 'value' => $value];
583-
})->values()->all();
584-
}
585587
}

src/NovaInlineRelationshipRequest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
class NovaInlineRelationshipRequest extends NovaRequest
1111
{
12-
1312
/**
1413
* Update list of converted files
1514
*

0 commit comments

Comments
 (0)