# HG changeset patch # User Luka Sitas # Date 1755650093 14400 # Node ID 8dd66802031045a5ed25e826f5ac2afcd7717956 # Parent 21439512ba69e8875f9b928a120d8b971d45a472 started converting too bootstrap, also better support for casts diff -r 21439512ba69 -r 8dd668020310 src/Generator/Model/stubs/model.stub --- a/src/Generator/Model/stubs/model.stub Wed Jun 18 09:04:59 2025 -0400 +++ b/src/Generator/Model/stubs/model.stub Tue Aug 19 20:34:53 2025 -0400 @@ -3,6 +3,7 @@ namespace {{ namespace }}; use Illuminate\Database\Eloquent\SoftDeletes; +use Wizard\Framework\Models\BaseModel; class {{ class }} extends BaseModel { @@ -25,6 +26,10 @@ # {{ atributeInsertPoint }} ]; + protected $casts = [ + # {{ castInsertPoint }} + ]; + protected $fillable = [ # {{ fillableInsertPoint }} ]; diff -r 21439512ba69 -r 8dd668020310 src/Generator/View/IndexViewGenerator.php --- a/src/Generator/View/IndexViewGenerator.php Wed Jun 18 09:04:59 2025 -0400 +++ b/src/Generator/View/IndexViewGenerator.php Tue Aug 19 20:34:53 2025 -0400 @@ -118,7 +118,7 @@ $replacements['{{value}}'] = '{{ $item->'.$name.'?->format(\'Y-m-d H:i\') ?? "" }}'; } //checkbox - elseif(in_array($type, ['tinyint'])) { + if(in_array($type, ['tinyint'])) { $replacements['{{valueClass}}'] .= ' text-center'; $replacements['{{value}}'] = '{{ $item->' . $name . ' ?? "0" }}'; } diff -r 21439512ba69 -r 8dd668020310 src/Generator/View/snippets/index/header.stub --- a/src/Generator/View/snippets/index/header.stub Wed Jun 18 09:04:59 2025 -0400 +++ b/src/Generator/View/snippets/index/header.stub Tue Aug 19 20:34:53 2025 -0400 @@ -1,1 +1,1 @@ -{{header}} +{{header}} diff -r 21439512ba69 -r 8dd668020310 src/Generator/View/snippets/input/date.stub --- a/src/Generator/View/snippets/input/date.stub Wed Jun 18 09:04:59 2025 -0400 +++ b/src/Generator/View/snippets/input/date.stub Tue Aug 19 20:34:53 2025 -0400 @@ -1,6 +1,6 @@ diff -r 21439512ba69 -r 8dd668020310 src/Generator/View/stubs/create_edit.stub --- a/src/Generator/View/stubs/create_edit.stub Wed Jun 18 09:04:59 2025 -0400 +++ b/src/Generator/View/stubs/create_edit.stub Tue Aug 19 20:34:53 2025 -0400 @@ -1,25 +1,25 @@ -

+

{{ isset($item) ? 'Edit' : 'Create' }} {{ ucfirst('{{ modelVariable }}') }}

-
-
-
-
- @csrf - @if(isset($item)) +
+
+
+ + @csrf + @if (isset($item)) @method('PUT') @endif {{ fieldsInsertPoint }} - -
- Back -
diff -r 21439512ba69 -r 8dd668020310 src/Generator/View/stubs/index.stub --- a/src/Generator/View/stubs/index.stub Wed Jun 18 09:04:59 2025 -0400 +++ b/src/Generator/View/stubs/index.stub Tue Aug 19 20:34:53 2025 -0400 @@ -1,50 +1,50 @@ -

+

All {{ Str::plural(ucfirst('{{ modelVariable }}')) }}

-
-
-
- - - - - {{ headerInsertPoint }} - - - - - @forelse ($items as $item) - - {{ valueInsertPoint }} - - - @empty - - - - @endforelse - -
Actions
-
- View - Edit - - @csrf - @method('DELETE') - - -
-
No {{ tableName }} found.
-
+
+
+
+ + + + + {{ headerInsertPoint }} + + + + + @forelse ($items as $item) + + {{ valueInsertPoint }} + + + @empty + + + + @endforelse + +
Actions
+
+ View + Edit +
+ @csrf + @method('DELETE') + +
+
+
No {{ tableName }} found.
+
diff -r 21439512ba69 -r 8dd668020310 src/Generator/View/stubs/show.stub --- a/src/Generator/View/stubs/show.stub Wed Jun 18 09:04:59 2025 -0400 +++ b/src/Generator/View/stubs/show.stub Tue Aug 19 20:34:53 2025 -0400 @@ -1,24 +1,24 @@ -

+

{{ ucfirst('{{ modelVariable }}') }} Details

-
-
-
-
+
+
+
+
@foreach($fields as $field) -
- {{ ucfirst($field) }}: - {{ $item->$field }} +
+ {{ ucfirst($field) }}: + {{ $item->$field }}
@endforeach
-
- Edit - Back +
+ Edit + Back
diff -r 21439512ba69 -r 8dd668020310 src/Replacer/TableReplacer.php --- a/src/Replacer/TableReplacer.php Wed Jun 18 09:04:59 2025 -0400 +++ b/src/Replacer/TableReplacer.php Tue Aug 19 20:34:53 2025 -0400 @@ -44,6 +44,30 @@ /** * Get a string representation of table attributes. */ + protected function getCasts(): string + { + $insert = ''; + foreach ($this->get_columns() as $column) { + if (in_array($column['name'], $this->columns_to_ignore)) { + continue; + } + $type = $column['type_name']; + //date + if(in_array($type, ['date'])) { + $insert .= sprintf("'%s' => 'date:Y-m-d',", $column['name'])."\n"; + } + //time + if(in_array($type, ['timestamp'])) { + $insert .= sprintf("'%s' => 'date:Y-m-d H:i',", $column['name'])."\n"; + } + } + + return $insert; + } + + /** + * Get a string representation of table attributes. + */ protected function getAttributes(): string { $insert = ''; @@ -112,6 +136,7 @@ return [ '// {{ valuesForCreation }}' => $this->getValuesForCreation(), '# {{ attributeInsertPoint }}' => $this->getAttributes(), + '# {{ castInsertPoint }}' => $this->getCasts(), '# {{ fillableInsertPoint }}' => $this->getFillable(), '// {{ valuesForValidation }}' => $this->getValuesForValidation(), ];