@@ -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\Pages; |
6 | 6 |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | |
61 | 61 | public function presentForParent(ActsAsParent $parent, Relation $relation): string |
62 | 62 | { |
63 | - return 'Dit is de relatie weergave van een pagina onder ' . $parent->id; |
|
63 | + return 'Dit is de relatie weergave van een pagina onder '.$parent->id; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | public function presentForChild(ActsAsChild $child, Relation $relation): string |
67 | 67 | { |
68 | - return 'Dit is de relatie weergave van een pagina als parent voor ' . $child->id; |
|
68 | + return 'Dit is de relatie weergave van een pagina als parent voor '.$child->id; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | public function getRelationId(): string |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | { |
100 | 100 | $collectionKey = (new static)->collectionKey(); |
101 | 101 | |
102 | - $names = (object) [ |
|
102 | + $names = (object)[ |
|
103 | 103 | 'key' => $collectionKey, |
104 | 104 | 'class' => static::class, |
105 | 105 | 'singular' => $collectionKey == 'statics' ? 'pagina' : ucfirst(str_singular($collectionKey)), |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | public function handle(string $collection, array $translations): Page |
16 | 16 | { |
17 | - try{ |
|
17 | + try { |
|
18 | 18 | DB::beginTransaction(); |
19 | 19 | |
20 | 20 | $page = Page::create(['collection' => $collection]); |
@@ -58,7 +58,7 @@ |
||
58 | 58 | public function scopeCollection($query, string $collection = null) |
59 | 59 | { |
60 | 60 | return $query->withoutGlobalScope(PageCollectionScope::class) |
61 | - ->where('collection', '=', $collection); |
|
61 | + ->where('collection', '=', $collection); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -16,18 +16,18 @@ discard block |
||
16 | 16 | public function collectionKey() |
17 | 17 | { |
18 | 18 | // Collection key is stored at db - if not we map it from our config |
19 | - if($this->collection) return $this->collection; |
|
19 | + if ($this->collection) return $this->collection; |
|
20 | 20 | |
21 | - $mapping = config('thinktomorrow.chief.collections',[]); |
|
21 | + $mapping = config('thinktomorrow.chief.collections', []); |
|
22 | 22 | |
23 | 23 | return false != ($key = array_search(static::class, $mapping)) ? $key : null; |
24 | 24 | } |
25 | 25 | |
26 | 26 | public static function fromCollectionKey(string $key = null) |
27 | 27 | { |
28 | - $mapping = config('thinktomorrow.chief.collections',[]); |
|
28 | + $mapping = config('thinktomorrow.chief.collections', []); |
|
29 | 29 | |
30 | - if(!isset($mapping[$key])){ |
|
30 | + if (!isset($mapping[$key])) { |
|
31 | 31 | throw new \DomainException('No corresponding class found for the collection key ['.$key.']. Make sure to add this to the [thinktomorrow.chief.collections] config array.'); |
32 | 32 | } |
33 | 33 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | { |
46 | 46 | $collectionKey = (new static)->collectionKey(); |
47 | 47 | |
48 | - $names = (object) [ |
|
48 | + $names = (object)[ |
|
49 | 49 | 'key' => $collectionKey, |
50 | 50 | 'class' => static::class, |
51 | 51 | 'singular' => ucfirst(str_singular($collectionKey)), |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | |
73 | 73 | public static function availableCollections(): Collection |
74 | 74 | { |
75 | - if(static::$availableCollections) return static::$availableCollections; |
|
75 | + if (static::$availableCollections) return static::$availableCollections; |
|
76 | 76 | |
77 | - $mapping = config('thinktomorrow.chief.collections',[]); |
|
77 | + $mapping = config('thinktomorrow.chief.collections', []); |
|
78 | 78 | |
79 | - $availableCollections = collect($mapping)->map(function($className){ |
|
79 | + $availableCollections = collect($mapping)->map(function($className) { |
|
80 | 80 | return $className::collectionDetails(); |
81 | 81 | }); |
82 | 82 |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | public function collectionKey() |
17 | 17 | { |
18 | 18 | // Collection key is stored at db - if not we map it from our config |
19 | - if($this->collection) return $this->collection; |
|
19 | + if($this->collection) { |
|
20 | + return $this->collection; |
|
21 | + } |
|
20 | 22 | |
21 | 23 | $mapping = config('thinktomorrow.chief.collections',[]); |
22 | 24 | |
@@ -72,7 +74,9 @@ discard block |
||
72 | 74 | |
73 | 75 | public static function availableCollections(): Collection |
74 | 76 | { |
75 | - if(static::$availableCollections) return static::$availableCollections; |
|
77 | + if(static::$availableCollections) { |
|
78 | + return static::$availableCollections; |
|
79 | + } |
|
76 | 80 | |
77 | 81 | $mapping = config('thinktomorrow.chief.collections',[]); |
78 | 82 |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | |
37 | 37 | // Set required paths |
38 | 38 | $this->dirs = ['base' => $this->settings['base_path'] ?? base_path()]; |
39 | - $this->dirs['model'] = $this->settings['model_path'] ?? $this->dirs['base'] . '/src'; |
|
40 | - $this->dirs['views'] = $this->settings['views_path'] ?? $this->dirs['base'] . '/resources/views'; |
|
41 | - $this->dirs['controller'] = $this->settings['controller_path'] ?? $this->dirs['base'] . '/app/Http/Controllers'; |
|
39 | + $this->dirs['model'] = $this->settings['model_path'] ?? $this->dirs['base'].'/src'; |
|
40 | + $this->dirs['views'] = $this->settings['views_path'] ?? $this->dirs['base'].'/resources/views'; |
|
41 | + $this->dirs['controller'] = $this->settings['controller_path'] ?? $this->dirs['base'].'/app/Http/Controllers'; |
|
42 | 42 | |
43 | - $this->files['routes'] = $this->settings['routes_file'] ?? $this->dirs['base'] . '/routes/web.php'; |
|
43 | + $this->files['routes'] = $this->settings['routes_file'] ?? $this->dirs['base'].'/routes/web.php'; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | public function handle() |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | private function publishModel() |
63 | 63 | { |
64 | 64 | $this->publishFile( |
65 | - __DIR__ . '/stubs/model.php.stub', |
|
66 | - $to = $this->dirs['model'] . '/' . ucfirst($this->plural) . '/' . ucfirst($this->singular) . '.php', |
|
65 | + __DIR__.'/stubs/model.php.stub', |
|
66 | + $to = $this->dirs['model'].'/'.ucfirst($this->plural).'/'.ucfirst($this->singular).'.php', |
|
67 | 67 | 'model' |
68 | 68 | ); |
69 | 69 | } |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | private function publishController() |
72 | 72 | { |
73 | 73 | $this->publishFile( |
74 | - __DIR__ . '/stubs/controller.php.stub', |
|
75 | - $to = $this->dirs['controller'] . '/' . ucfirst($this->plural) . '/' . ucfirst($this->singular) . '.php', |
|
74 | + __DIR__.'/stubs/controller.php.stub', |
|
75 | + $to = $this->dirs['controller'].'/'.ucfirst($this->plural).'/'.ucfirst($this->singular).'.php', |
|
76 | 76 | 'controller' |
77 | 77 | ); |
78 | 78 | } |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | private function modelTraits() |
112 | 112 | { |
113 | 113 | return [ |
114 | - '\\' . Publishable::class, |
|
115 | - '\\' . Sortable::class, |
|
114 | + '\\'.Publishable::class, |
|
115 | + '\\'.Sortable::class, |
|
116 | 116 | 'q' => 'Proceed.', |
117 | 117 | ]; |
118 | 118 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | protected function publishFile($from, $to, $type) |
128 | 128 | { |
129 | 129 | if ($this->filesystem->exists($to) && !$this->option('force')) { |
130 | - if (!$this->confirm('File [' . $to . '] already exists? Overwrite this file?')) { |
|
130 | + if (!$this->confirm('File ['.$to.'] already exists? Overwrite this file?')) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | $to = str_replace($this->dirs['base'], '', realpath($to)); |
168 | 168 | |
169 | - $this->line('<info>Copied ' . $type . '</info> <comment>[' . $from . ']</comment> <info>To</info> <comment>[' . $to . ']</comment>'); |
|
169 | + $this->line('<info>Copied '.$type.'</info> <comment>['.$from.']</comment> <info>To</info> <comment>['.$to.']</comment>'); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | protected function replacePlaceholders($content) |
@@ -185,16 +185,16 @@ discard block |
||
185 | 185 | private function generateImportStatements(): string |
186 | 186 | { |
187 | 187 | return collect(['Illuminate\Database\Eloquent\Model']) |
188 | - ->map(function ($statement) { |
|
189 | - return 'use ' . $statement . ";\n "; |
|
188 | + ->map(function($statement) { |
|
189 | + return 'use '.$statement.";\n "; |
|
190 | 190 | })->implode(''); |
191 | 191 | } |
192 | 192 | |
193 | 193 | private function generateTraitStatements(): string |
194 | 194 | { |
195 | 195 | return collect($this->chosenTraits) |
196 | - ->map(function ($statement) { |
|
197 | - return 'use ' . $statement . ";\n "; |
|
196 | + ->map(function($statement) { |
|
197 | + return 'use '.$statement.";\n "; |
|
198 | 198 | })->implode(''); |
199 | 199 | } |
200 | 200 | |
@@ -213,6 +213,6 @@ discard block |
||
213 | 213 | |
214 | 214 | // We make an estimated guess based on the project name. At Think Tomorrow, we |
215 | 215 | // have a src folder which is PSR-4 namespaced by the project name itself. |
216 | - return ucfirst(config('thinktomorrow.chief.name', 'App')).'\\'. ucfirst($this->plural); |
|
216 | + return ucfirst(config('thinktomorrow.chief.name', 'App')).'\\'.ucfirst($this->plural); |
|
217 | 217 | } |
218 | 218 | } |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('pages', function (Blueprint $table) { |
|
16 | + Schema::create('pages', function(Blueprint $table) { |
|
17 | 17 | $table->increments('id'); |
18 | - $table->string('collection',32)->index()->default('statics'); |
|
18 | + $table->string('collection', 32)->index()->default('statics'); |
|
19 | 19 | $table->boolean('published')->default(false); |
20 | 20 | $table->boolean('featured')->default(false); |
21 | 21 | $table->timestamp('archived_at')->default(null)->nullable(); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | $table->softDeletes(); |
25 | 25 | }); |
26 | 26 | |
27 | - Schema::create('page_translations', function (Blueprint $table) { |
|
27 | + Schema::create('page_translations', function(Blueprint $table) { |
|
28 | 28 | $table->increments('id'); |
29 | 29 | $table->integer('page_id')->unsigned(); |
30 | 30 | $table->string('locale'); |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * SPIRIT ROUTES |
6 | 6 | * ----------------------------------------------------------------- |
7 | 7 | */ |
8 | -Route::get('spirit/{section?}/{item?}', ['as' => 'spirit.index', 'uses' => function ($section = null, $item = null) { |
|
8 | +Route::get('spirit/{section?}/{item?}', ['as' => 'spirit.index', 'uses' => function($section = null, $item = null) { |
|
9 | 9 | if ($section && $item && view()->exists('chief::spirit.'.$section.'.'.$item)) { |
10 | 10 | return view('chief::spirit.'.$section.'.'.$item); |
11 | 11 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * ADMIN ROUTES |
39 | 39 | * ----------------------------------------------------------------- |
40 | 40 | */ |
41 | -Route::group(['prefix' => 'admin','middleware' => ['web', 'web-chief', 'auth:chief']], function () { |
|
41 | +Route::group(['prefix' => 'admin', 'middleware' => ['web', 'web-chief', 'auth:chief']], function() { |
|
42 | 42 | Route::get('logout', 'Thinktomorrow\Chief\App\Http\Controllers\Auth\LoginController@logout')->name('chief.back.logout'); |
43 | 43 | |
44 | 44 | Route::get('/', 'Thinktomorrow\Chief\App\Http\Controllers\Back\DashboardController@show')->name('chief.back.dashboard'); |
@@ -49,16 +49,16 @@ discard block |
||
49 | 49 | Route::put('password-prompt', 'Thinktomorrow\Chief\App\Http\Controllers\Auth\ChangePasswordController@update')->name('chief.back.password.update'); |
50 | 50 | |
51 | 51 | // Pages |
52 | - Route::get('pages/{collection}','Thinktomorrow\Chief\App\Http\Controllers\Back\PagesController@index')->name('chief.back.pages.index'); |
|
52 | + Route::get('pages/{collection}', 'Thinktomorrow\Chief\App\Http\Controllers\Back\PagesController@index')->name('chief.back.pages.index'); |
|
53 | 53 | Route::post('pages/{collection}', 'Thinktomorrow\Chief\App\Http\Controllers\Back\PagesController@store')->name('chief.back.pages.store'); |
54 | 54 | Route::get('pages/{collection}/create', 'Thinktomorrow\Chief\App\Http\Controllers\Back\PagesController@create')->name('chief.back.pages.create'); |
55 | 55 | Route::put('pages/{id}', 'Thinktomorrow\Chief\App\Http\Controllers\Back\PagesController@update')->name('chief.back.pages.update'); |
56 | - Route::get('pages/{id}', 'Thinktomorrow\Chief\App\Http\Controllers\Back\PagesController@show')->name('chief.back.pages.show')->where('id','[0-9]+'); |
|
56 | + Route::get('pages/{id}', 'Thinktomorrow\Chief\App\Http\Controllers\Back\PagesController@show')->name('chief.back.pages.show')->where('id', '[0-9]+'); |
|
57 | 57 | Route::get('pages/{id}/edit', 'Thinktomorrow\Chief\App\Http\Controllers\Back\PagesController@edit')->name('chief.back.pages.edit'); |
58 | 58 | Route::delete('pages/{id}', 'Thinktomorrow\Chief\App\Http\Controllers\Back\PagesController@destroy')->name('chief.back.pages.destroy'); |
59 | 59 | |
60 | 60 | // TODO: publish routing - below route does not work yet... |
61 | - Route::post('pages/publish','Thinktomorrow\Chief\App\Http\Controllers\Back\PagesController@publish')->name('chief.back.pages.publish'); |
|
61 | + Route::post('pages/publish', 'Thinktomorrow\Chief\App\Http\Controllers\Back\PagesController@publish')->name('chief.back.pages.publish'); |
|
62 | 62 | |
63 | 63 | Route::get('media', 'Thinktomorrow\Chief\App\Http\Controllers\Back\MediaLibraryController@library')->name('media.library'); |
64 | 64 | Route::get('media-modal', 'Thinktomorrow\Chief\App\Http\Controllers\Back\MediaLibraryController@mediaModal')->name('media.modal'); |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | |
70 | 70 | Route::post('page/{id}/upload', 'Thinktomorrow\Chief\App\Http\Controllers\Back\PagesController@upload')->name('page.upload'); |
71 | 71 | |
72 | - Route::get('/settings', ['as' => 'chief.back.settings.index','uses' => Thinktomorrow\Chief\App\Http\Controllers\Back\System\SettingsController::class.'@show']); |
|
72 | + Route::get('/settings', ['as' => 'chief.back.settings.index', 'uses' => Thinktomorrow\Chief\App\Http\Controllers\Back\System\SettingsController::class.'@show']); |
|
73 | 73 | |
74 | - Route::post('notes/publish', ['as' => 'notes.publish','uses' => Thinktomorrow\Chief\App\Http\Controllers\Back\NoteController::class.'@publish']); |
|
74 | + Route::post('notes/publish', ['as' => 'notes.publish', 'uses' => Thinktomorrow\Chief\App\Http\Controllers\Back\NoteController::class.'@publish']); |
|
75 | 75 | Route::resource('notes', Thinktomorrow\Chief\App\Http\Controllers\Back\NoteController::class); |
76 | 76 | |
77 | 77 | // YOUR PROFILE MANAGEMENT |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | * ----------------------------------------------------------------- |
122 | 122 | */ |
123 | 123 | // Developer access |
124 | - Route::get('translations/lines/create', ['middleware' => 'auth.superadmin', 'as' => 'squanto.lines.create','uses' => '\Thinktomorrow\Squanto\Manager\Http\Controllers\LineController@create']); |
|
125 | - Route::delete('translations/lines/{id}', ['middleware' => 'auth.superadmin', 'as' => 'squanto.lines.destroy','uses' => '\Thinktomorrow\Squanto\Manager\Http\Controllers\LineController@destroy']); |
|
126 | - Route::get('translations/lines/{id}/edit', ['middleware' => 'auth.superadmin', 'as' => 'squanto.lines.edit','uses' => '\Thinktomorrow\Squanto\Manager\Http\Controllers\LineController@edit']); |
|
127 | - Route::put('translations/lines/{id}', ['middleware' => 'auth.superadmin', 'as' => 'squanto.lines.update','uses' => '\Thinktomorrow\Squanto\Manager\Http\Controllers\LineController@update']); |
|
128 | - Route::post('translations/lines', ['middleware' => 'auth.superadmin', 'as' => 'squanto.lines.store','uses' => '\Thinktomorrow\Squanto\Manager\Http\Controllers\LineController@store']); |
|
124 | + Route::get('translations/lines/create', ['middleware' => 'auth.superadmin', 'as' => 'squanto.lines.create', 'uses' => '\Thinktomorrow\Squanto\Manager\Http\Controllers\LineController@create']); |
|
125 | + Route::delete('translations/lines/{id}', ['middleware' => 'auth.superadmin', 'as' => 'squanto.lines.destroy', 'uses' => '\Thinktomorrow\Squanto\Manager\Http\Controllers\LineController@destroy']); |
|
126 | + Route::get('translations/lines/{id}/edit', ['middleware' => 'auth.superadmin', 'as' => 'squanto.lines.edit', 'uses' => '\Thinktomorrow\Squanto\Manager\Http\Controllers\LineController@edit']); |
|
127 | + Route::put('translations/lines/{id}', ['middleware' => 'auth.superadmin', 'as' => 'squanto.lines.update', 'uses' => '\Thinktomorrow\Squanto\Manager\Http\Controllers\LineController@update']); |
|
128 | + Route::post('translations/lines', ['middleware' => 'auth.superadmin', 'as' => 'squanto.lines.store', 'uses' => '\Thinktomorrow\Squanto\Manager\Http\Controllers\LineController@store']); |
|
129 | 129 | |
130 | 130 | // Client access |
131 | - Route::get('translations/{id}/edit', ['as' => 'squanto.edit','uses' => '\Thinktomorrow\Squanto\Manager\Http\Controllers\TranslationController@edit']); |
|
132 | - Route::put('translations/{id}', ['as' => 'squanto.update','uses' => '\Thinktomorrow\Squanto\Manager\Http\Controllers\TranslationController@update']); |
|
133 | - Route::get('translations', ['as' => 'squanto.index','uses' => 'Thinktomorrow\Chief\App\Http\Controllers\Back\TranslationController@index']); |
|
131 | + Route::get('translations/{id}/edit', ['as' => 'squanto.edit', 'uses' => '\Thinktomorrow\Squanto\Manager\Http\Controllers\TranslationController@edit']); |
|
132 | + Route::put('translations/{id}', ['as' => 'squanto.update', 'uses' => '\Thinktomorrow\Squanto\Manager\Http\Controllers\TranslationController@update']); |
|
133 | + Route::get('translations', ['as' => 'squanto.index', 'uses' => 'Thinktomorrow\Chief\App\Http\Controllers\Back\TranslationController@index']); |
|
134 | 134 | }); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | { |
55 | 55 | $page = app(CreatePage::class)->handle($collection, $request->trans); |
56 | 56 | |
57 | - return redirect()->route('chief.back.pages.index',$page->collectionKey())->with('messages.success', $page->title . ' is aangemaakt'); |
|
57 | + return redirect()->route('chief.back.pages.index', $page->collectionKey())->with('messages.success', $page->title.' is aangemaakt'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | { |
89 | 89 | $page = app(UpdatePage::class)->handle($id, $request->trans, $request->relations); |
90 | 90 | |
91 | - return redirect()->route('chief.back.pages.index', $page->collectionKey())->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $page->title . '" werd aangepast'); |
|
91 | + return redirect()->route('chief.back.pages.index', $page->collectionKey())->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$page->title.'" werd aangepast'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |