diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d851bdb
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/vendor/
+/.idea/
+composer.lock
\ No newline at end of file
diff --git a/README.md b/README.md
index b66cb47..c6fb3c5 100644
--- a/README.md
+++ b/README.md
@@ -21,9 +21,9 @@ If you find this project useful, please consider giving it a star⭐. It helps m
``` composer require mrdebug/crudgen --dev ```
-2\. If you don't use Laravel Collective Form package in your project, install it:
+2\. If you don't use Spatie's HTML package in your project, install it:
-``` composer require laravelcollective/html ```
+``` composer require spatie/laravel-html ```
(Note: This step is not required if you don't need views.)
diff --git a/composer.json b/composer.json
index 168e5c7..62b2e41 100644
--- a/composer.json
+++ b/composer.json
@@ -25,7 +25,8 @@
],
"require":
{
- "php": ">=8.0.0"
+ "php": ">=8.0.0",
+ "spatie/laravel-html": "^3.4"
},
"autoload":
{
diff --git a/src/Services/MakeViewsService.php b/src/Services/MakeViewsService.php
index b206806..263bd9f 100644
--- a/src/Services/MakeViewsService.php
+++ b/src/Services/MakeViewsService.php
@@ -78,7 +78,7 @@ public function findAndReplaceIndexViewPlaceholderColumns($columns, $templateVie
$column = $type[0];
// our placeholders
- $thIndex .=str_repeat("\t", 4)."
".trim($column)." | \n";
+ $thIndex .=str_repeat("\t", 4)."".trim($column)." | \n";
if($column == $columnInSearch)
$indexView .=str_repeat("\t", 5).'{!! $this->search ? $this->highlightTitle(DummyCreateVariableSing$->'.$columnInSearch.') : DummyCreateVariableSing$->'.$columnInSearch.' !!} | '."\n";
@@ -123,11 +123,16 @@ public function findAndReplaceCreateViewPlaceholderColumns($columns, $templateVi
$sql_type = (count($type)==2) ? $type[1] : 'string';
$column = $type[0];
$typeHtml = $this->getHtmlType($sql_type);
+ $number_types = ['decimal', 'float', 'double'];
// our placeholders
$formCreate .=str_repeat("\t", 2).''."\n";
- $formCreate .=str_repeat("\t", 3).'{{ Form::label(\''.trim($column).'\', \''.ucfirst(trim($column)).'\', [\'class\'=>\'form-label\']) }}'."\n";
- $formCreate .=str_repeat("\t", 3).'{{ Form::'.$typeHtml.'(\''.trim($column).'\', null, array(\'class\' => \'form-control\')) }}'."\n";
+ $formCreate .=str_repeat("\t", 3).'{{ html()->label(\''.ucfirst(trim($column)).'\', \''.trim($column).'\')->class(\'form-label\') }}'."\n";
+
+ $formCreate .=str_repeat("\t", 3).'{{ html()->'.$typeHtml.'(name: \''.trim($column).'\'';
+ if(in_array($sql_type, $number_types))
+ $formCreate .=", step: .000001";
+ $formCreate .=")->class('form-control') }}\n";
$formCreate .=str_repeat("\t", 2).'
'."\n";
}
@@ -160,8 +165,8 @@ public function findAndReplaceEditViewPlaceholderColumns($columns, $templateView
// our placeholders
$formEdit .=str_repeat("\t", 2).''."\n";
- $formEdit .=str_repeat("\t", 3).'{{ Form::label(\''.trim($column).'\', \''.ucfirst(trim($column)).'\', [\'class\'=>\'form-label\']) }}'."\n";
- $formEdit .=str_repeat("\t", 3).'{{ Form::'.$typeHtml.'(\''.trim($column).'\', null, array(\'class\' => \'form-control\')) }}'."\n";
+ $formEdit .=str_repeat("\t", 3).'{{ html()->label(\''.ucfirst(trim($column)).'\', \''.trim($column).'\') }}'."\n";
+ $formEdit .=str_repeat("\t", 3).'{{ html()->'.$typeHtml.'(\''.trim($column).'\', null }}'."\n";
$formEdit .=str_repeat("\t", 2).'
'."\n";
}
@@ -195,7 +200,11 @@ private function getHtmlType($sql_type)
[
'string' => 'text',
'text' => 'textarea',
- 'integer' => 'text'
+ 'integer' => 'number',
+ 'float' => 'number',
+ 'double' => 'number',
+ 'decimal' => 'number',
+ 'bool' => 'checkbox'
];
return (isset($conversion[$sql_type]) ? $conversion[$sql_type] : 'string');
}
diff --git a/src/stubs/commentable/views/comment-block.stub b/src/stubs/commentable/views/comment-block.stub
index 3f1e238..0123a42 100644
--- a/src/stubs/commentable/views/comment-block.stub
+++ b/src/stubs/commentable/views/comment-block.stub
@@ -1,18 +1,18 @@
-{!! Form::open(['route' => ['{{route_comment}}.store', {{parent_variable}}->id]]) !!}
+{!! html()->form(route('{{route_comment}}.store', {parent_variable}}->id))->open() !!}
- {{ Form::label('comment', 'Comment', ['class'=>'form-label']) }}
- {{ Form::textarea('comment', null, array('class' => 'form-control')) }}
+ {{ html()->label('Comment', 'comment')->class('form-label)' }}
+ {{ html()->textarea()('comment')->class('form-control) }}
- {{ Form::submit('Create', array('class' => 'btn btn-primary')) }}
-{{ Form::close() }}
+ {{ html()->submit('Create')->class('btn btn-primary') }}
+{{ html()->form()->close() }}
@foreach({{parent_variable}}->{{name_relationship}} as $comment)
- {!! Form::open(['method' => 'DELETE','route' => ['{{route_comment}}.destroy', {{comment_variable}}->id]]) !!}
- {!! Form::submit('❌', ['class' => 'btn btn-sm']) !!}
- {!! Form::close() !!}
+ {!! html()->form('DELETE', route('{{route_comment}}.destroy', {{comment_variable}}->id))->open() !!}
+ {!! html()->submit('❌')->class('btn btn-sm') !!}
+ {!! html()->form()->close() !!}
diff --git a/src/stubs/default-theme/create.stub b/src/stubs/default-theme/create.stub
index 3b5f288..03d0949 100644
--- a/src/stubs/default-theme/create.stub
+++ b/src/stubs/default-theme/create.stub
@@ -10,13 +10,10 @@
@endif
- {!! Form::open(['route' => 'DummyVariable.store']) !!}
+ {{ html()->form('POST', route('DummyVariable.store') )->open() }}
+ DummyFormCreate
+ {{ html()->submit('Create')->class('btn btn-primary') }}
+ {{ html()->form()->close() }}
-DummyFormCreate
- {{ Form::submit('Create', array('class' => 'btn btn-primary')) }}
-
- {{ Form::close() }}
-
-
-@stop
\ No newline at end of file
+@stop
diff --git a/src/stubs/default-theme/edit.stub b/src/stubs/default-theme/edit.stub
index 45ade21..d7c9f7e 100644
--- a/src/stubs/default-theme/edit.stub
+++ b/src/stubs/default-theme/edit.stub
@@ -10,10 +10,8 @@
@endif
- {{ Form::model(DummyCreateVariableSing$, array('route' => array('DummyVariable.update', DummyCreateVariableSing$->id), 'method' => 'PUT')) }}
-
-DummyFormCreate
- {{ Form::submit('Edit', array('class' => 'btn btn-primary')) }}
-
- {{ Form::close() }}
+ {{ html()->form('PUT', route(['DummyVariable.update', DummyCreateVariableSing$->id]) )->open() }}
+ DummyFormCreate
+ {{ html()->submit('Edit')->class('btn btn-primary') }}
+ {{ html()->form()->close() }}
@stop
diff --git a/src/stubs/default-theme/index.stub b/src/stubs/default-theme/index.stub
index 07d0dcb..191ebd5 100644
--- a/src/stubs/default-theme/index.stub
+++ b/src/stubs/default-theme/index.stub
@@ -1,30 +1,26 @@
@extends('DummyExtends')
-
@section('DummySection')
-
-
- id |
-DummyHeaderTable
- Action |
+ id |
+ DummyHeaderTable
+ Action |
@foreach(DummyCreateVariable$ as DummyCreateVariableSing$)
-
{{ DummyCreateVariableSing$->id }} |
-DummyIndexTable
+ DummyIndexTable
Show
Edit
- {!! Form::open(['method' => 'DELETE','route' => ['DummyVariable.destroy', DummyCreateVariableSing$->id]]) !!}
- {!! Form::submit('Delete', ['class' => 'btn btn-danger']) !!}
- {!! Form::close() !!}
+ {!! html()->form('DELETE', route('DummyVariable.destroy', DummyCreateVariableSing$->id))->open() !!}
+ {!! html()->submit('Delete')->class('btn btn-danger') !!}
+ {!! html()->form()->close() !!}
|
@@ -32,5 +28,4 @@ DummyIndexTable
@endforeach
-
@stop
diff --git a/src/stubs/default-theme/livewire/index-datatable.stub b/src/stubs/default-theme/livewire/index-datatable.stub
index 0a4fd6b..639357b 100644
--- a/src/stubs/default-theme/livewire/index-datatable.stub
+++ b/src/stubs/default-theme/livewire/index-datatable.stub
@@ -12,7 +12,7 @@
id |
-DummyHeaderTable
+ DummyHeaderTable
Action |
@@ -20,14 +20,14 @@ DummyHeaderTable
@foreach(DummyCreateVariable$ as DummyCreateVariableSing$)
{{ DummyCreateVariableSing$->id }} |
-DummyIndexTable
+ DummyIndexTable
Show
Edit
- {!! Form::open(['method' => 'DELETE','route' => ['DummyVariable.destroy', DummyCreateVariableSing$->id]]) !!}
- {!! Form::submit('Delete', ['class' => 'btn btn-danger']) !!}
- {!! Form::close() !!}
+ {!! html()->form('DELETE', route('DummyVariable.destroy', DummyCreateVariableSing$->id))->open() !!}
+ {!! html()->submit('Delete')->class('btn btn-danger') !!}
+ {!! html()->form()->close() !!}
|
diff --git a/tests/Console/resultsOk/create.blade.php b/tests/Console/resultsOk/create.blade.php
index 2d11424..0d7fd9f 100644
--- a/tests/Console/resultsOk/create.blade.php
+++ b/tests/Console/resultsOk/create.blade.php
@@ -10,21 +10,21 @@
@endif
- {!! Form::open(['route' => 'posts.store']) !!}
+ {!! html()->form('POST', route('posts.store'))->open() !!}
- {{ Form::label('title', 'Title', ['class'=>'form-label']) }}
- {{ Form::text('title', null, array('class' => 'form-control')) }}
+ {{ html()->label('Title', 'title') }}
+ {{ html()->text('title', null) }}
- {{ Form::label('url', 'Url', ['class'=>'form-label']) }}
- {{ Form::text('url', null, array('class' => 'form-control')) }}
+ {{ html()->label('Url', 'url') }}
+ {{ html()->text('url', null) }}
- {{ Form::submit('Create', array('class' => 'btn btn-primary')) }}
+ {{ html()->submit('Create') }}
- {{ Form::close() }}
+ {{ html()->form()->close() }}
@stop
\ No newline at end of file
diff --git a/tests/Console/resultsOk/edit.blade.php b/tests/Console/resultsOk/edit.blade.php
index 9d6c3e7..d1ee39e 100644
--- a/tests/Console/resultsOk/edit.blade.php
+++ b/tests/Console/resultsOk/edit.blade.php
@@ -10,18 +10,18 @@
@endif
- {{ Form::model($post, array('route' => array('posts.update', $post->id), 'method' => 'PUT')) }}
+ {{ html()->form()->modelform($post, 'PUT', route('posts.update', $post->id)) }}
- {{ Form::label('title', 'Title', ['class'=>'form-label']) }}
- {{ Form::text('title', null, array('class' => 'form-control')) }}
+ {{ html()->label('Title', 'title') }}
+ {{ html()->text('title', null) }}
- {{ Form::label('url', 'Url', ['class'=>'form-label']) }}
- {{ Form::text('url', null, array('class' => 'form-control')) }}
+ {{ html()->label('Url', 'url') }}
+ {{ html()->text('url', null) }}
- {{ Form::submit('Edit', array('class' => 'btn btn-primary')) }}
+ {{ html()->submit('Edit') }}
- {{ Form::close() }}
+ {{ html()->form()->close() }}
@stop
\ No newline at end of file
diff --git a/tests/Console/resultsOk/index.blade.php b/tests/Console/resultsOk/index.blade.php
index a127ed0..297d39d 100644
--- a/tests/Console/resultsOk/index.blade.php
+++ b/tests/Console/resultsOk/index.blade.php
@@ -26,9 +26,9 @@
Show
Edit
- {!! Form::open(['method' => 'DELETE','route' => ['posts.destroy', $post->id]]) !!}
- {!! Form::submit('Delete', ['class' => 'btn btn-danger']) !!}
- {!! Form::close() !!}
+ {!! html()->form('DELETE', route('posts.destroy', $post->id))->open() !!}
+ {!! html()->submit('Delete') !!}
+ {!! html()->form()->close() !!}
diff --git a/tests/Console/resultsOk/post-datatable.blade.php b/tests/Console/resultsOk/post-datatable.blade.php
index bb1f9a8..8f4a475 100644
--- a/tests/Console/resultsOk/post-datatable.blade.php
+++ b/tests/Console/resultsOk/post-datatable.blade.php
@@ -29,9 +29,9 @@
Show
Edit
- {!! Form::open(['method' => 'DELETE','route' => ['posts.destroy', $post->id]]) !!}
- {!! Form::submit('Delete', ['class' => 'btn btn-danger']) !!}
- {!! Form::close() !!}
+ {!! html()->form('DELETE',route('posts.destroy', $post->id))->open() !!}
+ {!! html()->form()->submit('Delete') !!}
+ {!! html()->form()->close() !!}