@@ -23,7 +23,7 @@ |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | // non-assoc array of items |
| 26 | - if(is_array($this->items[$key]) && key($this->items[$key]) === 0) { |
|
| 26 | + if (is_array($this->items[$key]) && key($this->items[$key]) === 0) { |
|
| 27 | 27 | return $this->items[$key]; |
| 28 | 28 | } |
| 29 | 29 | |
@@ -52,8 +52,8 @@ |
||
| 52 | 52 | { |
| 53 | 53 | $instances = []; |
| 54 | 54 | |
| 55 | - foreach($flatReferences as $k => $flatReference) { |
|
| 56 | - if(is_string($flatReference)) { |
|
| 55 | + foreach ($flatReferences as $k => $flatReference) { |
|
| 56 | + if (is_string($flatReference)) { |
|
| 57 | 57 | $flatReference = FlatReferenceFactory::fromString($flatReference); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -37,11 +37,11 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | if ($verb == 'index' && $this->model->isPageSpecific()) { |
| 39 | 39 | |
| 40 | - if(!$this->model->page) { |
|
| 41 | - throw new \RuntimeException('Cannot retrieve parent for page specific module [type: '.$this->registration->key() .', id: '. $this->existingModel()->id.']'); |
|
| 40 | + if (!$this->model->page) { |
|
| 41 | + throw new \RuntimeException('Cannot retrieve parent for page specific module [type: '.$this->registration->key().', id: '.$this->existingModel()->id.']'); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - return app(Managers::class)->findByModel($this->model->page)->route('edit') . '#eigen-modules'; |
|
| 44 | + return app(Managers::class)->findByModel($this->model->page)->route('edit').'#eigen-modules'; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $routes = [ |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | if (is_array_empty($translation)) { |
| 162 | 162 | |
| 163 | 163 | // Nullify all values |
| 164 | - $trans[$locale] = array_map(function ($value) { |
|
| 164 | + $trans[$locale] = array_map(function($value) { |
|
| 165 | 165 | return null; |
| 166 | 166 | }, $translation); |
| 167 | 167 | continue; |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | ->orderBy('sort', 'ASC') |
| 55 | 55 | ->get(); |
| 56 | 56 | |
| 57 | - return $relations->map(function (Relation $relation) { |
|
| 57 | + return $relations->map(function(Relation $relation) { |
|
| 58 | 58 | $parent = $relation->parent; |
| 59 | 59 | $parent->relation = $relation; |
| 60 | 60 | |
@@ -70,13 +70,13 @@ discard block |
||
| 70 | 70 | ->orderBy('sort', 'ASC') |
| 71 | 71 | ->get(); |
| 72 | 72 | |
| 73 | - return $relations->map(function (Relation $relation) use ($parent_type, $parent_id) { |
|
| 73 | + return $relations->map(function(Relation $relation) use ($parent_type, $parent_id) { |
|
| 74 | 74 | |
| 75 | 75 | // It could be that the child itself is soft-deleted, if this is the case, we will ignore it and move on. |
| 76 | 76 | if (!$child = $relation->child) { |
| 77 | 77 | if (!$relation->child()->withTrashed()->first()) { |
| 78 | 78 | // If we cannot retrieve it then the relation type is possibly wrong, this is a database inconsistency and should be addressed |
| 79 | - throw new \DomainException('Corrupt relation reference. Related child [' . $relation->child_type . '@' . $relation->child_id . '] could not be retrieved for parent [' . $parent_type . '@' . $parent_id . ']. Make sure the morph key can resolve to a valid class.'); |
|
| 79 | + throw new \DomainException('Corrupt relation reference. Related child ['.$relation->child_type.'@'.$relation->child_id.'] could not be retrieved for parent ['.$parent_type.'@'.$parent_id.']. Make sure the morph key can resolve to a valid class.'); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | return null; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | }) |
| 89 | 89 | |
| 90 | 90 | // In case of soft-deleted entries, this will be null and should be ignored. We make sure that keys are reset in case of removed child |
| 91 | - ->reject(function ($child) { |
|
| 91 | + ->reject(function($child) { |
|
| 92 | 92 | return is_null($child); |
| 93 | 93 | }) |
| 94 | 94 | ->values(); |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | public static function deleteRelationsOf($type, $id) |
| 107 | 107 | { |
| 108 | - $relations = static::where(function ($query) use ($type, $id) { |
|
| 108 | + $relations = static::where(function($query) use ($type, $id) { |
|
| 109 | 109 | return $query->where('parent_type', $type) |
| 110 | 110 | ->where('parent_id', $id); |
| 111 | - })->orWhere(function ($query) use ($type, $id) { |
|
| 111 | + })->orWhere(function($query) use ($type, $id) { |
|
| 112 | 112 | return $query->where('child_type', $type) |
| 113 | 113 | ->where('child_id', $id); |
| 114 | 114 | })->get(); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | public static function deleteAllChildRelationsOf($type, $id) |
| 122 | 122 | { |
| 123 | - $relations = static::where(function ($query) use ($type, $id) { |
|
| 123 | + $relations = static::where(function($query) use ($type, $id) { |
|
| 124 | 124 | return $query->where('parent_type', $type) |
| 125 | 125 | ->where('parent_id', $id); |
| 126 | 126 | })->get(); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | public static function deleteAllParentRelationsOf($type, $id) |
| 134 | 134 | { |
| 135 | - $relations = static::where(function ($query) use ($type, $id) { |
|
| 135 | + $relations = static::where(function($query) use ($type, $id) { |
|
| 136 | 136 | return $query->where('child_type', $type) |
| 137 | 137 | ->where('child_id', $id); |
| 138 | 138 | })->get(); |
@@ -20,12 +20,12 @@ discard block |
||
| 20 | 20 | Assert::isInstanceOf($targetModel, Module::class); |
| 21 | 21 | |
| 22 | 22 | // Dynamic attributes |
| 23 | - if($sourceModel->values && $sourceModel->values instanceof DynamicAttributes) { |
|
| 23 | + if ($sourceModel->values && $sourceModel->values instanceof DynamicAttributes) { |
|
| 24 | 24 | $targetModel->values = $sourceModel->values; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | // Translations |
| 28 | - foreach($sourceModel->getTranslationsArray() as $locale => $values) { |
|
| 28 | + foreach ($sourceModel->getTranslationsArray() as $locale => $values) { |
|
| 29 | 29 | $targetModel->translations()->create(array_merge(['locale' => $locale], $values)); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $targetModel->save(); |
| 45 | 45 | |
| 46 | 46 | // Assets |
| 47 | - foreach($sourceModel->assets() as $asset) { |
|
| 47 | + foreach ($sourceModel->assets() as $asset) { |
|
| 48 | 48 | $targetModel->assetRelation()->attach($asset, ['type' => $asset->pivot->type, 'locale' => $asset->pivot->locale, 'order' => $asset->pivot->order]); |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | $targetModel = $this->findModel($targetClassName, $targetId); |
| 26 | 26 | |
| 27 | 27 | /** @var TemplateApplicator $applicator */ |
| 28 | - foreach($this->applicators as $applicator) { |
|
| 29 | - if(!$applicator->shouldApply($sourceModel, $targetModel)) { |
|
| 28 | + foreach ($this->applicators as $applicator) { |
|
| 29 | + if (!$applicator->shouldApply($sourceModel, $targetModel)) { |
|
| 30 | 30 | continue; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | return; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - $availableApplicatorsString = implode(array_map(function($applicator){ return get_class($applicator);}, $this->applicators), ','); |
|
| 38 | + $availableApplicatorsString = implode(array_map(function($applicator) { return get_class($applicator); }, $this->applicators), ','); |
|
| 39 | 39 | |
| 40 | 40 | throw new \RuntimeException("No proper template applicator found. $sourceClassName [$sourceId] cannot be applied as template. Available applicators: [$availableApplicatorsString]"); |
| 41 | 41 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | private function findModel(string $className, string $sourceId): Model |
| 50 | 50 | { |
| 51 | - if($morphedClassName = Relation::getMorphedModel($className)) { |
|
| 51 | + if ($morphedClassName = Relation::getMorphedModel($className)) { |
|
| 52 | 52 | $className = $morphedClassName; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -55,13 +55,13 @@ |
||
| 55 | 55 | if ($child instanceof Module && $child->isPageSpecific()) |
| 56 | 56 | { |
| 57 | 57 | $duplicatedChild = $child::create([ |
| 58 | - 'slug' => $targetModel->title ? $targetModel->title . '-' . $child->slug : $child->slug . '-copy', |
|
| 58 | + 'slug' => $targetModel->title ? $targetModel->title.'-'.$child->slug : $child->slug.'-copy', |
|
| 59 | 59 | 'owner_id' => $targetModel->id, |
| 60 | 60 | 'owner_type' => $targetModel->getMorphClass() |
| 61 | 61 | ]); |
| 62 | 62 | |
| 63 | 63 | $this->moduleTemplateApplicator->handle($child, $duplicatedChild); |
| 64 | - } else |
|
| 64 | + }else |
|
| 65 | 65 | { |
| 66 | 66 | $duplicatedChild = $child; |
| 67 | 67 | } |
@@ -37,12 +37,12 @@ |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $manager->saveCreateFields($request); |
| 40 | - if($request->filled('template')) { |
|
| 40 | + if ($request->filled('template')) { |
|
| 41 | 41 | $this->applyTemplate->handle( |
| 42 | 42 | FlatReferenceFactory::fromString($request->input('template'))->className(), |
| 43 | - (string) FlatReferenceFactory::fromString($request->input('template'))->id(), |
|
| 43 | + (string)FlatReferenceFactory::fromString($request->input('template'))->id(), |
|
| 44 | 44 | get_class($manager->existingModel()), |
| 45 | - (string) $manager->existingModel()->id |
|
| 45 | + (string)$manager->existingModel()->id |
|
| 46 | 46 | ); |
| 47 | 47 | } |
| 48 | 48 | |