@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | // instances, as well as the relationship instances we need for these. |
| 48 | 48 | $instance = $this->newRelatedInstance($related); |
| 49 | 49 | |
| 50 | - $foreignPivotKey = $foreignPivotKey ?: $name.'_id'; |
|
| 50 | + $foreignPivotKey = $foreignPivotKey ?: $name . '_id'; |
|
| 51 | 51 | |
| 52 | 52 | $relatedPivotKey = $relatedPivotKey ?: $instance->getForeignKey(); |
| 53 | 53 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | // For the inverse of the polymorphic many-to-many relations, we will change |
| 100 | 100 | // the way we determine the foreign and other keys, as it is the opposite |
| 101 | 101 | // of the morph-to-many method since we're figuring out these inverses. |
| 102 | - $relatedPivotKey = $relatedPivotKey ?: $name.'_id'; |
|
| 102 | + $relatedPivotKey = $relatedPivotKey ?: $name . '_id'; |
|
| 103 | 103 | |
| 104 | 104 | return $this->morphToSortedMany( |
| 105 | 105 | $related, |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | $sortableEntities = app('config')->get('sortable.entities', []); |
| 18 | 18 | $validator = $this->getValidator($sortableEntities, $request); |
| 19 | 19 | |
| 20 | - if (! $validator->passes()) { |
|
| 20 | + if (!$validator->passes()) { |
|
| 21 | 21 | return [ |
| 22 | 22 | 'success' => false, |
| 23 | 23 | 'errors' => $validator->errors(), |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | [$entityClass, $relation] = $this->getEntityInfo($sortableEntities, (string) $request->input('entityName')); |
| 30 | 30 | $method = ($request->input('type') === 'moveAfter') ? 'moveAfter' : 'moveBefore'; |
| 31 | 31 | |
| 32 | - if (! $relation) { |
|
| 32 | + if (!$relation) { |
|
| 33 | 33 | /** @var SortableTrait $entity */ |
| 34 | 34 | $entity = $entityClass::find($request->input('id')); |
| 35 | 35 | $postionEntity = $entityClass::find($request->input('positionEntityId')); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $rules = [ |
| 58 | 58 | 'type' => ['required', 'in:moveAfter,moveBefore'], |
| 59 | - 'entityName' => ['required', 'in:'.implode(',', array_keys($sortableEntities))], |
|
| 59 | + 'entityName' => ['required', 'in:' . implode(',', array_keys($sortableEntities))], |
|
| 60 | 60 | 'id' => 'required', |
| 61 | 61 | 'positionEntityId' => 'required', |
| 62 | 62 | ]; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | /** @var Model|bool $entityClass */ |
| 65 | 65 | [$entityClass, $relation] = $this->getEntityInfo($sortableEntities, (string) $request->input('entityName')); |
| 66 | 66 | |
| 67 | - if (! class_exists($entityClass)) { |
|
| 67 | + if (!class_exists($entityClass)) { |
|
| 68 | 68 | $rules['entityClass'] = 'required'; // fake rule for not exist field |
| 69 | 69 | |
| 70 | 70 | return $validator->make($request->all(), $rules); |
@@ -74,21 +74,21 @@ discard block |
||
| 74 | 74 | $tableName = with(new $entityClass)->getTable(); |
| 75 | 75 | $primaryKey = with(new $entityClass)->getKeyName(); |
| 76 | 76 | |
| 77 | - if (! empty($connectionName)) { |
|
| 78 | - $tableName = $connectionName.'.'.$tableName; |
|
| 77 | + if (!empty($connectionName)) { |
|
| 78 | + $tableName = $connectionName . '.' . $tableName; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if (! $relation) { |
|
| 82 | - $rules['id'] .= '|exists:'.$tableName.','.$primaryKey; |
|
| 83 | - $rules['positionEntityId'] .= '|exists:'.$tableName.','.$primaryKey; |
|
| 81 | + if (!$relation) { |
|
| 82 | + $rules['id'] .= '|exists:' . $tableName . ',' . $primaryKey; |
|
| 83 | + $rules['positionEntityId'] .= '|exists:' . $tableName . ',' . $primaryKey; |
|
| 84 | 84 | } else { |
| 85 | 85 | /** @var BelongsToSortedMany $relationObject */ |
| 86 | 86 | $relationObject = with(new $entityClass)->$relation(); |
| 87 | 87 | $pivotTable = $relationObject->getTable(); |
| 88 | 88 | |
| 89 | - $rules['parentId'] = 'required|exists:'.$tableName.','.$primaryKey; |
|
| 90 | - $rules['id'] .= '|exists:'.$pivotTable.','.$relationObject->getRelatedKey().','.$relationObject->getForeignKey().','.$request->input('parentId'); |
|
| 91 | - $rules['positionEntityId'] .= '|exists:'.$pivotTable.','.$relationObject->getRelatedKey().','.$relationObject->getForeignKey().','.$request->input('parentId'); |
|
| 89 | + $rules['parentId'] = 'required|exists:' . $tableName . ',' . $primaryKey; |
|
| 90 | + $rules['id'] .= '|exists:' . $pivotTable . ',' . $relationObject->getRelatedKey() . ',' . $relationObject->getForeignKey() . ',' . $request->input('parentId'); |
|
| 91 | + $rules['positionEntityId'] .= '|exists:' . $pivotTable . ',' . $relationObject->getRelatedKey() . ',' . $relationObject->getForeignKey() . ',' . $request->input('parentId'); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | return $validator->make($request->all(), $rules); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | if (is_array($entityConfig)) { |
| 109 | 109 | $entityClass = $entityConfig['entity']; |
| 110 | - $relation = ! empty($entityConfig['relation']) ? $entityConfig['relation'] : false; |
|
| 110 | + $relation = !empty($entityConfig['relation']) ? $entityConfig['relation'] : false; |
|
| 111 | 111 | } else { |
| 112 | 112 | $entityClass = $entityConfig; |
| 113 | 113 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | public function boot(): void |
| 22 | 22 | { |
| 23 | 23 | $this->publishes([ |
| 24 | - __DIR__.'/../../config/sortable.php' => config_path('sortable.php'), |
|
| 24 | + __DIR__ . '/../../config/sortable.php' => config_path('sortable.php'), |
|
| 25 | 25 | ]); |
| 26 | 26 | } |
| 27 | 27 | |