Completed
Branch master (fa3d71)
by Vojta
02:14
created
Plugin.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
                 'icon' => 'icon-building-o',
50 50
                 'url' => Backend::url('vojtasvoboda/locationtown/towns'),
51 51
                 'order' => 500,
52
-                'permissions' => ['vojtasvoboda.locationtown.*'],
52
+                'permissions' => [ 'vojtasvoboda.locationtown.*' ],
53 53
             ],
54 54
         ];
55 55
     }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         $this->app->bind('locationtowns', 'VojtaSvoboda\LocationTown\Models\Town');
60 60
 
61 61
         State::extend(function($model) {
62
-            $model->hasMany['towns'] = 'VojtaSvoboda\LocationTown\Models\Town';
62
+            $model->hasMany[ 'towns' ] = 'VojtaSvoboda\LocationTown\Models\Town';
63 63
         });
64 64
 
65 65
         // Add location towns to sitemap
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -71,13 +71,15 @@
 block discarded – undo
71 71
         });
72 72
 
73 73
         Event::listen('pages.menuitem.getTypeInfo', function($type) {
74
-            if ($type == 'location-town' || $type == 'all-location-towns')
75
-                return Town::getMenuTypeInfo($type);
74
+            if ($type == 'location-town' || $type == 'all-location-towns') {
75
+                            return Town::getMenuTypeInfo($type);
76
+            }
76 77
         });
77 78
 
78 79
         Event::listen('pages.menuitem.resolveItem', function($type, $item, $url, $theme) {
79
-            if ($type == 'location-town' || $type == 'all-location-towns')
80
-                return Town::resolveMenuItem($item, $url, $theme);
80
+            if ($type == 'location-town' || $type == 'all-location-towns') {
81
+                            return Town::resolveMenuItem($item, $url, $theme);
82
+            }
81 83
         });
82 84
     }
83 85
 }
Please login to merge, or discard this patch.
components/Town.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 
29 29
     public function onRun()
30 30
     {
31
-        $this->page['town'] = $this->loadTown();
31
+        $this->page[ 'town' ] = $this->loadTown();
32 32
     }
33 33
 
34 34
     protected function loadTown()
Please login to merge, or discard this patch.
components/Towns.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -59,19 +59,19 @@
 block discarded – undo
59 59
     public function onRun()
60 60
     {
61 61
         // init params
62
-        $this->page['pageParam'] = $this->paramName('pageNumber');
63
-        $this->page['noTownsMessage'] = $this->property('noTownsMessage');
64
-        $this->townPage = $this->page['townPage'] = $this->property('townPage');
62
+        $this->page[ 'pageParam' ] = $this->paramName('pageNumber');
63
+        $this->page[ 'noTownsMessage' ] = $this->property('noTownsMessage');
64
+        $this->townPage = $this->page[ 'townPage' ] = $this->property('townPage');
65 65
 
66 66
         // load towns
67
-        $this->towns = $this->page['towns'] = $this->listTowns();
67
+        $this->towns = $this->page[ 'towns' ] = $this->listTowns();
68 68
 
69 69
         // if the page number is not valid, redirect
70 70
         if ($pageNumberParam = $this->paramName('pageNumber')) {
71 71
             $currentPage = $this->property('pageNumber');
72 72
 
73 73
             if ($currentPage > ($lastPage = $this->towns->lastPage()) && $currentPage > 1) {
74
-                return Redirect::to($this->currentPageUrl([$pageNumberParam => $lastPage]));
74
+                return Redirect::to($this->currentPageUrl([ $pageNumberParam => $lastPage ]));
75 75
             }
76 76
         }
77 77
     }
Please login to merge, or discard this patch.
models/Town.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -19,15 +19,15 @@  discard block
 block discarded – undo
19 19
         'is_enabled' => 'boolean'
20 20
     ];
21 21
 
22
-    protected $fillable = ['name', 'slug', 'description', 'is_enabled'];
22
+    protected $fillable = [ 'name', 'slug', 'description', 'is_enabled' ];
23 23
 
24
-    protected $dates = ['created_at', 'updated_at', 'deleted_at'];
24
+    protected $dates = [ 'created_at', 'updated_at', 'deleted_at' ];
25 25
 
26 26
     public $belongsTo = [
27 27
         'state' => 'RainLab\Location\Models\State'
28 28
     ];
29 29
 
30
-    public function findOneBySlug($slug, $params = [])
30
+    public function findOneBySlug($slug, $params = [ ])
31 31
     {
32 32
         $params += [
33 33
             'slug' => $slug
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public static function getMenuTypeInfo($type)
70 70
     {
71
-        $result = [];
71
+        $result = [ ];
72 72
 
73 73
         if ($type == 'location-town') {
74 74
 
75
-            $references = [];
75
+            $references = [ ];
76 76
             $towns = self::orderBy('name')->get();
77 77
             foreach ($towns as $town) {
78 78
                 $town->url = $town->slug;
79
-                $references[$town->id] = $town->name;
79
+                $references[ $town->id ] = $town->name;
80 80
             }
81 81
 
82 82
             $result = [
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
             $state = $town->state;
116 116
             $stateCode = $state->code;
117 117
 
118
-            $result = [];
119
-            $result['url'] = URL::to('/kontakty/' . $stateCode . '/' . $town->slug);
120
-            $result['isActive'] = false;
121
-            $result['mtime'] = $town->updated_at;
118
+            $result = [ ];
119
+            $result[ 'url' ] = URL::to('/kontakty/' . $stateCode . '/' . $town->slug);
120
+            $result[ 'isActive' ] = false;
121
+            $result[ 'mtime' ] = $town->updated_at;
122 122
         }
123 123
         elseif ($item->type == 'all-location-towns') {
124 124
             $result = [
125
-                'items' => []
125
+                'items' => [ ]
126 126
             ];
127 127
 
128 128
             $towns = self::orderBy('name')->get();
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
                     'isActive' => false,
137 137
                 ];
138 138
 
139
-                $result['items'][] = $townItem;
139
+                $result[ 'items' ][ ] = $townItem;
140 140
             }
141 141
         }
142 142
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,8 +119,7 @@
 block discarded – undo
119 119
             $result['url'] = URL::to('/kontakty/' . $stateCode . '/' . $town->slug);
120 120
             $result['isActive'] = false;
121 121
             $result['mtime'] = $town->updated_at;
122
-        }
123
-        elseif ($item->type == 'all-location-towns') {
122
+        } elseif ($item->type == 'all-location-towns') {
124 123
             $result = [
125 124
                 'items' => []
126 125
             ];
Please login to merge, or discard this patch.
updates/create_towns_table.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
             $table->engine = 'InnoDB';
16 16
             $table->increments('id');
17 17
 
18
-            if ( $this->isPluginActive('RainLab.Location') ) {
18
+            if ($this->isPluginActive('RainLab.Location')) {
19 19
                 $table->integer('state_id')->unsigned()->nullable();
20 20
                 $table->foreign('state_id')->references('id')->on('rainlab_location_states')->onDelete('set null');
21 21
             }
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
     public function down()
34 34
     {
35
-        Schema::table($this->table_name, function ($table) {
35
+        Schema::table($this->table_name, function($table) {
36 36
             $table->dropForeign('vojtasvoboda_locationtown_towns_state_id_foreign');
37 37
             $table->dropIndex('vojtasvoboda_locationtown_towns_state_id_foreign');
38 38
             $table->dropIndex('vojtasvoboda_locationtown_towns_slug_index');
Please login to merge, or discard this patch.