@@ -36,7 +36,7 @@ |
||
36 | 36 | $data = DB::table($table); |
37 | 37 | if($SQLCondition && is_callable($SQLCondition)) { |
38 | 38 | $data = call_user_func($SQLCondition, $data); |
39 | - }elseif ($SQLCondition && is_string($SQLCondition)) { |
|
39 | + } elseif ($SQLCondition && is_string($SQLCondition)) { |
|
40 | 40 | $data->whereRaw($SQLCondition); |
41 | 41 | } |
42 | 42 | $data = $data->get(); |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function optionsFromTable($table, $key_field, $display_field, $SQLCondition = null) { |
37 | 37 | |
38 | - if(strpos($table,"App\Models")!==false) { |
|
38 | + if (strpos($table, "App\Models") !== false) { |
|
39 | 39 | $table = new $table(); |
40 | 40 | $table = $table::$tableName; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $data = DB::table($table); |
44 | - if($SQLCondition && is_callable($SQLCondition)) { |
|
44 | + if ($SQLCondition && is_callable($SQLCondition)) { |
|
45 | 45 | $data = call_user_func($SQLCondition, $data); |
46 | 46 | }elseif ($SQLCondition && is_string($SQLCondition)) { |
47 | 47 | $data->whereRaw($SQLCondition); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $data = $data->get(); |
50 | 50 | $options = []; |
51 | 51 | foreach ($data as $d) { |
52 | - $options[ $d->$key_field ] = $d->$display_field; |
|
52 | + $options[$d->$key_field] = $d->$display_field; |
|
53 | 53 | } |
54 | 54 | $this->options($options); |
55 | 55 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | */ |
13 | 13 | public function up() |
14 | 14 | { |
15 | - Schema::create('cb_menus', function (Blueprint $table) { |
|
15 | + Schema::create('cb_menus', function(Blueprint $table) { |
|
16 | 16 | $table->increments("id"); |
17 | 17 | $table->string('name'); |
18 | 18 | $table->string("icon")->nullable(); |
@@ -36,7 +36,7 @@ |
||
36 | 36 | $data = DB::table($table); |
37 | 37 | if($SQLCondition && is_callable($SQLCondition)) { |
38 | 38 | $data = call_user_func($SQLCondition, $data); |
39 | - }elseif ($SQLCondition && is_string($SQLCondition)) { |
|
39 | + } elseif ($SQLCondition && is_string($SQLCondition)) { |
|
40 | 40 | $data->whereRaw($SQLCondition); |
41 | 41 | } |
42 | 42 | $data = $data->get(); |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | * @param $SQLCondition string|callable |
41 | 41 | */ |
42 | 42 | public function optionsFromTable($table, $key_field, $display_field, $SQLCondition = null) { |
43 | - if(strpos($table,"App\Models")!==false) { |
|
43 | + if (strpos($table, "App\Models") !== false) { |
|
44 | 44 | $table = new $table(); |
45 | 45 | $table = $table::$tableName; |
46 | 46 | } |
47 | 47 | |
48 | 48 | $data = DB::table($table); |
49 | - if($SQLCondition && is_callable($SQLCondition)) { |
|
49 | + if ($SQLCondition && is_callable($SQLCondition)) { |
|
50 | 50 | $data = call_user_func($SQLCondition, $data); |
51 | 51 | }elseif ($SQLCondition && is_string($SQLCondition)) { |
52 | 52 | $data->whereRaw($SQLCondition); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $data = $data->get(); |
55 | 55 | $options = []; |
56 | 56 | foreach ($data as $d) { |
57 | - $options[ $d->$key_field ] = $d->$display_field; |
|
57 | + $options[$d->$key_field] = $d->$display_field; |
|
58 | 58 | } |
59 | 59 | $this->options($options); |
60 | 60 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | { |
23 | 23 | if($column->getFormat()) { |
24 | 24 | return date($column->getFormat(), strtotime($row->{$column->getField()})); |
25 | - }else{ |
|
25 | + } else{ |
|
26 | 26 | return $row->{$column->getField()}; |
27 | 27 | } |
28 | 28 | } |
@@ -28,12 +28,12 @@ |
||
28 | 28 | |
29 | 29 | public function assignment($value, $column) |
30 | 30 | { |
31 | - if($column->getFormat()) { |
|
32 | - $date = date_create_from_format($column->getFormat(), $value); |
|
33 | - return $date ? $date->format('Y-m-d') : $value; |
|
34 | - } else { |
|
35 | - return $value; |
|
36 | - } |
|
31 | + if($column->getFormat()) { |
|
32 | + $date = date_create_from_format($column->getFormat(), $value); |
|
33 | + return $date ? $date->format('Y-m-d') : $value; |
|
34 | + } else { |
|
35 | + return $value; |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | public function detailRender($row, $column) |
@@ -19,16 +19,16 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public function indexRender($row, $column) |
21 | 21 | { |
22 | - if($column->getFormat()) { |
|
22 | + if ($column->getFormat()) { |
|
23 | 23 | return date($column->getFormat(), strtotime($row->{$column->getField()})); |
24 | - }else{ |
|
24 | + } else { |
|
25 | 25 | return $row->{$column->getField()}; |
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | 29 | public function assignment($value, $column) |
30 | 30 | { |
31 | - if($column->getFormat()) { |
|
31 | + if ($column->getFormat()) { |
|
32 | 32 | $date = date_create_from_format($column->getFormat(), $value); |
33 | 33 | return $date ? $date->format('Y-m-d') : $value; |
34 | 34 | } else { |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | { |
46 | 46 | $start = sanitizeXSS($value['start']); |
47 | 47 | $end = sanitizeXSS($value['end']); |
48 | - if($start && $end) { |
|
48 | + if ($start && $end) { |
|
49 | 49 | $start = date("Y-m-d", strtotime($start)); |
50 | 50 | $end = date("Y-m-d", strtotime($end)); |
51 | 51 | $query->whereBetween($column->getFilterColumn(), [$start, $end]); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace crocodicstudio\crudbooster\helpers; |
3 | 3 | |
4 | -class UserSession { |
|
4 | +class UserSession { |
|
5 | 5 | |
6 | 6 | public function user() |
7 | 7 | { |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | public function photo() |
22 | 22 | { |
23 | 23 | $user = $this->user(); |
24 | - return ($user->photo)?asset($user->photo):asset(dummyPhoto()); |
|
24 | + return ($user->photo) ?asset($user->photo) : asset(dummyPhoto()); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function roleName() |
28 | 28 | { |
29 | 29 | $user = $this->user(); |
30 | 30 | $role = cb()->find("cb_roles", $user->cb_roles_id); |
31 | - if($role) return $role->name; |
|
31 | + if ($role) return $role->name; |
|
32 | 32 | else return null; |
33 | 33 | } |
34 | 34 |
@@ -28,8 +28,11 @@ |
||
28 | 28 | { |
29 | 29 | $user = $this->user(); |
30 | 30 | $role = cb()->find("cb_roles", $user->cb_roles_id); |
31 | - if($role) return $role->name; |
|
32 | - else return null; |
|
31 | + if($role) { |
|
32 | + return $role->name; |
|
33 | + } else { |
|
34 | + return null; |
|
35 | + } |
|
33 | 36 | } |
34 | 37 | |
35 | 38 | public function roleId() |
@@ -2,7 +2,7 @@ |
||
2 | 2 | <?php /** @var \crocodicstudio\crudbooster\types\radio\RadioModel $column */ ?> |
3 | 3 | @foreach($column->getOptions() as $key=>$value) |
4 | 4 | <?php |
5 | - $columnValue = old($column->getName())?:($column->getDefaultValue())?:$column->getValue(); |
|
5 | + $columnValue = old($column->getName()) ?: ($column->getDefaultValue()) ?: $column->getValue(); |
|
6 | 6 | ?> |
7 | 7 | <div class="{{ $column->getDisabled()?"disabled":"" }}"> |
8 | 8 | <label class='radio-inline'> |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | public function assignment($value, $column) |
22 | 22 | { |
23 | - return @implode(";", request( $column->getName() )); |
|
23 | + return @implode(";", request($column->getName())); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** @var ColumnModel $column */ |
50 | 50 | if($data_row) { |
51 | 51 | $value = (isset($data_row->{$column->getField()}))?$data_row->{ $column->getField() }:null; |
52 | - }else{ |
|
52 | + } else{ |
|
53 | 53 | $value = request($column->getName()); |
54 | 54 | |
55 | 55 | if(!$value && $column->getDefaultValue()) { |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | foreach($column->getValue() as $key=>$val) { |
140 | 140 | $data[$key] = $val; |
141 | 141 | } |
142 | - }else{ |
|
142 | + } else{ |
|
143 | 143 | $data[$column->getField()] = $column->getValue(); |
144 | 144 | } |
145 | 145 | } |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | public function valueAssignment($data_row = null) { |
43 | 43 | foreach ($this->getColumns() as $index=>$column) { |
44 | 44 | |
45 | - if (! $column->getName()) { |
|
45 | + if (!$column->getName()) { |
|
46 | 46 | continue; |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** @var ColumnModel $column */ |
50 | - if($data_row) { |
|
51 | - $value = (isset($data_row->{$column->getField()}))?$data_row->{ $column->getField() }:null; |
|
52 | - }else{ |
|
50 | + if ($data_row) { |
|
51 | + $value = (isset($data_row->{$column->getField()})) ? $data_row->{ $column->getField() }:null; |
|
52 | + } else { |
|
53 | 53 | $value = request($column->getName()); |
54 | 54 | |
55 | - if(!$value && $column->getDefaultValue()) { |
|
55 | + if (!$value && $column->getDefaultValue()) { |
|
56 | 56 | $value = $column->getDefaultValue(); |
57 | 57 | } |
58 | 58 | |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | { |
69 | 69 | $data = $this->columns; |
70 | 70 | $newData = []; |
71 | - foreach($data as $i=>$item) { |
|
71 | + foreach ($data as $i=>$item) { |
|
72 | 72 | /** @var ColumnModel $item */ |
73 | - if($item->getShowIndex()) { |
|
73 | + if ($item->getShowIndex()) { |
|
74 | 74 | $newData[] = $item; |
75 | 75 | } |
76 | 76 | } |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | { |
82 | 82 | $data = $this->columns; |
83 | 83 | $newData = []; |
84 | - foreach($data as $i=>$item) { |
|
84 | + foreach ($data as $i=>$item) { |
|
85 | 85 | /** @var ColumnModel $item */ |
86 | - if($item->getShowAdd() || $item->getShowEdit()) { |
|
86 | + if ($item->getShowAdd() || $item->getShowEdit()) { |
|
87 | 87 | $newData[] = $item; |
88 | 88 | } |
89 | 89 | } |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | { |
95 | 95 | $data = $this->columns; |
96 | 96 | $newData = []; |
97 | - foreach($data as $i=>$item) { |
|
97 | + foreach ($data as $i=>$item) { |
|
98 | 98 | /** @var ColumnModel $item */ |
99 | - if($item->getShowEdit()) { |
|
99 | + if ($item->getShowEdit()) { |
|
100 | 100 | $newData[] = $item; |
101 | 101 | } |
102 | 102 | } |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | { |
108 | 108 | $data = $this->columns; |
109 | 109 | $newData = []; |
110 | - foreach($data as $i=>$item) { |
|
110 | + foreach ($data as $i=>$item) { |
|
111 | 111 | /** @var ColumnModel $item */ |
112 | - if($item->getShowAdd()) { |
|
112 | + if ($item->getShowAdd()) { |
|
113 | 113 | $newData[] = $item; |
114 | 114 | } |
115 | 115 | } |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | { |
121 | 121 | $data = $this->columns; |
122 | 122 | $newData = []; |
123 | - foreach($data as $i=>$item) { |
|
123 | + foreach ($data as $i=>$item) { |
|
124 | 124 | /** @var ColumnModel $item */ |
125 | - if($item->getFilterable()) { |
|
125 | + if ($item->getFilterable()) { |
|
126 | 126 | $newData[] = $item; |
127 | 127 | } |
128 | 128 | } |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | { |
134 | 134 | $data = $this->columns; |
135 | 135 | $newData = []; |
136 | - foreach($data as $i=>$item) { |
|
136 | + foreach ($data as $i=>$item) { |
|
137 | 137 | /** @var ColumnModel $item */ |
138 | - if($item->getShowDetail()) { |
|
138 | + if ($item->getShowDetail()) { |
|
139 | 139 | $newData[] = $item; |
140 | 140 | } |
141 | 141 | } |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | public function getAssignmentData() |
146 | 146 | { |
147 | 147 | $data = []; |
148 | - foreach($this->columns as $column) { |
|
148 | + foreach ($this->columns as $column) { |
|
149 | 149 | /** @var ColumnModel $column */ |
150 | 150 | |
151 | - if(is_array($column->getValue())) { |
|
152 | - foreach($column->getValue() as $key=>$val) { |
|
151 | + if (is_array($column->getValue())) { |
|
152 | + foreach ($column->getValue() as $key=>$val) { |
|
153 | 153 | $data[$key] = $val; |
154 | 154 | } |
155 | - }else{ |
|
155 | + } else { |
|
156 | 156 | $data[$column->getField()] = $column->getValue(); |
157 | 157 | } |
158 | 158 | } |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | public function removeColumn($label_or_name) |
163 | 163 | { |
164 | 164 | $data = $this->getColumns(); |
165 | - foreach($data as $i=>$d) |
|
165 | + foreach ($data as $i=>$d) |
|
166 | 166 | { |
167 | 167 | /** @var ColumnModel $d */ |
168 | - if($d->getLabel() == $label_or_name || $d->getName() == $label_or_name) { |
|
168 | + if ($d->getLabel() == $label_or_name || $d->getName() == $label_or_name) { |
|
169 | 169 | unset($data[$i]); |
170 | 170 | } |
171 | 171 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | public function getColumnNameOnly() |
176 | 176 | { |
177 | 177 | $result = []; |
178 | - foreach($this->columns as $column) { |
|
178 | + foreach ($this->columns as $column) { |
|
179 | 179 | /** @var ColumnModel $column */ |
180 | 180 | $result[] = $column->getName(); |
181 | 181 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | private function name($label, $name = null) |
20 | 20 | { |
21 | - return (!$name)?strtolower(slug($label,"_")):$name; |
|
21 | + return (!$name) ?strtolower(slug($label, "_")) : $name; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | $model->setShowAdd(true); |
40 | 40 | $model->setShowEdit(true); |
41 | 41 | $model->setShowDetail(true); |
42 | - $model->setIndexDisplayTransform(function ($value, $row) { return $value; }); |
|
43 | - $model->setDetailDisplayTransform(function ($value, $row) { return $value; }); |
|
42 | + $model->setIndexDisplayTransform(function($value, $row) { return $value; }); |
|
43 | + $model->setDetailDisplayTransform(function($value, $row) { return $value; }); |
|
44 | 44 | return $model; |
45 | 45 | } |
46 | 46 |