diff --git a/resources/views/manthra-index.blade.php b/resources/views/manthra-index.blade.php new file mode 100644 index 0000000..b2439aa --- /dev/null +++ b/resources/views/manthra-index.blade.php @@ -0,0 +1,250 @@ + +​ +
+
+
+
+
+

+ @{{ welcome }} +

+ + + + + +
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+
+
+ Add Field +
+
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ X +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ + + + + \ No newline at end of file diff --git a/src/Http/Controllers/ManthraController.php b/src/Http/Controllers/ManthraController.php new file mode 100644 index 0000000..c2cc33f --- /dev/null +++ b/src/Http/Controllers/ManthraController.php @@ -0,0 +1,39 @@ +merge_fields(request('fields')); + + Artisan::call("manthra:all", [ + 'name' => request('model'), + '--fields' => $fields, + '--validations' => '', + '--controller-namespace' => request('controller_namespace'), + '--model-namespace' => request('model_namespace'), + '--view-path' => request('view_path'), + '--route-group' => request('group_group') + ]); + } + + private function merge_fields(array $fields): string + { + $merge = ''; + foreach ($fields as $field) { + $merge .= $field['name'] . '#' . $field['type'] . ';'; + } + + return $merge; + } +} diff --git a/src/LaravelManthraServiceProvider.php b/src/LaravelManthraServiceProvider.php index 14fd6e9..bc9c106 100644 --- a/src/LaravelManthraServiceProvider.php +++ b/src/LaravelManthraServiceProvider.php @@ -20,9 +20,10 @@ class LaravelManthraServiceProvider extends ServiceProvider */ public function boot() { - if ($this->app->runningInConsole()) { - $this->bootForConsole(); - } + $this->bootForConsole(); + + $this->loadRoutesFrom(__DIR__ . '/routes/web.php'); + $this->loadViewsFrom(__DIR__ . '/./../resources/views', 'manthra'); } /** diff --git a/src/routes/web.php b/src/routes/web.php new file mode 100644 index 0000000..309abbb --- /dev/null +++ b/src/routes/web.php @@ -0,0 +1,8 @@ +prefix('manthra')->group(function () { + Route::get('/', 'ManthraController@index'); + Route::post('/', 'ManthraController@store')->name('generate-manthra'); +});