{"id":14974685,"url":"https://github.com/digitaldreams/laracrud","last_synced_at":"2025-05-15T02:08:00.506Z","repository":{"id":49274300,"uuid":"67508056","full_name":"digitaldreams/laracrud","owner":"digitaldreams","description":"Laravel Code Generator based on MySQL Database","archived":false,"fork":false,"pushed_at":"2024-12-17T03:27:52.000Z","size":4956,"stargazers_count":334,"open_issues_count":7,"forks_count":54,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-14T00:58:00.088Z","etag":null,"topics":["code-generator","crud-generator","laracrud","laravel","laravel-5-package","laravel-application","laravel-crud","laravel-framework","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digitaldreams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-06T12:54:15.000Z","updated_at":"2025-03-30T22:10:04.000Z","dependencies_parsed_at":"2024-06-19T00:15:18.691Z","dependency_job_id":"d9a09ec9-f607-4a99-845f-9ccf0b0da8cc","html_url":"https://github.com/digitaldreams/laracrud","commit_stats":{"total_commits":356,"total_committers":4,"mean_commits":89.0,"dds":"0.014044943820224698","last_synced_commit":"1618bf03a316372087cff2c20129802732475ba4"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldreams%2Flaracrud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldreams%2Flaracrud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldreams%2Flaracrud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldreams%2Flaracrud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitaldreams","download_url":"https://codeload.github.com/digitaldreams/laracrud/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254159135,"owners_count":22024553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generator","crud-generator","laracrud","laravel","laravel-5-package","laravel-application","laravel-crud","laravel-framework","php"],"created_at":"2024-09-24T13:50:55.570Z","updated_at":"2025-05-15T02:07:55.495Z","avatar_url":"https://github.com/digitaldreams.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Code Generator\n\nDo you have a well structed database and you want to make a Laravel Application on top of it.\nBy using this tools you can generate Models which have necessary methods and property, Request class with rules, generate route from controllers method and its parameter and full features form with validation error message and more with a single line of command. So lets start. [See demo](https://github.com/digitaldreams/laracrud-demo) code and [slides](https://slides.com/tuhinbepari/laracrud/fullscreen#/) \n\n### Installation ###\n```\ncomposer require digitaldream/laracrud --dev\n```\n\n## Setting\n\n01. Add this line to config/app.php providers array . Not needed if you are using laravel 5.5 or greater\n```php\n    LaraCrud\\LaraCrudServiceProvider::class\n``` \n  \n02. Then Run\n```php\n    php artisan vendor:publish --provider=\"LaraCrud\\LaraCrudServiceProvider\"\n```\n    \n## Commands\nThen you can see new commands by running 'php artisan'\n\n*\t`laracrud:model {tableName} {name?} {--on=} {--off=}`: Create model based on table\n*\t`laracrud:request {Model} {name?} {--resource=} {--controller=} {--api}`: Create Request Class/es based on table\n*\t`laracrud:Controller {Model} {name?} {--parent=} {--only=} {--api}`: Create Controller Class based on Model\n*\t`laracrud:mvc {table} {--api}`: Run above commands into one place\n*\t`laracrud:route {controller} {--api}`: Create routes based on controller method\n*\t`laracrud:view {Model} {--page=(index|create|edit|show|form|table|panel|modal)} {--type=} {--name=} {--controller=}`\n*\t`laracrud:migration {table}`: Create a migration file based on Table structure. Its opposite of normal migration file creation in Laravel\n* `laracrud:policy {model} {--controller=} {--name=}`\n* `laracrud:package {--name=}`\n* `laracrud:transformer {model} {name?}`: Create a dingo api transformer for a model\n* `laracrud:test {controller} {--api}`: Create test methods for each of the method of a controller\n\n**N.B: --api option will generate api resource. Like Controller, Request, Route, Test. [Dingo API](https://github.com/dingo/api) compatible code will be generated**\n . [See API documentation](https://github.com/digitaldreams/laracrud/wiki/API-Development)\n\n### How to Use\n\n\n\n## Create a Model\n\nThere are some good practice for model in Laravel. Use scope to define query, define fillable, dates, casts etc.\nAlso define relation, set*Attribute and get*Attribute for doing work before and after model save and fetch.\n\nWe are going to create this thing automatically by reading table structure and its relation to others table.\n```php\n    php artisan laracrud:model users\n```\nBy default Model Name will be based on Table name. But Model name can be specified as second parameter. Like below\n```php\nphp artisan laracrud:model users MyUser\n```  \n[Video Tutorial](https://www.youtube.com/watch?v=TDfsdkPHKf4\u0026list=PLcGdsjZbEjRtxROY7mlHcJQcSwxx9L8NB)\n\n## Create Request\n\n A well structured table validate everything before inserting . You can not insert a illegal date in a birth_date column if its data type set to date.So if we have this logic set on table why we should write it on Request again. Lets use this table logic to create a request class in laravel.\n \n    php artisan laracrud:request MyUser\n   \n\n Here **MyUser** is Eloquent Model. From LaraCrud version 4.* this command accept Model Name instead of Table\n\nLike Model Name we can also specify a custom request name.\n```php\nphp artisan laracrud:request User RegisterRequest\n```  \nAlso If you like to create multiple request for your resourceful controller then \n```php\nphp artisan laracrud:request User –-resource=index,show,create,update,destroy\n```\n\nIt will create a folder users on app/Http/Requests folder and create these request classes. \nSometimes you may like to create individual request class for each of your controller method then. \n```php\nphp artisan laracrud:request User –-controller=UserController\nphp artisan laracrud:request User --controller=UserController --api //this will generated Request for API usages\n\n```\nIt will read your controller and create request classes for your Public method \n\n[video tutorial](https://www.youtube.com/watch?v=MGMP9FB2l5g\u0026index=2\u0026list=PLcGdsjZbEjRtxROY7mlHcJQcSwxx9L8NB)\n\n## Create Controller\n```php \n    php artisan laracrud:controller User\n    //Or Give a controller name.\n    php artisan laracrud:controller User MyUserController\n    //Or we can give a sub namespace\n    php artisan laracrud:controller User User/UserController\n    //It will create a folder User to controllers\n    php artisan laracrud:controller Comment --parent=Post // it will create a sub resource CommentController\n```\nThis will create a controller which have create, edit, save and delete method with codes .\nIt also handle your relation syncronization\n\n[video tutorial](https://youtu.be/MGMP9FB2l5g?t=5m10s)\n\n## Create View \n\nA typical form represent a database table. \nE.g. for a Registration form it has all the input field which is necessary for users table. Most of the time we use \nBootstrap to generate a form . It has error field highlighting if validation fails. Also display value. This all can be done by\n```php  \n php artisan laracrud:view User --page=form\n php artisan laracrud:view User --page=index --type=panel //There are three type of layout for index page panel,table and tabpan\n php artisan laracrud:view User --controller=UserController // Create all the views which is not created yet for this controller\n \n ```\n Here **User** is Eloquent Model. From LaraCrud version 4.* this command accept Model Name instead of Table\n\nThis will create a complete users crud view. \n\n[video tutorial](https://www.youtube.com/watch?v=RjRFWABwXnA\u0026list=PLcGdsjZbEjRtxROY7mlHcJQcSwxx9L8NB\u0026index=5)\n\n## Create Route\n\nRoutes are the most vital part of a laravel application.\nWE create routes by its public methods and parameter. \nLets do this work to rotue command.\n```php \n    php artisan laracrud:route UserController\n    php artisan laracrud:route UserController --api // generate api routes for this conroller\n```\nIf you have some routes already redine for \u003ccontrollerName\u003e then do not worry.\nIt will create routes for which does not define yet. \nPlease use forward slash(/) for sub namespace. For example,\n```php \n php artisan laracrud:route Auth/AuthController\n```\n\n## Policy\nLaravel have default policy generator. It works like same with one extra feature that is create policy method based on controller public methods. \n```php\nphp artisan laracrud:policy User \n// will create policy class with basic methods\nphp artisan laracrud:policy User --controller=UserController\n// create method based on Controller public methods\n```\n\n## Package\nPackages gives us opportunity to create/use components into our existing application. That make our code reusable. \nLaravel package has similar structure as a Laravel application has.\n```php\nphp artisan laracrud:package Hello\n```\nThis will create a folder same structure as a Laravel application has into your /packages folder\n[See Package documentation](https://github.com/digitaldreams/laracrud/wiki/Package-Development)\n[Video tutorial](https://www.youtube.com/watch?v=7-mhRjKQPuY\u0026t=2s)\n\n## Test\nWe need to test our routes endpoints. To create test class based on a controller do the following\n```php\nphp artisan laracrud:test UserController\n// or to make api test just pass --api like below\nphp artisan laracrud:test UserController --api\n```\n\n## Transformer\nTransformer are a vital part of Dingo API. To expose a model to api endpoint Transformer play media between api and model.\n\n```php\nphp artisan laracrud:transformer User\n```\n[See API documentation](https://github.com/digitaldreams/laracrud/wiki/API-Development)\n## Create everything at once\n\nIf we need all the command to then just to\n```php \n    php artisan laracrud:mvc users\n    php artisan laracrud:mvc users --api // create all the API related resources\n```\nIt will create Model, Request, Controller, View.\nThen you just need to run route command to create routes.\n\n## Migration\n\nSomethings we may need to create a migration file from a table. Then this command will be useful. It will generate all the necessary code for your migration files. So your migration file is ready to use.\n\n```php \nphp artisan laracrud:migration users\n```\n## Customize Code Template\nCoding Style differ from developer to developer. So you can control how your code will be generated. Code templates are organized by folder in resources/vendor/laracrud/templates . Go there and change the style. After that your code will be generated by reading these files. _Please do not remove or change @@placeHolder@@. This will be replaced by application_.\n\n\n# NB: only for mysql database\n\nIt is recommended to take a look in the generated file before use it.\n\n\nLike my work? If so [hire me on upwork](https://www.upwork.com/fl/tuhinbepari)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitaldreams%2Flaracrud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitaldreams%2Flaracrud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitaldreams%2Flaracrud/lists"}