@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | // First, we will need to determine the foreign key and "other key" for the |
| 36 | 36 | // relationship. Once we have determined the keys we will make the query |
| 37 | 37 | // instances, as well as the relationship instances we need for these. |
| 38 | - $foreignKey = $foreignKey ?: $name . '_id'; |
|
| 38 | + $foreignKey = $foreignKey ?: $name.'_id'; |
|
| 39 | 39 | |
| 40 | 40 | $instance = new $related(); |
| 41 | 41 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | // For the inverse of the polymorphic many-to-many relations, we will change |
| 69 | 69 | // the way we determine the foreign and other keys, as it is the opposite |
| 70 | 70 | // of the morph-to-many method since we're figuring out these inverses. |
| 71 | - $otherKey = $otherKey ?: $name . '_id'; |
|
| 71 | + $otherKey = $otherKey ?: $name.'_id'; |
|
| 72 | 72 | |
| 73 | 73 | return $this->morphToSortedMany($related, $name, $orderColumn, $table, $foreignKey, $otherKey, true); |
| 74 | 74 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | public function boot() |
| 24 | 24 | { |
| 25 | 25 | $this->publishes([ |
| 26 | - __DIR__ . '/../../config/sortable.php' => config_path('sortable.php'), |
|
| 26 | + __DIR__.'/../../config/sortable.php' => config_path('sortable.php'), |
|
| 27 | 27 | ]); |
| 28 | 28 | } |
| 29 | 29 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | $rules = [ |
| 60 | 60 | 'type' => ['required', 'in:moveAfter,moveBefore'], |
| 61 | - 'entityName' => ['required', 'in:' . implode(',', array_keys($sortableEntities))], |
|
| 61 | + 'entityName' => ['required', 'in:'.implode(',', array_keys($sortableEntities))], |
|
| 62 | 62 | 'id' => 'required', |
| 63 | 63 | 'positionEntityId' => 'required', |
| 64 | 64 | ]; |
@@ -75,16 +75,16 @@ discard block |
||
| 75 | 75 | $primaryKey = with(new $entityClass())->getKeyName(); |
| 76 | 76 | |
| 77 | 77 | if (!$relation) { |
| 78 | - $rules['id'] .= '|exists:' . $tableName . ',' . $primaryKey; |
|
| 79 | - $rules['positionEntityId'] .= '|exists:' . $tableName . ',' . $primaryKey; |
|
| 78 | + $rules['id'] .= '|exists:'.$tableName.','.$primaryKey; |
|
| 79 | + $rules['positionEntityId'] .= '|exists:'.$tableName.','.$primaryKey; |
|
| 80 | 80 | } else { |
| 81 | 81 | /** @var BelongsToSortedMany $relationObject */ |
| 82 | 82 | $relationObject = with(new $entityClass())->$relation(); |
| 83 | 83 | $pivotTable = $relationObject->getTable(); |
| 84 | 84 | |
| 85 | - $rules['parentId'] = 'required|exists:' . $tableName . ',' . $primaryKey; |
|
| 86 | - $rules['id'] .= '|exists:' . $pivotTable . ',' . $relationObject->getRelatedKey() . ',' . $relationObject->getForeignKey() . ',' . $request->input('parentId'); |
|
| 87 | - $rules['positionEntityId'] .= '|exists:' . $pivotTable . ',' . $relationObject->getRelatedKey() . ',' . $relationObject->getForeignKey() . ',' . $request->input('parentId'); |
|
| 85 | + $rules['parentId'] = 'required|exists:'.$tableName.','.$primaryKey; |
|
| 86 | + $rules['id'] .= '|exists:'.$pivotTable.','.$relationObject->getRelatedKey().','.$relationObject->getForeignKey().','.$request->input('parentId'); |
|
| 87 | + $rules['positionEntityId'] .= '|exists:'.$pivotTable.','.$relationObject->getRelatedKey().','.$relationObject->getForeignKey().','.$request->input('parentId'); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | return $validator->make($request->all(), $rules); |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
| 290 | - * @param string|array $sortableGroupField |
|
| 290 | + * @param string|null $sortableGroupField |
|
| 291 | 291 | * @param Model $entity |
| 292 | 292 | * |
| 293 | 293 | * @throws SortableException |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
| 311 | - * @param Model|SortableTrait $entity1 |
|
| 311 | + * @param SortableTrait $entity1 |
|
| 312 | 312 | * @param Model $entity2 |
| 313 | 313 | * @param string $field |
| 314 | 314 | * |
@@ -93,14 +93,14 @@ discard block |
||
| 93 | 93 | $oldPosition = $this->getAttribute($sortableField); |
| 94 | 94 | $newPosition = $entity->getAttribute($sortableField); |
| 95 | 95 | |
| 96 | - if($groupField && $this->getCanSwitchBetweenGroups()) { |
|
| 96 | + if ($groupField && $this->getCanSwitchBetweenGroups()) { |
|
| 97 | 97 | $oldList = $this->getAttribute($groupField); |
| 98 | 98 | $newList = $entity->getAttribute($groupField); |
| 99 | - if($oldList !== $newList) |
|
| 99 | + if ($oldList !== $newList) |
|
| 100 | 100 | { |
| 101 | 101 | $query = static::applySortableGroup(static::on(), $entity); |
| 102 | 102 | $oldPosition = $query->max($sortableField) + 1; |
| 103 | - $this->setAttribute($groupField,$newList); |
|
| 103 | + $this->setAttribute($groupField, $newList); |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | { |
| 271 | 271 | $sortableGroupField = self::getSortableGroupField(); |
| 272 | 272 | |
| 273 | - if($sortableGroupField == null || is_array($sortableGroupField)) |
|
| 273 | + if ($sortableGroupField == null || is_array($sortableGroupField)) |
|
| 274 | 274 | return false; |
| 275 | 275 | |
| 276 | 276 | return isset(static::$switchBetweenGroups) ? static::$switchBetweenGroups : false; |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | */ |
| 295 | 295 | public function checkSortableGroupField($sortableGroupField, $entity) |
| 296 | 296 | { |
| 297 | - if($this->getCanSwitchBetweenGroups()) { |
|
| 297 | + if ($this->getCanSwitchBetweenGroups()) { |
|
| 298 | 298 | return; |
| 299 | 299 | } |
| 300 | 300 | |
@@ -270,8 +270,9 @@ |
||
| 270 | 270 | { |
| 271 | 271 | $sortableGroupField = self::getSortableGroupField(); |
| 272 | 272 | |
| 273 | - if($sortableGroupField == null || is_array($sortableGroupField)) |
|
| 274 | - return false; |
|
| 273 | + if($sortableGroupField == null || is_array($sortableGroupField)) { |
|
| 274 | + return false; |
|
| 275 | + } |
|
| 275 | 276 | |
| 276 | 277 | return isset(static::$switchBetweenGroups) ? static::$switchBetweenGroups : false; |
| 277 | 278 | } |