changeset 3:6468684362c2

It works! Created a controller, no update insert but it works
author luka
date Tue, 27 Jun 2023 15:32:47 -0400
parents cf9993c5c7df
children a20439b1c9d3
files .php-cs-fixer.cache examples/ExampleGenerator.php.stub src/Generator/BaseGenerator.php src/Generator/Controller/ControllerGenerator.php src/Generator/Controller/stubs/controller.stub src/Generator/Generator.php src/Generator/Replacer.php src/MagicForgerServiceProvider.php src/Replacer.php
diffstat 9 files changed, 544 insertions(+), 179 deletions(-) [+]
line wrap: on
line diff
--- a/.php-cs-fixer.cache	Sun Jun 25 14:45:15 2023 -0400
+++ b/.php-cs-fixer.cache	Tue Jun 27 15:32:47 2023 -0400
@@ -1,1 +1,1 @@
-{"php":"8.2.7","version":"3.19.1","indent":"    ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_typehint":true,"curly_braces_position":{"allow_single_line_empty_anonymous_classes":true},"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true},"hashes":{"src\/Generator\/BaseGenerator.php":"35ac461e0fefdb76984233e6e05b1d96","src\/Replacer.php":"7a70096cc0aa604f1220867101595d18","src\/MagicForgerServiceProvider.php":"32cf8654ee2d13f02338fac22de66245"}}
\ No newline at end of file
+{"php":"8.2.7","version":"3.19.1","indent":"    ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_typehint":true,"curly_braces_position":{"allow_single_line_empty_anonymous_classes":true},"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true},"hashes":{"src\/Generator\/BaseGenerator.php":"bc9d41ab0960ae2c2b3c74c1d33086fb","src\/Replacer.php":"c6b5f421259f41016014c00270ca001c","src\/MagicForgerServiceProvider.php":"e56f92adc0181e9b7681de8ca8aca6eb","src\/Generator\/Controller\/ControllerGenerator.php":"abc9620527a5cc4194215ce7eeabcd50","src\/Generator\/Generator.php":"794271f48bed8f156878fc36a25ff60f","src\/Generator\/Replacer.php":"69aa83cbb0efbe8235730af51b68212f"}}
\ No newline at end of file
--- a/examples/ExampleGenerator.php.stub	Sun Jun 25 14:45:15 2023 -0400
+++ b/examples/ExampleGenerator.php.stub	Tue Jun 27 15:32:47 2023 -0400
@@ -39,37 +39,7 @@
      */
     public function handle()
     {
-
-
-        // First we need to ensure that the table exists, then we can
-        if (! $this->tableExists($this->getTableInput())) {
-            $this->components->error('The table: "'.$this->getTableInput().'" does not exist in the database.');
-
-            return false;
-        }
-
-        $name = $this->qualifyClass($this->getTableInput());
-
-        $path = $this->getPath($name);
-
-        $file = $this->getFile($name);
-
-        // Next, we will generate the path to the location where this class' file should get
-        // written. Then, we will build the class and make the proper replacements on the
-        // file so that it gets the correctly formatted namespace and class name.
-        $this->makeDirectory($path);
-
-        $this->files->put($path, $this->sortImports($this->buildClass($name)));
-
-        $info = $this->type;
-
-        if (in_array(CreatesMatchingTest::class, class_uses_recursive($this))) {
-            if ($this->handleTestCreation($path)) {
-                $info .= ' and test';
-            }
-        }
-
-        $this->components->info(sprintf('%s [%s] created successfully.', $info, $path));
+			parent::handle();
     }
 
     /**
--- a/src/Generator/BaseGenerator.php	Sun Jun 25 14:45:15 2023 -0400
+++ b/src/Generator/BaseGenerator.php	Tue Jun 27 15:32:47 2023 -0400
@@ -4,33 +4,18 @@
 
 use DB;
 
-use Illuminate\Routing\Console\ControllerMakeCommand;
-
+use Illuminate\Console\GeneratorCommand;
+use Illuminate\Support\Str;
 use Symfony\Component\Console\Attribute\AsCommand;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
-use Illuminate\Support\Str;
 
-use Wizzard\MagicForger\Replacer;
+use Wizzard\MagicForger\Generator\Replacer;
 
-#[AsCommand(name: 'mf')]
-class BaseGenerator extends ControllerMakeCommand
+abstract class BaseGenerator extends GeneratorCommand
 {
-    /**
-     * The name and signature of the console command.
-     *
-     * @var string
-     */
-    protected $name = 'mf';
-
-    /**
-     * The console command description.
-     *
-     * @var string
-     */
-    protected $description = 'Generates any (or all) of the available files.';
-
+    use Replacer;
 
     /**
      * The console command description.
@@ -51,62 +36,24 @@
      */
     public function handle()
     {
-
         // First we need to ensure that the table exists, then we can
-        if (!$this->tableExists($this->getTableInput())) {
+        if (! $this->tableExists($this->getTableInput())) {
             $this->components->error('The table: "'.$this->getTableInput().'" does not exist in the database.');
 
             return false;
         }
 
-        if ($this->option('all')) {
-            $this->input->setOption('factory', true);
-            $this->input->setOption('seed', true);
-            $this->input->setOption('migration', true);
-            $this->input->setOption('controller', true);
-            $this->input->setOption('model', true);
-        }
-
-        if ($this->option('factory')) {
-            $this->createFactory();
-        }
-
-        if ($this->option('migration')) {
-            $this->createMigration();
-        }
-
-        if ($this->option('seed')) {
-            $this->createSeeder();
-        }
-
-        if ($this->option('controller')) {
-            $this->createController();
-        }
-
-        if ($this->option('model')) {
-            $this->createModel();
-        }
-
-        //TODO: when working on an actual
         $name = $this->qualifyClass($this->getTableInput());
 
         $path = $this->getPath($name);
-        dd($name, $path);
 
-        // Next, We will check to see if the class already exists. If it does, we don't want
-        // to create the class and overwrite the user's code. So, we will bail out so the
-        // code is untouched. Otherwise, we will continue generating this class' files.
-        if ((! $this->hasOption('force') ||
-             ! $this->option('force')) &&
-             $this->alreadyExists($this->getNameInput())) {
-            $this->components->error($this->type.' already exists.');
+        $file = $this->getFile($name);
 
-            return false;
-        }
+        dd($this->get_all_inserts($file));
 
         // Next, we will generate the path to the location where this class' file should get
         // written. Then, we will build the class and make the proper replacements on the
-        // stub files so that it gets the correctly formatted namespace and class name.
+        // file so that it gets the correctly formatted namespace and class name.
         $this->makeDirectory($path);
 
         $this->files->put($path, $this->sortImports($this->buildClass($name)));
@@ -120,28 +67,18 @@
         }
 
         $this->components->info(sprintf('%s [%s] created successfully.', $info, $path));
-        echo "Generating Replacements\n";
-        $replacer = new Replacer();
-
-        $table_name = 'timesheet_statuses';
-        $model_name = $replacer->model_name($table_name);
-        $controller_name = $replacer->controller_name($table_name);
-        $human_readable = $replacer->human_readable($table_name);
-        $human_readable_lc = $replacer->human_readable_lc($table_name);
-        $replacer->log("Table Name : $table_name");
-        $replacer->log("Model Name : $model_name");
-        $replacer->log("Controller Name : $controller_name");
-        $replacer->log("Human Readable: $human_readable");
-        $replacer->log("Human Readable LC: $human_readable_lc");
-
-        echo "Stub Location\n";
-        $replacer->log($this->getStub());
 
     }
 
+    /**
+     * Override the original so that we can prompt for a table with autocomplete.
+     *
+     */
     protected function promptForMissingArguments(InputInterface $input, OutputInterface $output)
     {
+        $prompted = false;
         if(is_null($input->getArgument('table'))) {
+            $prompted = true;
             $table = null;
             while ($table === null) {
                 $table = $this->components->askWithCompletion(
@@ -152,7 +89,13 @@
 
             $input->setArgument('table', $table);
         }
+
         parent::promptForMissingArguments($input, $output);
+
+        // This will get missed if we prompt here but not in the parent
+        if($prompted) {
+            $this->afterPromptingForMissingArguments($input, $output);
+        }
     }
 
     /**
@@ -186,12 +129,6 @@
     protected function getOptions()
     {
         return [
-            /* ['type', null, InputOption::VALUE_REQUIRED, 'Manually specify the controller stub file to use'], */
-            /* ['force', null, InputOption::VALUE_NONE, 'Create the class even if the controller already exists'], */
-            /* ['invokable', 'i', InputOption::VALUE_NONE, 'Generate a single method, invokable controller class'], */
-
-            ['all', 'a', InputOption::VALUE_NONE, 'Generate a migration, seeder, factory, policy, resource controller, and form request classes for the model'],
-
         ];
     }
 
@@ -204,11 +141,6 @@
     {
     }
 
-    ////////////////////////////////////////////
-    ///				TO GO IN THE BASE CLASS				 ///
-    ////////////////////////////////////////////
-
-
     /**
      * Gets the file that will be worked on. If there is already an existing file
      * then we can open that. However if we are forcing the operation, then we
@@ -239,6 +171,9 @@
         return trim($this->argument('table'));
     }
 
+    /**
+     * Determines if the table exists in the current database
+     */
     protected function tableExists(string $table_name): bool
     {
         return in_array($table_name, $this->getTables());
@@ -265,7 +200,7 @@
     }
 
     /**
-     * Get the database schema
+     * Get the database schema for DB interactions
      */
     protected function getSchema()
     {
--- a/src/Generator/Controller/ControllerGenerator.php	Sun Jun 25 14:45:15 2023 -0400
+++ b/src/Generator/Controller/ControllerGenerator.php	Tue Jun 27 15:32:47 2023 -0400
@@ -0,0 +1,139 @@
+<?php
+
+namespace Wizzard\MagicForger\Generator\Controller;
+
+use Symfony\Component\Console\Attribute\AsCommand;
+use Wizzard\MagicForger\Generator\BaseGenerator;
+use Wizzard\MagicForger\Replacer;
+use Illuminate\Support\Str;
+
+//use Illuminate\Console\Concerns\CreatesMatchingTest;
+
+#[AsCommand(name: 'mf:controller')]
+class ControllerGenerator extends BaseGenerator
+{
+    //use CreatesMatchingTest;
+
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $name = 'mf:controller';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Generates the Controller File for a table.';
+
+    /**
+     * The type of class being generated.
+     *
+     * @var string
+     */
+    protected $type = 'Controller';
+
+
+    /**
+     * Execute the console command.
+     */
+    public function handle()
+    {
+
+
+        // First we need to ensure that the table exists, then we can
+        if (! $this->tableExists($this->getTableInput())) {
+            $this->components->error('The table: "'.$this->getTableInput().'" does not exist in the database.');
+
+            return false;
+        }
+
+        $name = $this->qualifyClass($this->getTableInput());
+
+        $path = $this->getPath($name);
+
+        $file = $this->getFile($path);
+
+        $file = $this->apply_replacements($file);
+
+
+        // Next, we will generate the path to the location where this class' file should get
+        // written. Then, we will build the class and make the proper replacements on the
+        // file so that it gets the correctly formatted namespace and class name.
+        $path = $this->makeDirectory($path);
+
+        $this->files->put($path, $this->sortImports($file));
+
+        $info = $this->type;
+
+        if (in_array(CreatesMatchingTest::class, class_uses_recursive($this))) {
+            if ($this->handleTestCreation($path)) {
+                $info .= ' and test';
+            }
+        }
+
+        $this->components->info(sprintf('%s [%s] created successfully.', $info, $path));
+    }
+
+    /**
+     * Get the stub file for the generator.
+     *
+     * @return string
+     */
+    protected function getStub()
+    {
+        return $this->resolveStubPath('/stubs/controller.stub');
+    }
+
+    /**
+     * Resolve the fully-qualified path to the stub.
+     *
+     * @param  string  $stub
+     * @return string
+     */
+    protected function resolveStubPath($stub)
+    {
+        return is_file($customPath = $this->laravel->basePath(trim($stub, '/')))
+            ? $customPath
+            : __DIR__.$stub;
+    }
+    /**
+     * Parse the class name and format according to the root namespace.
+     *
+     * @param  string  $name
+     * @return string
+     */
+    protected function qualifyClass($name)
+    {
+        $name = ltrim($name, '\\/');
+
+        $name = str_replace('/', '\\', $name);
+
+        $rootNamespace = $this->rootNamespace();
+
+        if (Str::startsWith($name, $rootNamespace)) {
+            return $name;
+        }
+
+        return $this->qualifyClass(
+            $this->getDefaultNamespace(trim($rootNamespace, '\\')).'\\'.$name
+        );
+    }
+
+    protected function getClassName($name)
+    {
+        return $this->controller_name($name);
+    }
+
+    /**
+     * Get the stub file for the generator.
+     *
+     * @return string
+     */
+    protected function getPath($name)
+    {
+        return str_replace(['App\\', '\\'], ['app/', '/'], $this->getControllerNamespace() . '/' . $this->controller_name($this->getTableInput()) . '.php');
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Generator/Controller/stubs/controller.stub	Tue Jun 27 15:32:47 2023 -0400
@@ -0,0 +1,93 @@
+<?php
+
+namespace {{ namespace }};
+
+use {{ namespacedModel }};
+use {{ rootNamespace }}Http\Controllers\Controller;
+{{ requestUses }}
+
+class {{ class }} extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     */
+    public function index()
+    {
+				$data = [];
+				
+				$data['items'] = {{ model }}::all();
+
+        return view('{{ tableName }}.index', $data);
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     */
+    public function create()
+    {
+				$data = []; 
+
+        return view('{{ tableName }}.create_edit', $data);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     */
+    public function store({{ storeRequest }} $request)
+    {
+        //
+				${{ modelVariable }} = new {{ model }}();
+
+				//insert the values into the model
+
+				${{ modelVariable }}->save();
+
+        return redirect()->route('{{ tableName }}.index');
+    }
+
+    /**
+     * Display the specified resource.
+     */
+    public function show({{ model }} ${{ modelVariable }})
+    {
+				$data = [];
+				
+				$data['item'] = ${{ modelVariable }};
+
+				return view('{{ tableName }}.show', $data); 
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     */
+    public function edit({{ model }} ${{ modelVariable }})
+    {
+			$data = [];
+
+			$data['item'] = ${{ modelVariable }};
+
+			return view('{{ tableName }}.create_edit', $data);
+    }
+
+    /**
+     * Update the specified resource in storage.
+     */
+    public function update({{ updateRequest }} $request, {{ model }} ${{ modelVariable }})
+    {
+        // Set the variables
+				${{ modelVariable }}->save();
+
+				return redirect()->route('{{ tableName }}.index');
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     */
+    public function destroy({{ model }} ${{ modelVariable }})
+    {
+        //
+				${{ modelVariable }}->delete();
+
+				return redirect()->route('{{ tableName }}.index');
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Generator/Generator.php	Tue Jun 27 15:32:47 2023 -0400
@@ -0,0 +1,107 @@
+<?php
+
+namespace Wizzard\MagicForger\Generator;
+
+use DB;
+
+use Symfony\Component\Console\Attribute\AsCommand;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+use Illuminate\Support\Str;
+
+use Wizzard\MagicForger\Generator\BaseGenerator;
+use Wizzard\MagicForger\Replacer;
+
+#[AsCommand(name: 'mf')]
+class Generator extends BaseGenerator
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $name = 'mf';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Generates any (or all) of the available files.';
+
+
+    /**
+     * Execute the console command.
+     */
+    public function handle()
+    {
+
+        // First we need to ensure that the table exists, then we can
+        if (!$this->tableExists($this->getTableInput())) {
+            $this->components->error('The table: "'.$this->getTableInput().'" does not exist in the database.');
+
+            return false;
+        }
+
+        if ($this->option('all')) {
+            /* $this->input->setOption('factory', true); */
+            /* $this->input->setOption('seed', true); */
+            /* $this->input->setOption('migration', true); */
+            $this->input->setOption('controller', true);
+            /* $this->input->setOption('model', true); */
+        }
+
+        /* if ($this->option('factory')) { */
+        /*     $this->createFactory(); */
+        /* } */
+
+        /* if ($this->option('migration')) { */
+        /*     $this->createMigration(); */
+        /* } */
+
+        /* if ($this->option('seed')) { */
+        /*     $this->createSeeder(); */
+        /* } */
+
+        if ($this->option('controller')) {
+            $this->createController();
+        }
+
+        /* if ($this->option('model')) { */
+        /*     $this->createModel(); */
+        /* } */
+
+    }
+
+    /**
+     * Get the console command options.
+     *
+     * @return array
+     */
+    protected function getOptions()
+    {
+        return [
+            ['all', 'a', InputOption::VALUE_NONE, 'Generate a migration, seeder, factory, policy, resource controller, and form request classes for the table.'],
+            ['controller', 'c', InputOption::VALUE_NONE, 'Generate a controller class for the table.'],
+        ];
+    }
+
+    /**
+     * Interact further with the user if they were prompted for missing arguments.
+     *
+     * @return void
+     */
+    protected function afterPromptingForMissingArguments(InputInterface $input, OutputInterface $output)
+    {
+    }
+
+    protected function getStub()
+    {
+    }
+
+    protected function createController()
+    {
+        $this->call('mf:controller', ['table' => $this->getTableInput()]);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Generator/Replacer.php	Tue Jun 27 15:32:47 2023 -0400
@@ -0,0 +1,175 @@
+<?php
+
+namespace Wizzard\MagicForger\Generator;
+
+use Illuminate\Support\Str;
+
+trait Replacer
+{
+    /**
+     * Prefix and Suffix for controller.
+     * Usage is up to the user.
+     *
+     * @var string
+     */
+    protected $controller_prefix = "";
+
+
+    /**
+     * Prefix and Suffix for controller.
+     * Usage is up to the user.
+     *
+     * @var string
+     */
+    protected $controller_suffix = "Controller";
+
+
+    /**
+     * Finds all places in a string that could be replaced.
+     * Returns an array of all potential replacements as they
+     * appear in the target.
+     */
+    public function get_all_inserts(string $target): array
+    {
+        //find all the matches to our expected syntax
+        $matches = [];
+        preg_match_all('/{{[\sa-zA-Z\-_]+}}/', $target, $matches);
+        // sort the array and return unique values
+        sort($matches[0]);
+        return array_values(array_unique($matches[0]));
+    }
+
+
+    public function apply_replacements(string $target): string
+    {
+        $inserts = $this->get_all_inserts($target);
+        $available_replacements = $this->get_available_replacements();
+
+        $target = str_replace(
+            array_keys($available_replacements),
+            $available_replacements,
+            $target
+        );
+
+        return $target;
+    }
+
+    public function get_available_replacements()
+    {
+        $table_name = $this->getTableInput();
+        $replacements = [
+                    "{{ class }}" => $this->getClassName($table_name),
+                    "{{ model }}" => $this->model_name($table_name),
+                    "{{ modelVariable }}" => $this->model_variable($table_name),
+                    "{{ namespace }}" => $this->{'get' . $this->type . 'Namespace'}(),
+                    "{{ namespacedModel }}" => $this->getModelNamespace(),
+                    "{{ requestUses }}" => $this->getRequestUses($table_name),
+                    "{{ rootNamespace }}" => $this->getRootNamespace(),
+                    "{{ storeRequest }}" => $this->store_request_name($table_name),
+                    "{{ tableName }}" => $table_name,
+                    "{{ updateRequest }}" => $this->update_request_name($table_name),
+
+        ];
+
+        return $replacements;
+    }
+
+    ////////////////////////////////////////////
+    //				Internals and Classes   				//
+    ////////////////////////////////////////////
+
+    /**
+     * Model names are generated in uppercase first Camel case
+     */
+    public function model_name(string $name): string
+    {
+        return Str::singular(Str::studly($name));
+    }
+
+    /**
+     * Model variable is standardly just a singular version of the table name
+     */
+    public function model_variable(string $name): string
+    {
+        return Str::singular($name);
+    }
+
+    /**
+     * Controller names are generated in uppercase first Camel case
+     * and wrapped in the prefix and suffix
+     */
+    public function controller_name(string $name): string
+    {
+        return $this->controller_prefix .
+            $this->model_name($name) .
+            $this->controller_suffix;
+    }
+
+    public function store_request_name(string $name): string
+    {
+        return 'Store' . $this->model_name($name);
+    }
+
+    public function update_request_name(string $name): string
+    {
+        return 'Update' . $this->model_name($name);
+    }
+
+
+    ////////////////////////////////////////////
+    //							Namespaces			   				//
+    ////////////////////////////////////////////
+
+    public function getRootNamespace()
+    {
+        return $this->laravel->getNamespace();
+    }
+
+    public function getModelNamespace()
+    {
+        return $this->getRootNamespace() . 'Models';
+    }
+
+    public function getControllerNamespace()
+    {
+        return $this->getRootNamespace() . 'Http\\Controllers';
+    }
+
+    public function getRequestNamespace(string $name)
+    {
+        return $this->getRootNamespace() . 'Http\\Requests\\' . $this->model_name($name);
+    }
+
+    public function getRequestUses(string $name)
+    {
+        return implode("\n", [
+            "use " . $this->getRequestNamespace($name) . '\\' . $this->store_request_name($name),
+            "use " . $this->getRequestNamespace($name) . '\\' . $this->update_request_name($name),
+        ]);
+    }
+
+
+    ////////////////////////////////////////////
+    //				Language and Presentables				//
+    ////////////////////////////////////////////
+
+    /**
+     * Breaks up a string and makes it human readable
+     *
+     * This function assumes that the inputted name is camel case
+     */
+    public function human_readable(string $name): string
+    {
+        return Str::title(Str::replace('_', ' ', $name));
+    }
+
+    /**
+     * Breaks up a string and makes it human readable and lowecase
+     *
+     * This function assumes that the inputted name is camel case
+     */
+    public function human_readable_lc(string $name): string
+    {
+        return Str::lower($this->human_readable($name));
+    }
+}
--- a/src/MagicForgerServiceProvider.php	Sun Jun 25 14:45:15 2023 -0400
+++ b/src/MagicForgerServiceProvider.php	Tue Jun 27 15:32:47 2023 -0400
@@ -3,8 +3,8 @@
 namespace Wizzard\MagicForger;
 
 use Illuminate\Support\ServiceProvider;
-use Wizzard\Magicforger\Generator\BaseGenerator;
-use Wizzard\Magicforger\Generator\Controller\ControllerGenerator;
+use Wizzard\MagicForger\Generator\Generator;
+use Wizzard\MagicForger\Generator\Controller\ControllerGenerator;
 
 class MagicForgerServiceProvider extends ServiceProvider
 {
@@ -15,7 +15,7 @@
     {
         if ($this->app->runningInConsole()) {
             $this->commands([
-                BaseGenerator::class,
+                Generator::class,
                 ControllerGenerator::class,
             ]);
         }
--- a/src/Replacer.php	Sun Jun 25 14:45:15 2023 -0400
+++ b/src/Replacer.php	Tue Jun 27 15:32:47 2023 -0400
@@ -14,22 +14,6 @@
     protected $replacement_cache = [];
 
 
-    /**
-     * Prefix and Suffix for controller.
-     * Usage is up to the user.
-     *
-     * @var string
-     */
-    protected $controller_prefix = "";
-
-
-    /**
-     * Prefix and Suffix for controller.
-     * Usage is up to the user.
-     *
-     * @var string
-     */
-    protected $controller_suffix = "Controller";
 
 
     /**
@@ -45,44 +29,6 @@
         /* parent::__construct(); */
     }
 
-    /**
-     * Model names are generated in uppercase first Camel case
-     */
-    public function model_name(string $name): string
-    {
-        return Str::singular(Str::studly($name));
-    }
-
-    /**
-     * Controller names are generated in uppercase first Camel case
-     * and wrapped in the prefix and suffix
-     */
-    public function controller_name(string $name): string
-    {
-        return $this->controller_prefix .
-            $this->model_name($name) .
-            $this->controller_suffix;
-    }
-
-    /**
-     * Breaks up a string and makes it human readable
-     *
-     * This function assumes that the inputted name is camel case
-     */
-    public function human_readable(string $name): string
-    {
-        return Str::title(Str::replace('_', ' ', $name));
-    }
-
-    /**
-     * Breaks up a string and makes it human readable and lowecase
-     *
-     * This function assumes that the inputted name is camel case
-     */
-    public function human_readable_lc(string $name): string
-    {
-        return Str::lower($this->human_readable($name));
-    }
 
     /**
      * Outputs a log for the replacements based on log level.