Skip to content

Commit ecb6515

Browse files
committed
=Fix couple bugs with the layouts. Also, fixes a label issue when creating views from existing database
1 parent 5ad199e commit ecb6515

15 files changed

+113
-68
lines changed

config/codegenerator.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
'templates_path' => base_path('resources/codegenerator-templates'),
3434

35-
3635
/*
3736
|--------------------------------------------------------------------------
3837
| Array of templetes that should be generated with Laravel-Collective
@@ -47,8 +46,6 @@
4746
'default-collective'
4847
],
4948

50-
51-
5249
/*
5350
|--------------------------------------------------------------------------
5451
| The default path of where the uploaded files lives!

src/CodeGeneratorServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public function boot()
2222
{
2323
$this->publishes([
2424
__DIR__ . '/../config/codegenerator.php' => config_path('codegenerator.php'),
25-
], 'config');
25+
], 'default');
2626

2727
$this->publishes([
2828
__DIR__ . '/templates/' => base_path('resources\\codegenerator-templates'),
29-
], 'default-template');
29+
], 'default');
3030

3131
$this->publishes([
3232
__DIR__ . '/templates/' => base_path('resources\\codegenerator-templates'),

src/DatabaseParsers/MysqlParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
2-
namespace CrestApps\CodeGenerator\DatabaseParser;
2+
namespace CrestApps\CodeGenerator\DatabaseParsers;
33

4-
use CrestApps\CodeGenerator\DatabaseParser\ParserBase;
4+
use CrestApps\CodeGenerator\DatabaseParsers\ParserBase;
55
use CrestApps\CodeGenerator\Support\Field;
66
use DB;
77

src/DatabaseParsers/ParserBase.php

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
2-
namespace CrestApps\CodeGenerator\DatabaseParser;
2+
namespace CrestApps\CodeGenerator\DatabaseParsers;
33

44
use CrestApps\CodeGenerator\Support\Field;
55
use CrestApps\CodeGenerator\Support\FieldOptimizer;
6+
67
use Exception;
78
use App;
89
use DB;
@@ -230,6 +231,7 @@ protected function setDefault(Field & $field, $default)
230231
*/
231232
protected function setLabel(Field & $field, $name)
232233
{
234+
233235
$field->addLabel( $this->getLabelName($name), $this->tableName, true, $this->locale);
234236

235237
return $this;
@@ -301,25 +303,6 @@ protected function dataTypeMap()
301303
return config('codegenerator.eloquent_type_to_method');
302304
}
303305

304-
/**
305-
* Set the unsiged flag for a giving field.
306-
*
307-
* @param CrestApps\CodeGenerator\Support\Field $field
308-
* @param string $type
309-
*
310-
* @return $this
311-
*/
312-
protected function setUnsigned(Field & $field, $type)
313-
{
314-
if(strpos($type, 'unsigned') !== false)
315-
{
316-
$field->isUnsigned = true;
317-
$field->validationRules[] = sprintf('min:%s', 0);
318-
}
319-
320-
return $this;
321-
}
322-
323306
/**
324307
* Set the column comment for a giving field.
325308
*

src/HtmlGenerators/HtmlGeneratorBase.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,10 +800,9 @@ protected function getTranslatedTitle(Label $label, $raw = false)
800800
*/
801801
protected function getTitle(Label $label, $raw = false)
802802
{
803-
804803
if(!$label->isPlain)
805804
{
806-
return $this->getTitleTranslation($label, $raw);
805+
return $this->getTranslatedTitle($label, $raw);
807806
}
808807

809808
return $this->getPlainTitle($label, $raw);

src/HtmlGenerators/StandardHtml.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,22 @@ protected function getMultipleRawOptionValue($name, $value)
231231

232232
return sprintf("in_array(%s, old('%s', isset(\$%s) ? \$%s->%s : []))", $valueString, $name, $modelName, $modelName, $name);
233233
}
234+
235+
/**
236+
* Creates html label.
237+
*
238+
* @param string $name
239+
* @param CrestApps\CodeGenerator\Support\Label $label
240+
*
241+
* @return string
242+
*/
243+
protected function getLabelElement($name, Label $label)
244+
{
245+
$labelStub = $this->getStubContent('form-label-field.blade', $this->template);
246+
247+
$this->replaceFieldName($labelStub, $name)
248+
->replaceFieldTitle($labelStub, $this->getTitle($label, true));
249+
250+
return $labelStub;
251+
}
234252
}

