Permalink
Browse files

First Commit

  • Loading branch information...
0 parents commit a4b3fca111dec6ff026ba2be8a83b0d9aa0c1673 Maru Amallo-amamarul committed Jan 9, 2017
Showing with 2,001 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +21 −0 LICENSE.md
  3. +171 −0 README.md
  4. +22 −0 composer.json
  5. +103 −0 src/Commands/Console/BreadcrumbsMakeCommand.php
  6. +135 −0 src/Commands/Console/ControllerMakeCommand.php
  7. +154 −0 src/Commands/Console/DataTablesMakeCommand.php
  8. +118 −0 src/Commands/Console/ModelMakeCommand.php
  9. +104 −0 src/Commands/Console/RequestMakeCommand.php
  10. +97 −0 src/Commands/Console/RoutesMakeCommand.php
  11. +70 −0 src/Commands/Console/TraitAttributeMakeCommand.php
  12. +70 −0 src/Commands/Console/TraitRelationshipMakeCommand.php
  13. +70 −0 src/Commands/Console/TraitScopeMakeCommand.php
  14. +13 −0 src/Commands/Console/stubs/attribute.stub
  15. +21 −0 src/Commands/Console/stubs/breadcrumb.group.stub
  16. +21 −0 src/Commands/Console/stubs/breadcrumb.stub
  17. +87 −0 src/Commands/Console/stubs/controller.model.stub
  18. +139 −0 src/Commands/Console/stubs/controller.model2.stub
  19. +94 −0 src/Commands/Console/stubs/datatables.stub
  20. +19 −0 src/Commands/Console/stubs/model.stub
  21. +31 −0 src/Commands/Console/stubs/request.stub
  22. +10 −0 src/Commands/Console/stubs/routes.group.stub
  23. +3 −0 src/Commands/Console/stubs/routes.stub
  24. +18 −0 src/Commands/Console/stubs/scope.stub
  25. +11 −0 src/Commands/Console/stubs/trait.stub
  26. +232 −0 src/Commands/CrudCommand.php
  27. +72 −0 src/Providers/BoilerPlateCommandsServiceProvider.php
  28. +29 −0 src/Views/datatable.blade.php
  29. +1 −0 src/Views/form/box_link.blade.php
  30. +5 −0 src/Views/form/email.blade.php
  31. +6 −0 src/Views/form/submit.blade.php
  32. +5 −0 src/Views/form/text.blade.php
  33. +4 −0 src/Views/form/text_show.blade.php
  34. +44 −0 src/Views/show.blade.php
