File tree Expand file tree Collapse file tree 3 files changed +5
-1
lines changed
Expand file tree Collapse file tree 3 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,7 @@ You can set:
142142* * string* ` positionColumn ` * to enable overriding for the position column*
143143* * boolean* ` disablePositionUpdate ` * disables the updated of other entries*
144144* * string|array* ` positionGroup ` * builds a filter from columns for position calculation. Supports single column or multiple columns*
145+ * * string* ` defaultPositionValue ` * allows returning different value when position is empty string or null. Default value is null*
145146
146147#### PositionScopeTrait
147148
Original file line number Diff line number Diff line change @@ -48,7 +48,8 @@ public function setPosition($value)
4848 protected function setPositionAttribute ($ value )
4949 {
5050 // Convert to numeric value if needed
51- $ finalValue = is_null ($ value ) || $ value === '' ? null : intval ($ value );
51+ $ finalValue = is_null ($ value ) || $ value === '' ?
52+ $ this ->positionOption ('defaultPositionValue ' , null ) : intval ($ value );
5253
5354 $ this ->attributes ['position ' ] = $ finalValue ;
5455 }
Original file line number Diff line number Diff line change 11<?php
2+
23namespace Pion \Support \Eloquent \Position \Traits ;
34
45use Pion \Support \Eloquent \Position \PositionObserver ;
89/**
910 * Trait PositionTrait
1011 *
12+ * @property mixed defaultPositionValue Setup default value
1113 * @property array attributes
1214 * @property string positionColumn to enable overriding for the position column
1315 * @property boolean disablePositionUpdate disables the updated of other entries
You can’t perform that action at this time.
0 commit comments