@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Thinktomorrow\Chief\Concerns\Archivable; |
6 | 6 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | public function onlyModules(): Collection |
35 | 35 | { |
36 | - return $this->collection()->reject(function ($item) { |
|
36 | + return $this->collection()->reject(function($item) { |
|
37 | 37 | if ($item instanceof Page || $item instanceof StoredSetReference) { |
38 | 38 | return true; |
39 | 39 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | public function onlyPages(): Collection |
44 | 44 | { |
45 | - return $this->collection()->filter(function ($item) { |
|
45 | + return $this->collection()->filter(function($item) { |
|
46 | 46 | if ($item instanceof Page) { |
47 | 47 | return true; |
48 | 48 | } |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | |
73 | 73 | // Merging the results of all the pages and all the modules, then filter by the config |
74 | 74 | // This prevents us from having duplicates and also reduces the query load. |
75 | - $collection = $collection->filter(function ($page) use ($available_children_types) { |
|
75 | + $collection = $collection->filter(function($page) use ($available_children_types) { |
|
76 | 76 | return in_array(get_class($page), $available_children_types); |
77 | 77 | }); |
78 | 78 | |
79 | 79 | // Filter out our already loaded pages and modules |
80 | - $remaining_children_types = collect($available_children_types)->reject(function ($type) { |
|
80 | + $remaining_children_types = collect($available_children_types)->reject(function($type) { |
|
81 | 81 | return (new $type() instanceof Page || new $type() instanceof Module); |
82 | 82 | }); |
83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $collection = collect(array_merge($collection->all(), (new $type())->all()->all())); |
89 | 89 | } |
90 | 90 | // Filter out our parent |
91 | - return $this->collection = $collection->reject(function ($item) { |
|
91 | + return $this->collection = $collection->reject(function($item) { |
|
92 | 92 | if ($item instanceof $this->parent) { |
93 | 93 | return $item->id == $this->parent->id; |
94 | 94 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | ]; |
18 | 18 | |
19 | 19 | foreach ($viewPaths as $viewPath) { |
20 | - if (! view()->exists($viewPath)) { |
|
20 | + if (!view()->exists($viewPath)) { |
|
21 | 21 | continue; |
22 | 22 | } |
23 | 23 |
@@ -103,7 +103,7 @@ |
||
103 | 103 | { |
104 | 104 | $relations = static::where(function ($query) use ($type, $id) { |
105 | 105 | return $query->where('parent_type', $type) |
106 | - ->where('parent_id', $id); |
|
106 | + ->where('parent_id', $id); |
|
107 | 107 | })->orWhere(function ($query) use ($type, $id) { |
108 | 108 | return $query->where('child_type', $type) |
109 | 109 | ->where('child_id', $id); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | ->orderBy('sort', 'ASC') |
52 | 52 | ->get(); |
53 | 53 | |
54 | - return $relations->map(function (Relation $relation) { |
|
54 | + return $relations->map(function(Relation $relation) { |
|
55 | 55 | $parent = $relation->parent; |
56 | 56 | $parent->relation = $relation; |
57 | 57 | return $parent; |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | ->orderBy('sort', 'ASC') |
66 | 66 | ->get(); |
67 | 67 | |
68 | - return $relations->map(function (Relation $relation) use ($parent_type, $parent_id) { |
|
68 | + return $relations->map(function(Relation $relation) use ($parent_type, $parent_id) { |
|
69 | 69 | |
70 | 70 | // It could be that the child itself is soft-deleted, if this is the case, we will ignore it and move on. |
71 | 71 | if (!$child = $relation->child) { |
72 | 72 | if (!$relation->child()->withTrashed()->first()) { |
73 | 73 | // if ((!method_exists($childInstance, 'trashed')) || ! $childInstance->onlyTrashed()->find($relation->child_id)) { |
74 | 74 | // If we cannot retrieve it then he collection type is possibly off, this is a database inconsistency and should be addressed |
75 | - 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.'); |
|
75 | + 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.'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | return null; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | }) |
85 | 85 | |
86 | 86 | // 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 |
87 | - ->reject(function ($child) { |
|
87 | + ->reject(function($child) { |
|
88 | 88 | return is_null($child); |
89 | 89 | }) |
90 | 90 | ->values(); |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | |
102 | 102 | public static function deleteRelationsOf($type, $id) |
103 | 103 | { |
104 | - $relations = static::where(function ($query) use ($type, $id) { |
|
104 | + $relations = static::where(function($query) use ($type, $id) { |
|
105 | 105 | return $query->where('parent_type', $type) |
106 | 106 | ->where('parent_id', $id); |
107 | - })->orWhere(function ($query) use ($type, $id) { |
|
107 | + })->orWhere(function($query) use ($type, $id) { |
|
108 | 108 | return $query->where('child_type', $type) |
109 | 109 | ->where('child_id', $id); |
110 | 110 | })->get(); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Thinktomorrow\Chief\Media; |
6 | 6 |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | if (is_string($file)) { |
58 | 58 | $image_name = json_decode($file)->output->name; |
59 | 59 | $asset = $this->addAsset(json_decode($file)->output->image, $type, null, $image_name, $model); |
60 | - } else { |
|
60 | + }else { |
|
61 | 61 | $image_name = $file->getClientOriginalName(); |
62 | 62 | $asset = $this->addAsset($file, $type, null, $image_name, $model); |
63 | 63 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | if (is_string($file)) { |
82 | 82 | $asset = AssetUploader::uploadFromBase64($file, $filename); |
83 | - } else { |
|
83 | + }else { |
|
84 | 84 | $asset = AssetUploader::upload($file, $filename); |
85 | 85 | } |
86 | 86 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | private function removeFiles(HasMedia $model, array $files) |
115 | 115 | { |
116 | 116 | if (isset($files['delete']) && is_array($files['delete']) && !empty($files['delete'])) { |
117 | - foreach($model->assets()->whereIn('id', $files['delete'])->get() as $asset){ |
|
117 | + foreach ($model->assets()->whereIn('id', $files['delete'])->get() as $asset) { |
|
118 | 118 | $asset->delete(); |
119 | 119 | } |
120 | 120 | } |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | */ |
127 | 127 | private function sluggifyFilename($filename): string |
128 | 128 | { |
129 | - $extension = substr($filename, strrpos($filename, '.') + 1); |
|
129 | + $extension = substr($filename, strrpos($filename, '.')+1); |
|
130 | 130 | $filename = substr($filename, 0, strrpos($filename, '.')); |
131 | - $filename = str_slug($filename) . '.' . $extension; |
|
131 | + $filename = str_slug($filename).'.'.$extension; |
|
132 | 132 | |
133 | 133 | return $filename; |
134 | 134 | } |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | if ($file instanceof UploadedFile && !$file->isValid()) { |
145 | 145 | if ($file->getError() == UPLOAD_ERR_INI_SIZE) { |
146 | 146 | throw new FileTooBigException( |
147 | - 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. ' . |
|
148 | - 'upload_max_filesize: ' . (int)ini_get('upload_max_filesize') . 'MB, ' . |
|
149 | - 'post_max_size: ' . (int)(ini_get('post_max_size')) . 'MB' |
|
147 | + 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. '. |
|
148 | + 'upload_max_filesize: '.(int)ini_get('upload_max_filesize').'MB, '. |
|
149 | + 'post_max_size: '.(int)(ini_get('post_max_size')).'MB' |
|
150 | 150 | ); |
151 | 151 | } |
152 | 152 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | { |
13 | 13 | $this->fetch(); |
14 | 14 | |
15 | - if (! isset($this->values[$key])) { |
|
15 | + if (!isset($this->values[$key])) { |
|
16 | 16 | return $default; |
17 | 17 | } |
18 | 18 |
@@ -11,7 +11,7 @@ |
||
11 | 11 | public static function generate(): Field |
12 | 12 | { |
13 | 13 | $singles = Single::all(); |
14 | - $singles = $singles->map(function ($single) { |
|
14 | + $singles = $singles->map(function($single) { |
|
15 | 15 | |
16 | 16 | // Select label (from translatable title field) |
17 | 17 | $single->label = $single->title; |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | public function register() |
15 | 15 | { |
16 | - $this->app->singleton(SettingsManager::class, function ($app) { |
|
16 | + $this->app->singleton(SettingsManager::class, function($app) { |
|
17 | 17 | return new SettingsManager(); |
18 | 18 | }); |
19 | 19 | } |