@@ -42,7 +42,7 @@ public function build()
4242 $ this ->fields = $ cached ['fields ' ];
4343 $ this ->files = $ cached ['files ' ];
4444 $ this ->names ();
45- $ template = (array ) $ this ->loadTemplate ();
45+ $ template = (array )$ this ->loadTemplate ();
4646 $ template = $ this ->buildParts ($ template );
4747 $ this ->publish ($ template );
4848 }
@@ -56,7 +56,7 @@ public function buildCustom($name)
5656 2 => ''
5757 ];
5858 $ this ->names ();
59- $ template = (array ) $ this ->loadTemplate ();
59+ $ template = (array )$ this ->loadTemplate ();
6060 $ this ->publishCustom ($ template );
6161
6262 }
@@ -141,7 +141,7 @@ private function buildTable()
141141 foreach ($ this ->fields as $ field ) {
142142 // Check if there is no duplication for radio and checkbox.
143143 // Password fields are excluded from the table too.
144- if (!in_array ($ field ->title , $ used )
144+ if (! in_array ($ field ->title , $ used )
145145 && $ field ->type != 'password '
146146 && $ field ->type != 'textarea '
147147 && $ field ->show == 1
@@ -173,12 +173,17 @@ private function buildEditForm()
173173 foreach ($ this ->fields as $ field ) {
174174 $ title = $ field ->label ;
175175 $ label = $ field ->title ;
176- if (in_array ($ field ->validation , $ this ->starred ) && $ field ->type != 'password ' && $ field ->type != 'file ' && $ field ->type != 'photo ' ) {
176+ if (in_array ($ field ->validation ,
177+ $ this ->starred ) && $ field ->type != 'password ' && $ field ->type != 'file ' && $ field ->type != 'photo '
178+ ) {
177179 $ title .= '* ' ;
178180 }
179181 if ($ field ->type == 'relationship ' ) {
180182 $ label = $ field ->relationship_name . '_id ' ;
181183 }
184+ if ($ field ->type == 'checkbox ' ) {
185+ $ field ->default = '$ ' . $ this ->model . '-> ' . $ label . ' == 1 ' ;
186+ }
182187 $ temp = file_get_contents (__DIR__ . DIRECTORY_SEPARATOR . '.. ' . DIRECTORY_SEPARATOR . 'Templates ' . DIRECTORY_SEPARATOR . 'fields ' . DIRECTORY_SEPARATOR . $ field ->type );
183188 $ temp = str_replace ([
184189 'old( \'$LABEL$ \') ' ,
@@ -195,7 +200,9 @@ private function buildEditForm()
195200 'old( \'$LABEL$ \',$ ' . $ this ->resource . '-> ' . $ label . ') ' ,
196201 $ label ,
197202 $ title ,
198- $ field ->value != '' ? ', " ' . $ field ->value . '" ' : '' ,
203+ $ field ->type != 'radio ' ?
204+ $ field ->value != '' ? ', " ' . $ field ->value . '" ' : ''
205+ : "' $ field ->value ' " ,
199206 $ field ->default ,
200207 '$ ' . $ field ->relationship_name ,
201208 $ field ->texteditor == 1 ? ' ckeditor ' : '' ,
@@ -237,7 +244,9 @@ private function buildCreateForm()
237244 ], [
238245 $ key ,
239246 $ title ,
240- $ field ->value != '' ? ', ' . $ field ->value : '' ,
247+ $ field ->type != 'radio ' ?
248+ $ field ->value != '' ? ', ' . $ field ->value : ''
249+ : "' $ field ->value ' " ,
241250 $ field ->default ,
242251 '$ ' . $ field ->relationship_name ,
243252 $ field ->texteditor == 1 ? ' ckeditor ' : '' ,
@@ -283,7 +292,7 @@ private function helper($value)
283292 */
284293 private function publish ($ template )
285294 {
286- if (!file_exists (base_path ('resources ' . DIRECTORY_SEPARATOR . 'views ' . DIRECTORY_SEPARATOR . 'admin ' . DIRECTORY_SEPARATOR . $ this ->path ))) {
295+ if (! file_exists (base_path ('resources ' . DIRECTORY_SEPARATOR . 'views ' . DIRECTORY_SEPARATOR . 'admin ' . DIRECTORY_SEPARATOR . $ this ->path ))) {
287296 mkdir (base_path ('resources ' . DIRECTORY_SEPARATOR . 'views ' . DIRECTORY_SEPARATOR . 'admin ' . DIRECTORY_SEPARATOR . $ this ->path ));
288297 chmod (base_path ('resources ' . DIRECTORY_SEPARATOR . 'views ' . DIRECTORY_SEPARATOR . 'admin ' ), 0777 );
289298 }
@@ -297,7 +306,7 @@ private function publish($template)
297306
298307 private function publishCustom ($ template )
299308 {
300- if (!file_exists (base_path ('resources ' . DIRECTORY_SEPARATOR . 'views ' . DIRECTORY_SEPARATOR . 'admin ' . DIRECTORY_SEPARATOR . $ this ->path ))) {
309+ if (! file_exists (base_path ('resources ' . DIRECTORY_SEPARATOR . 'views ' . DIRECTORY_SEPARATOR . 'admin ' . DIRECTORY_SEPARATOR . $ this ->path ))) {
301310 mkdir (base_path ('resources ' . DIRECTORY_SEPARATOR . 'views ' . DIRECTORY_SEPARATOR . 'admin ' . DIRECTORY_SEPARATOR . $ this ->path ));
302311 chmod (base_path ('resources ' . DIRECTORY_SEPARATOR . 'views ' . DIRECTORY_SEPARATOR . 'admin ' ), 0777 );
303312 }
0 commit comments