@@ -0,0 +1 @@
+
@@ -0,0 +1,21 @@
+# The MIT License (MIT)
+
+Copyright (c) 2017 Maru Amallo
+
+> Permission is hereby granted, free of charge, to any person obtaining a copy
+> of this software and associated documentation files (the "Software"), to deal
+> in the Software without restriction, including without limitation the rights
+> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+> copies of the Software, and to permit persons to whom the Software is
+> furnished to do so, subject to the following conditions:
+>
+> The above copyright notice and this permission notice shall be included in all
+> copies or substantial portions of the Software.
+>
+> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+> SOFTWARE.
@@ -0,0 +1,171 @@
+# BoilerPlateCommands
+Package to generate automatic cruds for Laravel BoilerPlate Apps [Boilerplate]https://github.com/rappasoft/laravel-5-boilerplate
+
+The amamarul:crud make:
+ 1 - Model
+ 2 - Model Trait Attribute
+ 3 - Model Trait Relationship
+ 4 - Model Trait Scope
+ 5 - Form Request
+ 6 - Controller
+ 7 - Datatable as Service for Controller
+ 8 - Routes
+ 9 - Breadcrumbs
+
+## Install Boilerplate
+
+``` bash
+$ git clone https://github.com/rappasoft/laravel-5-boilerplate.git
+```
+
+``` bash
+$ cd laravel-5-boilerplate
+```
+
+``` bash
+$ composer install
+```
+
+## Install Package (Laravel)
+
+# Via Composer
+
+``` bash
+$ composer require amamarul/BoilerPlateCommands
+```
+
+# Add the following to the AppServiceProvider in the register function:
+``` php
+/*
+ * Load third party local providers
+ */
+$this->app->register(\Amamarul\BoilerPlateCommands\Providers\BoilerPlateCommandsServiceProvider::class);
+```
+
+# The register function must look like this
+``` php
+public function register()
+{
+ /*
+ * Sets third party service providers that are only needed on local/testing environments
+ */
+ if ($this->app->environment() == 'local' || $this->app->environment() == 'testing') {
+ /**
+ * Loader for registering facades.
+ */
+ $loader = \Illuminate\Foundation\AliasLoader::getInstance();
+
+ /*
+ * Load third party local providers
+ */
+ $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
+
+ /*
+ * Load third party local aliases
+ */
+ $loader->alias('Debugbar', \Barryvdh\Debugbar\Facade::class);
+
+ /*
+ * Load third party local providers
+ */
+ $this->app->register(\Amamarul\BoilerPlateCommands\Providers\BoilerPlateCommandsServiceProvider::class);
+ }
+}
+```
+
+# Publish the views
+``` bash
+$ php artisan vendor:publish --provider='Amamarul\BoilerPlateCommands\Providers\BoilerPlateCommandsServiceProvider'
+```
+## Usage
+
+You need the tables migrated
+
+# create migration
+``` bash
+$ php artisan make:migration create_products_table
+```
+``` php
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateProductsTable extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::create('products', function (Blueprint $table) {
+ $table->increments('id');
+ $table->string('name');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('products');
+ }
+}
+```
+# Migrate
+``` bash
+$ php artisan migrate
+```
+## Make the Crud
+Run the following commands
+**amamarul:crud {name} {tabla} {seccion} {grupo?}**
+ * **name:** Is the Model Name
+ * **tabla:** Is the table name
+ * **seccion:** can be 'Backend', 'Frontend' or the section you want
+ * **grupo:** if you want to group different Models and Controllers like sub sections. **this is optional**
+
+**This is an example for Backend and the group 'Products'. Then you can to add another model/controller in that group**
+``` bash
+$ php artisan amamarul:crud Product products Backend Products
+```
+- **The result in console will be**
+``` bash
+Model created successfully.
+Request created successfully.
+TraitAttribute created successfully.
+TraitRelationship created successfully.
+TraitScope created successfully.
+Controller created successfully.
+DataTable created successfully.
+Routes created successfully.
+Breadcrumbs created successfully.
+```
+- **Run php artisan serve**
+``` bash
+$ php artisan serve
+```
+Now you can go to http://localhost:8000/admin/products/product and you will show the datatable.
+
+Go to app/Http/Controllers/Backend/Products/DataTables/ProductDataTable.php and uncomment the fields you want to show in the datatable in the getColumns() function (the last function), by default you will see only 'id', 'created_at' and 'updated_at'.
+
+## Contributing
+
+Contributions are **welcome** and will be fully **credited**.
+
+I accept contributions via Pull Requests
+
+## Credits
+
+- [Maru][link-author]
+- [All Contributors][link-contributors]
+
+## License
+
+The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
@@ -0,0 +1,22 @@
+{
+ "name": "amamarul/boiler-plate-commands",
+ "type": "library",
+ "description": "Package to generate automatic cruds for Laravel BoilerPlate Apps",
+ "keywords": ["laravel","package","BoilerPlate"],
+ "minimum-stability": "stable",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Maru Amallo",
+ "email": "ama_marul@hotmail.com"
+ }
+ ],
+ "autoload":{
+ "psr-4": {
+ "Amamarul\\BoilerPlateCommands\\": "src/"
+ }
+ },
+ "config": {
+ "preferred-install": "dist"
+ }
+}
@@ -0,0 +1,103 @@
+<?php
+
+namespace Amamarul\BoilerPlateCommands\Commands\Console;
+
+use Illuminate\Support\Str;
+use Illuminate\Console\GeneratorCommand;
+use Symfony\Component\Console\Input\InputOption;
+
+class BreadcrumbsMakeCommand extends GeneratorCommand
+{
+ /**
+ * The console command name.
+ *
+ * @var string
+ */
+ protected $name = 'amamarul:breadcrumbs {name} {seccion} {grupo?}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Register Breadcrumbs';
+
+ /**
+ * The type of class being generated.
+ *
+ * @var string
+ */
+ protected $type = 'Breadcrumbs';
+
+ /**
+ * Get the stub file for the generator.
+ *
+ * @return string
+ */
+ protected function getStub()
+ {
+ if ($this->argument('grupo') !== null) {
+ return __DIR__.'/stubs/breadcrumb.group.stub';
+ } else {
+ return __DIR__.'/stubs/breadcrumb.stub';
+ }
+ }
+
+ /**
+ * Get the default namespace for the class.
+ *
+ * @param string $rootNamespace
+ * @return string
+ */
+ protected function getDefaultNamespace($rootNamespace)
+ {
+
+ if ($this->argument('grupo') !== null) {
+ return $rootNamespace.'\Http\Breadcrumbs\\'.$this->argument('seccion').'\\'.$this->argument('grupo');
+ } else {
+ return $rootNamespace.'\Http\Breadcrumbs\\'.$this->argument('seccion');
+ }
+ }
+
+ /**
+ * Build the class with the given name.
+ *
+ * Remove the base controller import if we are already in base namespace.
+ *
+ * @param string $name
+ * @return string
+ */
+ protected function buildClass($name)
+ {
+ if ($this->argument('seccion') === 'Backend') {
+ $seccion = 'admin';
+ } else {
+ $seccion = strtolower($this->argument('seccion'));
+ }
+ $replace = [
+ 'DummyRoute' => lcfirst($this->argument('name')),
+ 'DummyCapsRoute' => $this->argument('name'),
+ 'DummySeccion' => $seccion,
+ 'DummyGrupo' => $this->argument('grupo') ? $this->argument('grupo') : '',
+ 'DummyPrefixGrupo' => $this->argument('grupo') ? strtolower($this->argument('grupo')) : '',
+ ];
+
+ return str_replace(
+ array_keys($replace), array_values($replace), parent::buildClass($name)
+ );
+ }
+
+ /**
+ * Get the console command arguments.
+ *
+ * @return array
+ */
+ protected function getArguments()
+ {
+ return [
+ ['name'],
+ ['seccion'],
+ ['grupo'],
+ ];
+ }
+}
Oops, something went wrong.

0 comments on commit a4b3fca

Please sign in to comment.