@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | if (isset(json_decode($file)->output)) { |
114 | 114 | $image_name = json_decode($file)->output->name; |
115 | 115 | $asset = app(AddAsset::class)->add($model, json_decode($file)->output->image, $type, $locale, $this->sluggifyFilename($image_name)); |
116 | - } else { |
|
116 | + }else { |
|
117 | 117 | if ($file instanceof UploadedFile) { |
118 | 118 | $image_name = $file->getClientOriginalName(); |
119 | 119 | $asset = app(AddAsset::class)->add($model, $file, $type, $locale, $this->sluggifyFilename($image_name)); |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | // New files are passed with their filename (instead of their id) |
122 | 122 | // For new files we will replace the filename with the id. |
123 | 123 | if (false !== ($key = array_search($image_name, $files_order))) { |
124 | - $files_order[$key] = (string) $asset->id; |
|
124 | + $files_order[$key] = (string)$asset->id; |
|
125 | 125 | } |
126 | - } else { |
|
126 | + }else { |
|
127 | 127 | $file = Asset::findOrFail($file); |
128 | 128 | $asset = app(AddAsset::class)->add($model, $file, $type, $locale); |
129 | 129 | } |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | */ |
137 | 137 | private function sluggifyFilename($filename): string |
138 | 138 | { |
139 | - $extension = substr($filename, strrpos($filename, '.') + 1); |
|
139 | + $extension = substr($filename, strrpos($filename, '.')+1); |
|
140 | 140 | $filename = substr($filename, 0, strrpos($filename, '.')); |
141 | - $filename = Str::slug($filename) . '.' . $extension; |
|
141 | + $filename = Str::slug($filename).'.'.$extension; |
|
142 | 142 | |
143 | 143 | return $filename; |
144 | 144 | } |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | if ($file instanceof UploadedFile && !$file->isValid()) { |
155 | 155 | if ($file->getError() == UPLOAD_ERR_INI_SIZE) { |
156 | 156 | throw new FileTooBigException( |
157 | - 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. ' . |
|
158 | - 'upload_max_filesize: ' . (int)ini_get('upload_max_filesize') . 'MB, ' . |
|
159 | - 'post_max_size: ' . (int)(ini_get('post_max_size')) . 'MB' |
|
157 | + 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. '. |
|
158 | + 'upload_max_filesize: '.(int)ini_get('upload_max_filesize').'MB, '. |
|
159 | + 'post_max_size: '.(int)(ini_get('post_max_size')).'MB' |
|
160 | 160 | ); |
161 | 161 | } |
162 | 162 | } |
@@ -170,16 +170,16 @@ discard block |
||
170 | 170 | foreach ($files_by_type as $type => $files) { |
171 | 171 | foreach ($files as $locale => $_files) { |
172 | 172 | if (!in_array($locale, config('translatable.locales'))) { |
173 | - throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale [' . implode(',', config('translatable.locales', [])). ']. Instead [' . $locale . '] is given.'); |
|
173 | + throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale ['.implode(',', config('translatable.locales', [])).']. Instead ['.$locale.'] is given.'); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | if (!is_array($_files)) { |
177 | - throw new \InvalidArgumentException('A valid files entry should be an array of files, key with either [new, replace or delete]. Instead a ' . gettype($_files) . ' is given.'); |
|
177 | + throw new \InvalidArgumentException('A valid files entry should be an array of files, key with either [new, replace or delete]. Instead a '.gettype($_files).' is given.'); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | foreach ($_files as $action => $file) { |
181 | 181 | if (!in_array($action, $actions)) { |
182 | - throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead ' . $action . ' is given.'); |
|
182 | + throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead '.$action.' is given.'); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | // If no view has been created for this page collection, we try once again to fetch the content value if any. This will silently fail |
53 | 53 | // if no content value is present. We don't consider the 'content' attribute to be a default as we do for module. |
54 | - return $this->map(function ($item) { |
|
54 | + return $this->map(function($item) { |
|
55 | 55 | return ($this->viewParent && $item instanceof ViewableContract) |
56 | 56 | ? $item->setViewParent($this->viewParent)->renderView() |
57 | 57 | : ($item->content ?? ''); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | { |
85 | 85 | $currentPage = $currentPage ?? request()->get('page', 1); |
86 | 86 | $path = request()->path(); |
87 | - $items = array_slice($this->all(), ($currentPage - 1) * $perPage); |
|
87 | + $items = array_slice($this->all(), ($currentPage-1) * $perPage); |
|
88 | 88 | |
89 | 89 | return (new \Illuminate\Pagination\Paginator($items, $perPage ?? $this->paginateSetting('perPage', '12'), $currentPage))->setPath($path); |
90 | 90 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | { |
102 | 102 | $currentPage = $currentPage ?? request()->get('page', 1); |
103 | 103 | $path = '/'.request()->path(); |
104 | - $items = array_slice($this->all(), ($currentPage - 1) * $perPage, $perPage); |
|
104 | + $items = array_slice($this->all(), ($currentPage-1) * $perPage, $perPage); |
|
105 | 105 | |
106 | 106 | return (new \Illuminate\Pagination\LengthAwarePaginator($items, $this->paginateSetting('total', $this->count()), $perPage ?? $this->paginateSetting('perPage', '12'), $currentPage))->setPath($path); |
107 | 107 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | { |
40 | 40 | // Constraints |
41 | 41 | if (!isset($values['action'])) { |
42 | - throw new \InvalidArgumentException('Set reference array is missing required values for the "action" keys. Given: ' . print_r($values, true)); |
|
42 | + throw new \InvalidArgumentException('Set reference array is missing required values for the "action" keys. Given: '.print_r($values, true)); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | return new static( |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | { |
55 | 55 | $sets = config('thinktomorrow.chief.sets', []); |
56 | 56 | |
57 | - return collect($sets)->map(function ($set, $key) { |
|
57 | + return collect($sets)->map(function($set, $key) { |
|
58 | 58 | return SetReference::fromArray($key, $set); |
59 | 59 | }); |
60 | 60 | } |
61 | 61 | |
62 | 62 | public static function find($key): ?SetReference |
63 | 63 | { |
64 | - return static::all()->filter(function ($ref) use ($key) { |
|
64 | + return static::all()->filter(function($ref) use ($key) { |
|
65 | 65 | return $ref->key() == $key; |
66 | 66 | })->first(); |
67 | 67 | } |
@@ -78,13 +78,13 @@ discard block |
||
78 | 78 | |
79 | 79 | $this->validateAction($class, $method); |
80 | 80 | |
81 | - $result = call_user_func_array([app($class),$method], $this->parameters($class, $method, $parent)); |
|
81 | + $result = call_user_func_array([app($class), $method], $this->parameters($class, $method, $parent)); |
|
82 | 82 | |
83 | - if (! $result instanceof Set && $result instanceof Collection) { |
|
83 | + if (!$result instanceof Set && $result instanceof Collection) { |
|
84 | 84 | return new Set($result->all(), $this->key); |
85 | 85 | } |
86 | 86 | |
87 | - if (! $result instanceof Set && $result instanceof Paginator) { |
|
87 | + if (!$result instanceof Set && $result instanceof Paginator) { |
|
88 | 88 | return new Set($result->all(), $this->key, [ |
89 | 89 | 'paginate' => [ |
90 | 90 | 'total' => $result->total(), |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | |
153 | 153 | private static function validateAction($class, $method) |
154 | 154 | { |
155 | - if (! class_exists($class)) { |
|
155 | + if (!class_exists($class)) { |
|
156 | 156 | throw new \InvalidArgumentException('The class ['.$class.'] isn\'t a valid class reference or does not exist in the chief-settings.sets config entry.'); |
157 | 157 | } |
158 | 158 |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public static function onlineModels(bool $onlySingles = false, Model $ignoredModel = null): Collection |
41 | 41 | { |
42 | - $models = chiefMemoize('all-online-models', function () use ($onlySingles) { |
|
42 | + $models = chiefMemoize('all-online-models', function() use ($onlySingles) { |
|
43 | 43 | $builder = UrlRecord::whereNull('redirect_id') |
44 | 44 | ->select('model_type', 'model_id') |
45 | 45 | ->groupBy('model_type', 'model_id'); |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | $builder->where('model_type', 'singles'); |
49 | 49 | } |
50 | 50 | |
51 | - return $builder->get()->mapToGroups(function ($record) { |
|
51 | + return $builder->get()->mapToGroups(function($record) { |
|
52 | 52 | return [$record->model_type => $record->model_id]; |
53 | - })->map(function ($record, $key) { |
|
53 | + })->map(function($record, $key) { |
|
54 | 54 | return Morphables::instance($key)->find($record->toArray()); |
55 | - })->map->reject(function ($model) { |
|
55 | + })->map->reject(function($model) { |
|
56 | 56 | return is_null($model) || !$model->isPublished(); // Invalid references to archived or removed models where url record still exists. |
57 | 57 | })->flatten(); |
58 | 58 | }, [$onlySingles]); |
59 | 59 | |
60 | 60 | if ($ignoredModel) { |
61 | - $models = $models->reject(function ($model) use ($ignoredModel) { |
|
61 | + $models = $models->reject(function($model) use ($ignoredModel) { |
|
62 | 62 | return (get_class($model) === get_class($ignoredModel) && $model->id === $ignoredModel->id); |
63 | 63 | }); |
64 | 64 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Thinktomorrow\Chief\Fields\Types; |
6 | 6 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | return $this; |
41 | 41 | } |
42 | 42 | |
43 | - return 'files['. ($this->values['name'] ?? $this->key()).']'; |
|
43 | + return 'files['.($this->values['name'] ?? $this->key()).']'; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | public function sluggifyName() |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $images = []; |
59 | 59 | $locale = $locale ?? app()->getLocale(); |
60 | 60 | |
61 | - $assets = $model->assetRelation->where('pivot.type', $this->key())->filter(function ($asset) use ($locale) { |
|
61 | + $assets = $model->assetRelation->where('pivot.type', $this->key())->filter(function($asset) use ($locale) { |
|
62 | 62 | return $asset->pivot->locale == $locale; |
63 | 63 | })->sortBy('pivot.order'); |
64 | 64 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | DB::beginTransaction(); |
22 | 22 | |
23 | 23 | // For stateful transitions we will apply this deletion as a state |
24 | - if($model instanceof StatefulContract) { |
|
24 | + if ($model instanceof StatefulContract) { |
|
25 | 25 | (new PageState($model))->apply('delete'); |
26 | 26 | $model->save(); |
27 | 27 | } |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | Relation::deleteRelationsOf($model->getMorphClass(), $model->id); |
30 | 30 | |
31 | 31 | // Mark the slug as deleted to avoid any conflict with newly created modules with the same slug. |
32 | - if($model instanceof Module) { |
|
32 | + if ($model instanceof Module) { |
|
33 | 33 | $model->update([ |
34 | - 'slug' => $model->slug . $this->appendDeleteMarker(), |
|
34 | + 'slug' => $model->slug.$this->appendDeleteMarker(), |
|
35 | 35 | ]); |
36 | 36 | } |
37 | 37 | |
38 | - if($model instanceof ProvidesUrl){ |
|
38 | + if ($model instanceof ProvidesUrl) { |
|
39 | 39 | UrlRecord::getByModel($model)->each->delete(); |
40 | 40 | } |
41 | 41 | |
42 | - if($model instanceof Page){ |
|
42 | + if ($model instanceof Page) { |
|
43 | 43 | Module::where('page_id', $model->id)->delete(); |
44 | 44 | } |
45 | 45 | |
@@ -58,6 +58,6 @@ discard block |
||
58 | 58 | |
59 | 59 | private function appendDeleteMarker(): string |
60 | 60 | { |
61 | - return '_DELETED_' . time(); |
|
61 | + return '_DELETED_'.time(); |
|
62 | 62 | } |
63 | 63 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Thinktomorrow\Chief\States\Archivable; |
6 | 6 | |
@@ -13,6 +13,6 @@ discard block |
||
13 | 13 | { |
14 | 14 | public function apply(Builder $builder, Model $model) |
15 | 15 | { |
16 | - $builder->where('current_state','<>', PageState::ARCHIVED); |
|
16 | + $builder->where('current_state', '<>', PageState::ARCHIVED); |
|
17 | 17 | } |
18 | 18 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | { |
51 | 51 | $registrations = collect($this->register->filterByTag($tag)->all()); |
52 | 52 | |
53 | - return $registrations->map(function ($registration) { |
|
53 | + return $registrations->map(function($registration) { |
|
54 | 54 | return $this->instance($registration); |
55 | 55 | }); |
56 | 56 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | $registrations = collect($this->register->filterByTag($tag)->all()); |
67 | 67 | |
68 | - return $registrations->map(function ($registration) { |
|
68 | + return $registrations->map(function($registration) { |
|
69 | 69 | return $this->instance($registration)->details(); |
70 | 70 | }); |
71 | 71 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | //return array with group name and values |
77 | 77 | $grouped = []; |
78 | 78 | |
79 | - $managers = $managers->map(function (Manager $item) { |
|
79 | + $managers = $managers->map(function(Manager $item) { |
|
80 | 80 | return [ |
81 | 81 | 'id' => $item->details()->id, |
82 | 82 | 'group' => $item->details()->plural, |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | { |
91 | 91 | $registrations = collect($this->register->all()); |
92 | 92 | |
93 | - return $registrations->map(function ($registration) { |
|
93 | + return $registrations->map(function($registration) { |
|
94 | 94 | return $this->instance($registration); |
95 | 95 | }); |
96 | 96 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | { |
100 | 100 | $assistants = collect(); |
101 | 101 | |
102 | - foreach($this->all() as $manager) { |
|
102 | + foreach ($this->all() as $manager) { |
|
103 | 103 | $assistants = $assistants->merge($manager->assistants(false)); |
104 | 104 | } |
105 | 105 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | public function anyRegisteredByTag($tag) |
110 | 110 | { |
111 | - return ! empty($this->register->filterByTag($tag)->all()); |
|
111 | + return !empty($this->register->filterByTag($tag)->all()); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -13,10 +13,10 @@ |
||
13 | 13 | |
14 | 14 | public static function register($app) |
15 | 15 | { |
16 | - Route::get('testje', [static::class, 'archive']); |
|
17 | - Route::get('testje', [AssistantController, 'archive']); |
|
16 | + Route::get('testje', [static::class, 'archive']); |
|
17 | + Route::get('testje', [AssistantController, 'archive']); |
|
18 | 18 | |
19 | - // fetched manager |
|
19 | + // fetched manager |
|
20 | 20 | // propagate naar assistant::archive |
21 | 21 | } |
22 | 22 |