Completed
Push — master ( a459d7...ce6f95 )
by Roberts
14s queued 11s
created
src/Admin/Grid/Column.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * @param string $name
62 62
      * @param string $label
63 63
      */
64
-    public function __construct( $name = null, $label = null )
64
+    public function __construct($name = null, $label = null)
65 65
     {
66 66
         $this->name = $name;
67 67
         $this->label = $label;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      * @param Grid $grid
96 96
      * @return Column
97 97
      */
98
-    public function setGrid( Grid $grid )
98
+    public function setGrid(Grid $grid)
99 99
     {
100 100
         $this->grid = $grid;
101 101
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      * @param Closure $callable
107 107
      * @return Column
108 108
      */
109
-    public function display( Closure $callable )
109
+    public function display(Closure $callable)
110 110
     {
111 111
         $this->displayer = $callable;
112 112
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      * @param bool $isSortable
118 118
      * @return Column
119 119
      */
120
-    public function sortable( $isSortable = true )
120
+    public function sortable($isSortable = true)
121 121
     {
122 122
         $this->sortable = $isSortable;
123 123
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      * @param bool $isSearchable
129 129
      * @return Column
130 130
      */
131
-    public function searchable( $isSearchable = true )
131
+    public function searchable($isSearchable = true)
132 132
     {
133 133
         $this->searchable = $isSearchable;
134 134
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      */
141 141
     public function isSortable()
142 142
     {
143
-        return $this->sortable && empty( $this->relationName );
143
+        return $this->sortable && empty($this->relationName);
144 144
     }
145 145
 
146 146
     /**
@@ -156,79 +156,79 @@  discard block
 block discarded – undo
156 156
      * @param $string
157 157
      * @return QueryBuilder
158 158
      */
159
-    public function searchConditions( QueryBuilder $query, $string )
159
+    public function searchConditions(QueryBuilder $query, $string)
160 160
     {
161
-        if( $this->relationName )
161
+        if ($this->relationName)
162 162
         {
163
-            return $query->orWhereHas( $this->relationName, function( QueryBuilder $query ) use ( $string )
163
+            return $query->orWhereHas($this->relationName, function(QueryBuilder $query) use ($string)
164 164
             {
165
-                $query->where( $this->relationColumn, 'like', "%$string%" );
165
+                $query->where($this->relationColumn, 'like', "%$string%");
166 166
             } );
167 167
         }
168 168
 
169
-        return $query->where( $this->getName(), 'like', "%$string%", 'OR' );
169
+        return $query->where($this->getName(), 'like', "%$string%", 'OR');
170 170
     }
171 171
 
172 172
     /**
173 173
      * @param Model $model
174 174
      * @return mixed
175 175
      */
176
-    protected function getValue( Model $model )
176
+    protected function getValue(Model $model)
177 177
     {
178
-        if( $this->relationName )
178
+        if ($this->relationName)
179 179
         {
180
-            if ( $this->relationName === 'translations' )
180
+            if ($this->relationName === 'translations')
181 181
             {
182
-                $translation = $model->getTranslation( null, true );
182
+                $translation = $model->getTranslation(null, true);
183 183
 
184
-                if ( !$translation )
184
+                if (!$translation)
185 185
                 {
186 186
                     return null;
187 187
                 }
188 188
 
189
-                return $translation->getAttribute( $this->relationColumn );
189
+                return $translation->getAttribute($this->relationColumn);
190 190
             }
191 191
 
192
-            $relation = $model->getAttribute( $this->relationName );
192
+            $relation = $model->getAttribute($this->relationName);
193 193
 
194
-            return ( $relation instanceof Relation )
195
-                ? $relation->getAttribute( $this->relationColumn )
194
+            return ($relation instanceof Relation)
195
+                ? $relation->getAttribute($this->relationColumn)
196 196
                 : $relation;
197 197
         }
198 198
 
199
-        return $model->getAttribute( $this->getName() );
199
+        return $model->getAttribute($this->getName());
200 200
     }
201 201
 
202 202
     /**
203 203
      * @param Model $model
204 204
      * @return Element
205 205
      */
206
-    public function callDisplayCallback( Model $model )
206
+    public function callDisplayCallback(Model $model)
207 207
     {
208
-        $value = $this->getValue( $model );
208
+        $value = $this->getValue($model);
209 209
 
210
-        if( $this->displayer === null )
210
+        if ($this->displayer === null)
211 211
         {
212 212
             $value = (string) $value;
213 213
 
214
-            if( $this->grid->hasTool( 'create' ) )
214
+            if ($this->grid->hasTool('create'))
215 215
             {
216
-                return Html::link( $value )->addAttributes( [
217
-                    'href' => $this->grid->getModule()->url( 'edit', [ $model->getKey() ] )
218
-                ] );
216
+                return Html::link($value)->addAttributes([
217
+                    'href' => $this->grid->getModule()->url('edit', [ $model->getKey() ])
218
+                ]);
219 219
             }
220 220
 
221
-            return Html::span( $value );
221
+            return Html::span($value);
222 222
         }
223 223
 
224
-        return call_user_func_array( $this->displayer, [ $value, $this, $model ] );
224
+        return call_user_func_array($this->displayer, [ $value, $this, $model ]);
225 225
     }
226 226
 
227 227
     /**
228 228
      * @param $relationName
229 229
      * @param $relationColumn
230 230
      */
231
-    public function setRelation( $relationName, $relationColumn )
231
+    public function setRelation($relationName, $relationColumn)
232 232
     {
233 233
         $this->relationName = $relationName;
234 234
         $this->relationColumn = $relationColumn;
Please login to merge, or discard this patch.
src/Http/Controllers/Admin/UsersController.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -37,61 +37,61 @@  discard block
 block discarded – undo
37 37
      * @return Form
38 38
      * @throws \InvalidArgumentException
39 39
      */
40
-    protected function form( Model $model )
40
+    protected function form(Model $model)
41 41
     {
42
-        $form = $this->module()->form( $model, function ( Form $form ) use ( $model )
42
+        $form = $this->module()->form($model, function(Form $form) use ($model)
43 43
         {
44
-            $form->addField( new Text( 'first_name' ) )->rules('required');
45
-            $form->addField( new Text( 'last_name' ) )->rules('required');
46
-            $form->addField( new Text( 'email' ) )->rules('required|unique:admin_users,email,' . $model->getKey());
47
-            $form->addField( new Password( 'password' ) )->rules('min:6|' . ( $model->exists ? 'nullable' : 'required' ));
48
-            $form->addField( new Boolean( 'active' ) )->setValue( Activation::completed( $model ) );
49
-            $form->addField( new BelongsToMany( 'roles' ) );
44
+            $form->addField(new Text('first_name'))->rules('required');
45
+            $form->addField(new Text('last_name'))->rules('required');
46
+            $form->addField(new Text('email'))->rules('required|unique:admin_users,email,' . $model->getKey());
47
+            $form->addField(new Password('password'))->rules('min:6|' . ($model->exists ? 'nullable' : 'required'));
48
+            $form->addField(new Boolean('active'))->setValue(Activation::completed($model));
49
+            $form->addField(new BelongsToMany('roles'));
50 50
         } );
51 51
 
52
-        $form->on( 'delete.before', function ( Form $form )
52
+        $form->on('delete.before', function(Form $form)
53 53
         {
54
-            if( Sentinel::getUser()->getKey() === $form->getModel()->getKey() )
54
+            if (Sentinel::getUser()->getKey() === $form->getModel()->getKey())
55 55
             {
56
-                throw new \InvalidArgumentException( 'You cannot remove yourself!' );
56
+                throw new \InvalidArgumentException('You cannot remove yourself!');
57 57
             }
58 58
         } );
59 59
 
60
-        $form->addEventListener('create.before', function() use ( $model )
60
+        $form->addEventListener('create.before', function() use ($model)
61 61
         {
62
-            unset( $model->active );
62
+            unset($model->active);
63 63
         } );
64 64
 
65
-        $form->addEventListener( 'update.before', function( Request $request ) use ( $model )
65
+        $form->addEventListener('update.before', function(Request $request) use ($model)
66 66
         {
67
-            if( $model->exists && !$request->has( 'resource.password' ) )
67
+            if ($model->exists && !$request->has('resource.password'))
68 68
             {
69
-                $parameters = $request->except( [ 'resource.password' ] );
69
+                $parameters = $request->except([ 'resource.password' ]);
70 70
 
71
-                $request->request->replace( $parameters );
71
+                $request->request->replace($parameters);
72 72
             }
73 73
         } );
74 74
 
75
-        $form->addEventListeners( [ 'update.before', 'create.after' ], function( Request $request ) use ( $model )
75
+        $form->addEventListeners([ 'update.before', 'create.after' ], function(Request $request) use ($model)
76 76
         {
77
-            unset( $model->active );
77
+            unset($model->active);
78 78
 
79
-            $active = $request->input( 'resource.active' );
79
+            $active = $request->input('resource.active');
80 80
 
81
-            if( $active && Activation::completed( $model ) )
81
+            if ($active && Activation::completed($model))
82 82
             {
83 83
                 return;
84 84
             }
85 85
 
86
-            if( $active )
86
+            if ($active)
87 87
             {
88
-                $activation = Activation::create( $model );
88
+                $activation = Activation::create($model);
89 89
 
90
-                Activation::complete( $model, array_get( $activation, 'code' ) );
90
+                Activation::complete($model, array_get($activation, 'code'));
91 91
             }
92 92
             else
93 93
             {
94
-                Activation::remove( $model );
94
+                Activation::remove($model);
95 95
             }
96 96
         } );
97 97
 
@@ -103,33 +103,33 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function grid()
105 105
     {
106
-        return $this->module()->grid( $this->resource(), function ( Grid $grid )
106
+        return $this->module()->grid($this->resource(), function(Grid $grid)
107 107
         {
108
-            $grid->column( 'email', 'avatar' )
109
-                ->display( function ( $value )
108
+            $grid->column('email', 'avatar')
109
+                ->display(function($value)
110 110
                 {
111 111
                     return Html::span(
112
-                        Html::image()->addAttributes( [
113
-                            'src' => '//www.gravatar.com/avatar/' . md5( $value ) . '?d=retro',
112
+                        Html::image()->addAttributes([
113
+                            'src' => '//www.gravatar.com/avatar/' . md5($value) . '?d=retro',
114 114
                             'width' => 32,
115 115
                             'alt' => $value,
116
-                        ] )
116
+                        ])
117 117
                     );
118 118
                 } );
119
-            $grid->column( 'email' )->sortable();
120
-            $grid->column( 'first_name' );
121
-            $grid->column( 'last_name' );
122
-            $grid->column( 'roles.name' )
123
-                ->display( function( Collection $value )
119
+            $grid->column('email')->sortable();
120
+            $grid->column('first_name');
121
+            $grid->column('last_name');
122
+            $grid->column('roles.name')
123
+                ->display(function(Collection $value)
124 124
                 {
125 125
                     return Html::ul(
126
-                        $value->map( function( $role )
126
+                        $value->map(function($role)
127 127
                         {
128
-                            return Html::li( (string) $role );
128
+                            return Html::li((string) $role);
129 129
                         } )->toArray()
130 130
                     );
131 131
                 } );
132
-            $grid->column( 'last_login' );
132
+            $grid->column('last_login');
133 133
         } );
134 134
     }
135 135
 
Please login to merge, or discard this patch.