@@ -10,12 +10,12 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | 'partials' => [ |
| 12 | 12 | 'translatable' => [ |
| 13 | - 'create' => [], |
|
| 14 | - 'edit' => [], |
|
| 13 | + 'create' => [ ], |
|
| 14 | + 'edit' => [ ], |
|
| 15 | 15 | ], |
| 16 | 16 | 'normal' => [ |
| 17 | - 'create' => [], |
|
| 18 | - 'edit' => [], |
|
| 17 | + 'create' => [ ], |
|
| 18 | + 'edit' => [ ], |
|
| 19 | 19 | ], |
| 20 | 20 | ], |
| 21 | 21 | |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | class BlockTranslation extends Model |
| 9 | 9 | { |
| 10 | 10 | public $timestamps = false; |
| 11 | - protected $fillable = ['online', 'body']; |
|
| 11 | + protected $fillable = [ 'online', 'body' ]; |
|
| 12 | 12 | protected $table = 'block__blocks_translations'; |
| 13 | 13 | |
| 14 | 14 | public function getBodyAttribute($body) |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function allOnlineInLang($lang) |
| 59 | 59 | { |
| 60 | - return $this->model->whereHas('translations', function (Builder $q) use ($lang) { |
|
| 60 | + return $this->model->whereHas('translations', function(Builder $q) use ($lang) { |
|
| 61 | 61 | $q->where('locale', "$lang"); |
| 62 | 62 | $q->where('online', true); |
| 63 | 63 | })->with('translations')->orderBy('created_at', 'DESC')->get(); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | { |
| 73 | 73 | $lang = $this->getCurrentLocale(); |
| 74 | 74 | |
| 75 | - $block = $this->model->whereHas('translations', function (Builder $q) use ($lang) { |
|
| 75 | + $block = $this->model->whereHas('translations', function(Builder $q) use ($lang) { |
|
| 76 | 76 | $q->where('locale', "$lang"); |
| 77 | 77 | $q->where('online', true); |
| 78 | 78 | })->with('translations')->whereName($name)->first(); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | private function sluggify(array &$data) |
| 97 | 97 | { |
| 98 | - $data['name'] = $this->makeNameUnique($data['name']); |
|
| 98 | + $data[ 'name' ] = $this->makeNameUnique($data[ 'name' ]); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -111,20 +111,20 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | if ( |
| 113 | 113 | $this->isEmptyArray($list) || |
| 114 | - ! $this->isSlugInList($slug, $list) || |
|
| 114 | + !$this->isSlugInList($slug, $list) || |
|
| 115 | 115 | ($this->isForModel($list) && $this->slugIsInList($slug, $list)) |
| 116 | 116 | ) { |
| 117 | 117 | return $slug; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // map our list to keep only the increments |
| 121 | - $len = strlen($slug . '-'); |
|
| 121 | + $len = strlen($slug.'-'); |
|
| 122 | 122 | |
| 123 | - array_walk($list, function (&$value, $key) use ($len) { |
|
| 123 | + array_walk($list, function(&$value, $key) use ($len) { |
|
| 124 | 124 | $value = intval(substr($value, $len)); |
| 125 | 125 | }); |
| 126 | 126 | |
| 127 | - return $slug . '-' . $this->findHighestIncrement($list); |
|
| 127 | + return $slug.'-'.$this->findHighestIncrement($list); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | private function getExistingSlugs($slug) |
| 136 | 136 | { |
| 137 | - $query = $this->model->where('name', 'LIKE', $slug . '%'); |
|
| 137 | + $query = $this->model->where('name', 'LIKE', $slug.'%'); |
|
| 138 | 138 | |
| 139 | 139 | $list = $query->pluck('name', $this->model->getKeyName())->toArray(); |
| 140 | 140 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | private function slugIsInList($slug, array $list) |
| 182 | 182 | { |
| 183 | - return $list[$this->model->getKey()] === $slug; |
|
| 183 | + return $list[ $this->model->getKey() ] === $slug; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -3,10 +3,10 @@ |
||
| 3 | 3 | use Illuminate\Routing\Router; |
| 4 | 4 | |
| 5 | 5 | /** @var Router $router */ |
| 6 | -$router->bind('block', function ($id) { |
|
| 6 | +$router->bind('block', function($id) { |
|
| 7 | 7 | return app(\Modules\Block\Repositories\BlockRepository::class)->find($id); |
| 8 | 8 | }); |
| 9 | -$router->group(['prefix' => '/block'], function (Router $router) { |
|
| 9 | +$router->group([ 'prefix' => '/block' ], function(Router $router) { |
|
| 10 | 10 | $router->get('blocks', [ |
| 11 | 11 | 'as' => 'admin.block.block.index', |
| 12 | 12 | 'uses' => 'BlockController@index', |
@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | /** @test */ |
| 11 | 11 | public function it_can_change_final_content() |
| 12 | 12 | { |
| 13 | - Event::listen(BlockContentIsRendering::class, function (BlockContentIsRendering $event) { |
|
| 14 | - $event->setBody('<strong>' . $event->getOriginal() . '</strong>'); |
|
| 13 | + Event::listen(BlockContentIsRendering::class, function(BlockContentIsRendering $event) { |
|
| 14 | + $event->setBody('<strong>'.$event->getOriginal().'</strong>'); |
|
| 15 | 15 | }); |
| 16 | 16 | |
| 17 | - $block = $this->block->create(['name' => 'testBlock', 'en' => ['body' => 'My Block Body'], 'fr' => ['body' => 'lorem fr']]); |
|
| 17 | + $block = $this->block->create([ 'name' => 'testBlock', 'en' => [ 'body' => 'My Block Body' ], 'fr' => [ 'body' => 'lorem fr' ] ]); |
|
| 18 | 18 | |
| 19 | 19 | $this->assertEquals('<strong>My Block Body</strong>', $block->body); |
| 20 | 20 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** @test */ |
| 23 | 23 | public function it_doesnt_alter_content_if_no_listeners() |
| 24 | 24 | { |
| 25 | - $block = $this->block->create(['name' => 'testBlock', 'en' => ['body' => 'My Block Body'], 'fr' => ['body' => 'lorem fr']]); |
|
| 25 | + $block = $this->block->create([ 'name' => 'testBlock', 'en' => [ 'body' => 'My Block Body' ], 'fr' => [ 'body' => 'lorem fr' ] ]); |
|
| 26 | 26 | |
| 27 | 27 | $this->assertEquals('My Block Body', $block->body); |
| 28 | 28 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | /** @test */ |
| 17 | 17 | public function it_creates_blocks() |
| 18 | 18 | { |
| 19 | - $block = $this->block->create(['name' => 'testBlock', 'en' => ['body' => 'lorem en'], 'fr' => ['body' => 'lorem fr']]); |
|
| 19 | + $block = $this->block->create([ 'name' => 'testBlock', 'en' => [ 'body' => 'lorem en' ], 'fr' => [ 'body' => 'lorem fr' ] ]); |
|
| 20 | 20 | $blocks = $this->block->all(); |
| 21 | 21 | |
| 22 | 22 | $this->assertCount(1, $blocks); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | /** @test */ |
| 46 | 46 | public function it_gets_block_by_name() |
| 47 | 47 | { |
| 48 | - $this->block->create(['name' => 'testblock', 'en' => ['body' => 'lorem en', 'online' => true], 'fr' => ['body' => 'lorem fr', 'online' => true]]); |
|
| 48 | + $this->block->create([ 'name' => 'testblock', 'en' => [ 'body' => 'lorem en', 'online' => true ], 'fr' => [ 'body' => 'lorem fr', 'online' => true ] ]); |
|
| 49 | 49 | $this->createRandomBlock(true, true); |
| 50 | 50 | $this->createRandomBlock(true, true); |
| 51 | 51 | $this->createRandomBlock(true, true); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | /** @test */ |
| 59 | 59 | public function it_gets_block_by_name_if_online() |
| 60 | 60 | { |
| 61 | - $this->block->create(['name' => 'testBlock', 'en' => ['body' => 'lorem en', 'online' => true], 'fr' => ['body' => 'lorem fr', 'online' => false]]); |
|
| 61 | + $this->block->create([ 'name' => 'testBlock', 'en' => [ 'body' => 'lorem en', 'online' => true ], 'fr' => [ 'body' => 'lorem fr', 'online' => false ] ]); |
|
| 62 | 62 | $this->createRandomBlock(true, true); |
| 63 | 63 | $this->createRandomBlock(true, true); |
| 64 | 64 | $this->createRandomBlock(true, true); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | /** @test */ |
| 76 | 76 | public function it_gets_block_by_facade() |
| 77 | 77 | { |
| 78 | - $this->block->create(['name' => 'testblock', 'en' => ['body' => 'lorem en', 'online' => true], 'fr' => ['body' => 'lorem fr', 'online' => false]]); |
|
| 78 | + $this->block->create([ 'name' => 'testblock', 'en' => [ 'body' => 'lorem en', 'online' => true ], 'fr' => [ 'body' => 'lorem fr', 'online' => false ] ]); |
|
| 79 | 79 | $this->createRandomBlock(true, true); |
| 80 | 80 | $this->createRandomBlock(true, true); |
| 81 | 81 | |
@@ -87,15 +87,15 @@ discard block |
||
| 87 | 87 | /** @test */ |
| 88 | 88 | public function it_slugifies_the_name_property() |
| 89 | 89 | { |
| 90 | - $block = $this->block->create(['name' => 'test block', 'en' => ['body' => 'lorem en', 'online' => true], 'fr' => ['body' => 'lorem fr', 'online' => false]]); |
|
| 90 | + $block = $this->block->create([ 'name' => 'test block', 'en' => [ 'body' => 'lorem en', 'online' => true ], 'fr' => [ 'body' => 'lorem fr', 'online' => false ] ]); |
|
| 91 | 91 | |
| 92 | 92 | $this->assertEquals('test-block', $block->name); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | public function it_makes_name_unique() |
| 96 | 96 | { |
| 97 | - $this->block->create(['name' => 'test block']); |
|
| 98 | - $block = $this->block->create(['name' => 'test block']); |
|
| 97 | + $this->block->create([ 'name' => 'test block' ]); |
|
| 98 | + $block = $this->block->create([ 'name' => 'test block' ]); |
|
| 99 | 99 | |
| 100 | 100 | $this->assertEquals('test-block-1', $block->name); |
| 101 | 101 | } |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | /** @test */ |
| 104 | 104 | public function it_increments_name_if_not_unique() |
| 105 | 105 | { |
| 106 | - $this->block->create(['name' => 'test block']); |
|
| 107 | - $this->block->create(['name' => 'test block']); |
|
| 108 | - $block1 = $this->block->create(['name' => 'test block']); |
|
| 109 | - $block2 = $this->block->create(['name' => 'test block']); |
|
| 106 | + $this->block->create([ 'name' => 'test block' ]); |
|
| 107 | + $this->block->create([ 'name' => 'test block' ]); |
|
| 108 | + $block1 = $this->block->create([ 'name' => 'test block' ]); |
|
| 109 | + $block2 = $this->block->create([ 'name' => 'test block' ]); |
|
| 110 | 110 | |
| 111 | 111 | $this->assertEquals('test-block-2', $block1->name); |
| 112 | 112 | $this->assertEquals('test-block-3', $block2->name); |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | /** @test */ |
| 116 | 116 | public function it_updates_block_without_name_change() |
| 117 | 117 | { |
| 118 | - $block = $this->block->create(['name' => 'test block']); |
|
| 119 | - $this->block->update($block, ['name' => 'test-block']); |
|
| 118 | + $block = $this->block->create([ 'name' => 'test block' ]); |
|
| 119 | + $this->block->update($block, [ 'name' => 'test-block' ]); |
|
| 120 | 120 | |
| 121 | 121 | $this->assertEquals($block->name, 'test-block'); |
| 122 | 122 | } |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | /** @test */ |
| 125 | 125 | public function it_updates_block_with_name_change() |
| 126 | 126 | { |
| 127 | - $block = $this->block->create(['name' => 'test block']); |
|
| 128 | - $this->block->update($block, ['name' => 'my awesome block']); |
|
| 127 | + $block = $this->block->create([ 'name' => 'test block' ]); |
|
| 128 | + $this->block->update($block, [ 'name' => 'my awesome block' ]); |
|
| 129 | 129 | |
| 130 | 130 | $this->assertEquals($block->name, 'my-awesome-block'); |
| 131 | 131 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | $block = $this->createRandomBlock(); |
| 147 | 147 | |
| 148 | - Event::assertDispatched(BlockWasCreated::class, function ($e) use ($block) { |
|
| 148 | + Event::assertDispatched(BlockWasCreated::class, function($e) use ($block) { |
|
| 149 | 149 | return $e->block->name === $block->name; |
| 150 | 150 | }); |
| 151 | 151 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $block = $this->createRandomBlock(); |
| 159 | 159 | |
| 160 | - Event::assertDispatched(BlockIsCreating::class, function ($e) use ($block) { |
|
| 160 | + Event::assertDispatched(BlockIsCreating::class, function($e) use ($block) { |
|
| 161 | 161 | return $e->getAttribute('name') === $block->name; |
| 162 | 162 | }); |
| 163 | 163 | } |
@@ -165,15 +165,15 @@ discard block |
||
| 165 | 165 | /** @test */ |
| 166 | 166 | public function it_can_change_data_when_it_is_creating_event() |
| 167 | 167 | { |
| 168 | - Event::listen(BlockIsCreating::class, function (BlockIsCreating $event) { |
|
| 169 | - $event->setAttributes(['name' => 'awesome block']); |
|
| 168 | + Event::listen(BlockIsCreating::class, function(BlockIsCreating $event) { |
|
| 169 | + $event->setAttributes([ 'name' => 'awesome block' ]); |
|
| 170 | 170 | $event->setAttributes([ |
| 171 | - 'en' => ['body' => 'no more lorem! en'], |
|
| 172 | - 'fr' => ['body' => 'no more lorem! fr'], |
|
| 171 | + 'en' => [ 'body' => 'no more lorem! en' ], |
|
| 172 | + 'fr' => [ 'body' => 'no more lorem! fr' ], |
|
| 173 | 173 | ]); |
| 174 | 174 | }); |
| 175 | 175 | |
| 176 | - $block = $this->block->create(['name' => 'testBlock', 'en' => ['body' => 'lorem en'], 'fr' => ['body' => 'lorem fr']]); |
|
| 176 | + $block = $this->block->create([ 'name' => 'testBlock', 'en' => [ 'body' => 'lorem en' ], 'fr' => [ 'body' => 'lorem fr' ] ]); |
|
| 177 | 177 | |
| 178 | 178 | $this->assertEquals('awesome block', $block->name); |
| 179 | 179 | $this->assertEquals('no more lorem! en', $block->translate('en')->body); |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | Event::fake(); |
| 187 | 187 | |
| 188 | 188 | $block = $this->createRandomBlock(); |
| 189 | - $block = $this->block->update($block, ['name' => 'something else']); |
|
| 189 | + $block = $this->block->update($block, [ 'name' => 'something else' ]); |
|
| 190 | 190 | |
| 191 | - Event::assertDispatched(BlockWasUpdated::class, function ($e) use ($block) { |
|
| 191 | + Event::assertDispatched(BlockWasUpdated::class, function($e) use ($block) { |
|
| 192 | 192 | return $e->block->name === $block->name; |
| 193 | 193 | }); |
| 194 | 194 | } |
@@ -199,9 +199,9 @@ discard block |
||
| 199 | 199 | Event::fake(); |
| 200 | 200 | |
| 201 | 201 | $block = $this->createRandomBlock(); |
| 202 | - $block = $this->block->update($block, ['name' => 'something else']); |
|
| 202 | + $block = $this->block->update($block, [ 'name' => 'something else' ]); |
|
| 203 | 203 | |
| 204 | - Event::assertDispatched(BlockIsUpdating::class, function ($e) use ($block) { |
|
| 204 | + Event::assertDispatched(BlockIsUpdating::class, function($e) use ($block) { |
|
| 205 | 205 | return $e->getAttribute('name') === $block->name; |
| 206 | 206 | }); |
| 207 | 207 | } |
@@ -209,16 +209,16 @@ discard block |
||
| 209 | 209 | /** @test */ |
| 210 | 210 | public function it_can_change_data_when_it_is_updating_event() |
| 211 | 211 | { |
| 212 | - Event::listen(BlockIsUpdating::class, function (BlockIsUpdating $event) { |
|
| 213 | - $event->setAttributes(['name' => 'awesome block']); |
|
| 212 | + Event::listen(BlockIsUpdating::class, function(BlockIsUpdating $event) { |
|
| 213 | + $event->setAttributes([ 'name' => 'awesome block' ]); |
|
| 214 | 214 | $event->setAttributes([ |
| 215 | - 'en' => ['body' => 'no more lorem! en'], |
|
| 216 | - 'fr' => ['body' => 'no more lorem! fr'], |
|
| 215 | + 'en' => [ 'body' => 'no more lorem! en' ], |
|
| 216 | + 'fr' => [ 'body' => 'no more lorem! fr' ], |
|
| 217 | 217 | ]); |
| 218 | 218 | }); |
| 219 | 219 | |
| 220 | 220 | $block = $this->createRandomBlock(); |
| 221 | - $block = $this->block->update($block, ['name' => 'something else']); |
|
| 221 | + $block = $this->block->update($block, [ 'name' => 'something else' ]); |
|
| 222 | 222 | |
| 223 | 223 | $this->assertEquals('awesome block', $block->name); |
| 224 | 224 | $this->assertEquals('no more lorem! en', $block->translate('en')->body); |
@@ -9,7 +9,7 @@ |
||
| 9 | 9 | /** @test */ |
| 10 | 10 | public function it_links_global_facade_to_repository() |
| 11 | 11 | { |
| 12 | - $this->block->create(['name' => 'testBlock', 'en' => ['body' => 'lorem en'], 'fr' => ['body' => 'lorem fr']]); |
|
| 12 | + $this->block->create([ 'name' => 'testBlock', 'en' => [ 'body' => 'lorem en' ], 'fr' => [ 'body' => 'lorem fr' ] ]); |
|
| 13 | 13 | |
| 14 | 14 | $this->assertInstanceOf(Collection::class, \Block::all()); |
| 15 | 15 | } |
@@ -29,8 +29,8 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | public function extendWith(Menu $menu) |
| 31 | 31 | { |
| 32 | - $menu->group(trans('core::sidebar.content'), function (Group $group) { |
|
| 33 | - $group->item(trans('block::blocks.title.blocks'), function (Item $item) { |
|
| 32 | + $menu->group(trans('core::sidebar.content'), function(Group $group) { |
|
| 33 | + $group->item(trans('block::blocks.title.blocks'), function(Item $item) { |
|
| 34 | 34 | $item->authorize( |
| 35 | 35 | $this->auth->hasAccess('block.blocks.index') |
| 36 | 36 | ); |
@@ -22,11 +22,11 @@ discard block |
||
| 22 | 22 | public function allOnlineInLang($lang) |
| 23 | 23 | { |
| 24 | 24 | return $this->cache |
| 25 | - ->tags([$this->entityName, 'global']) |
|
| 25 | + ->tags([ $this->entityName, 'global' ]) |
|
| 26 | 26 | ->remember( |
| 27 | 27 | "{$this->locale}.{$this->entityName}.allOnlineInLang", |
| 28 | 28 | $this->cacheTime, |
| 29 | - function () use ($lang) { |
|
| 29 | + function() use ($lang) { |
|
| 30 | 30 | return $this->repository->allOnlineInLang($lang); |
| 31 | 31 | } |
| 32 | 32 | ); |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | public function get($name) |
| 41 | 41 | { |
| 42 | 42 | return $this->cache |
| 43 | - ->tags([$this->entityName, 'global']) |
|
| 43 | + ->tags([ $this->entityName, 'global' ]) |
|
| 44 | 44 | ->remember( |
| 45 | 45 | "{$this->locale}.{$this->entityName}.get.{$name}", |
| 46 | 46 | $this->cacheTime, |
| 47 | - function () use ($name) { |
|
| 47 | + function() use ($name) { |
|
| 48 | 48 | return $this->repository->get($name); |
| 49 | 49 | } |
| 50 | 50 | ); |