src/commands/CreateLanguageCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function handle()
5555

5656
$languages = $this->getLanguageItems($fields);
5757

58+
5859
foreach ($languages as $language => $labels)
5960
{
6061
$fileFullName = $this->getLocalePath($language) . $input->fileName . '.php';

src/commands/CreateModelCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CreateModelCommand extends GeneratorCommand
1818
*/
1919
protected $signature = 'create:model
2020
{model-name : The name of the model.}
21-
{--table= : The name of the table.}
21+
{--table-name= : The name of the table.}
2222
{--fillable= : The exact string to put in the fillable property of the model.}
2323
{--relationships= : The relationships for the model.}
2424
{--primary-key=id : The name of the primary key.}
@@ -150,7 +150,7 @@ protected function getFillablefields(array $fields)
150150
*/
151151
protected function getCommandInput()
152152
{
153-
$table = trim($this->option('table')) ?: strtolower(str_plural(trim($this->argument('model-name'))));
153+
$table = trim($this->option('table-name')) ?: strtolower(str_plural(trim($this->argument('model-name'))));
154154
$fillable = trim($this->option('fillable'));
155155
$primaryKey = trim($this->option('primary-key'));
156156
$relationships = !empty(trim($this->option('relationships'))) ? explode(',', trim($this->option('relationships'))) : [];

src/commands/CreateResourceCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CreateResourceCommand extends Command
2727
{--models-per-page=25 : The amount of models per page for index pages.}
2828
{--lang-file-name= : The languages file name to put the labels in.}
2929
{--with-form-request : This will extract the validation into a request form class.}
30-
{--table= : The name of the table.}
30+
{--table-name= : The name of the table.}
3131
{--fillable= : The exact string to put in the fillable property of the model.}
3232
{--primary-key=id : The name of the primary key.}
3333
{--with-soft-delete : Enables softdelete future should be enable in the model.}
@@ -236,7 +236,7 @@ protected function createModel($input)
236236
$this->call('create:model',
237237
[
238238
'model-name' => $input->modelName,
239-
'--table' => $input->table,
239+
'--table-name' => $input->table,
240240
'--fillable' => $input->fillable,
241241
'--relationships' => $input->relationships,
242242
'--primary-key' => $input->primaryKey,
@@ -274,7 +274,7 @@ protected function getCommandInput()
274274
$withoutMigration = $this->option('without-migration');
275275
$force = $this->option('force');
276276
$modelDirectory = trim($this->option('model-directory'));
277-
$table = trim($this->option('table')) ?: $modelNamePlural;
277+
$table = trim($this->option('table-name')) ?: $modelNamePlural;
278278
$fillable = trim($this->option('fillable'));
279279
$primaryKey = trim($this->option('primary-key'));
280280
$relationships = trim($this->option('relationships'));

src/templates/default-collective/index.blade.stub

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
<div class="panel panel-default">
1818

19-
20-
2119
<div class="panel-heading clearfix">
2220

2321
<span class="pull-left">
@@ -33,14 +31,13 @@
3331
</div>
3432

3533
</div>
36-
3734

38-
<div class="panel-body">
3935
@if(count(${{modelNamePlural}}) == 0)
40-
<div class="alert alert-warning text-center">
41-
<p>There are no records!</p>
36+
<div class="panel-body text-center">
37+
<h4>There are no records!</h4>
4238
</div>
4339
@else
40+
<div class="panel-body panel-body-with-table">
4441
<div class="table-responsive">
4542

4643
<table class="table table-striped">
@@ -82,12 +79,15 @@
8279
</tbody>
8380
</table>
8481

85-
<div class="pagination-wrapper">
86-
{!! ${{modelNamePlural}}->render() !!}
87-
</div>
88-
8982
</div>
90-
@endif
83+
9184
</div>
85+
86+
<div class="panel-footer">
87+
{!! ${{modelNamePlural}}->render() !!}
88+
</div>
89+
90+
@endif
91+
9292
</div>
9393
@endsection

0 commit comments

Comments
 (0)