{"id":16041356,"url":"https://github.com/leogopal/laravel-startercrud","last_synced_at":"2025-03-24T09:21:56.093Z","repository":{"id":57013913,"uuid":"177430069","full_name":"leogopal/laravel-startercrud","owner":"leogopal","description":"A CRUD Artisan helper for the Laravel Starterkit","archived":false,"fork":false,"pushed_at":"2020-03-06T04:03:25.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-29T14:46:03.046Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leogopal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-24T15:02:41.000Z","updated_at":"2020-03-06T04:03:27.000Z","dependencies_parsed_at":"2022-08-21T14:50:37.311Z","dependency_job_id":null,"html_url":"https://github.com/leogopal/laravel-startercrud","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leogopal%2Flaravel-startercrud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leogopal%2Flaravel-startercrud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leogopal%2Flaravel-startercrud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leogopal%2Flaravel-startercrud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leogopal","download_url":"https://codeload.github.com/leogopal/laravel-startercrud/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245240829,"owners_count":20583102,"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":[],"created_at":"2024-10-08T23:41:31.150Z","updated_at":"2025-03-24T09:21:56.047Z","avatar_url":"https://github.com/leogopal.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Starterkit Artisan CRUD\n\n[![Latest Stable Version](https://poser.pugx.org/leogopal/laravel-startercrud/version)](https://packagist.org/packages/leogopal/laravel-startercrud)\n[![Total Downloads](https://poser.pugx.org/leogopal/laravel-startercrud/downloads)](https://packagist.org/packages/leogopal/laravel-startercrud)\n[![License](https://poser.pugx.org/leogopal/laravel-startercrud/license)](https://packagist.org/packages/leogopal/laravel-startercrud)\n\n\nThis is an Artisan based package for the [Laravel Starterkit](https://github.com/leogopal/laravel-starterkit)\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require leogopal/laravel-startercrud\n```\n\n## Usage\n\nCreates a Model, Controller (with Repository, validation Requests, Events and Listeners), Migration, Routes, Breadcrumbs and CRUD Views for the given name ready to work.\n\nIt does not overwrite any files that may exist with the pre-stablished names. So, if you delete one of the files and run the command again, the deleted file will be created again and the rest will be ignored and will keep the changes you could have made.\n\n## Run\n\nIn your Laravel project root folder:\n\n```\nphp artisan lg:crud example\n```\n\nWhere _example_ is the name you want for your model (routes, views, controllers,...). I've tried to follow best naming practices and it uses plural or singular names and lower or uppercase where needed. You can also use camelCase or snake_case.\n\nParameters _example_, _Example_, _examples_ or _EXAMPLES_ all give the same results.\n\nThen run the created migration:\n\n```\nphp artisan migrate\n```\n\nIn your browser open:\n\n```\nhttps://YOUR_SITE/admin/examples\n```\n\n**...et voilà! :)**\n\nNote: out of the box, the table comes only with a _title_ text field, besides the _id_, _deleted_at_, _created_at_ and _updated_at_. Edit your newly created migration file to add any other you may need before runnning the migrate command.\n\n## Options\n\nYou can create all the files and run the migration by running the command with the --migrate option:\n\n```\nphp artisan lg:crud example --migrate\n\nor\n\nphp artisan lg:crud example -m\n```\n\nYou may also specify the name of the default text field 'title' to whatever other you prefer with the --field option:\n\n```\nphp artisan lg:crud example --field=name\n\nor\n\nphp artisan lg:crud example -f name\n```\n\n## Include a menu item\n\nA file named _sidebar-examples.blade.php_ is created in the folder _/resources/views/backend/example/includes_. It contains the html code for a menu item to access your recently created views. You can show it in your sidebar by including the following line in _/resources/views/backend/includes/sidebar.blade.php_ wherever you want it to appear:\n\n```\n@include('backend.example.includes.sidebar-examples')\n```\n\n## Events and Listeners\n\nThe package generates three events and listeners for creating, updating and deleting items methods. In order to get these to work you must resgister them with the event dispatcher, adding this line to your _Providers/EventServiceProvider.php_ file (under _Backend Subscribers_):\n\n```\n\\App\\Listeners\\Backend\\Example\\ExampleEventListener::class\n```\n\n## Language lines\n\nFollowing are the _labels.php_, _menus.php_ and _validation.php_ English language lines needed, copy them into the files in _/resources/lang/en_ or whatever other language folder you may need. Replace _Example_ for the name of your Model.\n\nTODO: generate a file with all the customized language lines ready to copy\u0026paste.\n\n**labels.php** under _'backend'_:\n\n```\n'examples' =\u003e [\n    'management'    =\u003e 'Example Management',\n    'active'        =\u003e 'Active Examples',\n    'view'          =\u003e 'View Example',\n    'edit'          =\u003e 'Edit Example',\n    'create'        =\u003e 'Create Example',\n    'create_new'    =\u003e 'Create New Example',\n    'table'         =\u003e [\n        'title'         =\u003e 'Title',\n        'created'       =\u003e 'Created',\n        'last_updated'  =\u003e 'Last Updated',\n        'deleted'       =\u003e 'Deleted',\n        'actions'       =\u003e 'Actions',\n        'tab_title'     =\u003e 'Overview',\n        'total'         =\u003e 'example total|examples total',\n    ],\n\n    'tabs' =\u003e [\n        'title' =\u003e 'Overview',\n        'content' =\u003e [\n            'overview'  =\u003e [\n                'title'         =\u003e 'Title',\n                'created_at'    =\u003e 'Created',\n                'last_updated'  =\u003e 'Last Updated',\n            ],\n        ],\n    ],\n\n],\n\n_Warning: If you have used the --field option, you should change tabs-\u003econtent-\u003eoverview-\u003etitle to match the field name you have chosen._\n```\n\n**menus.php** under _'backend'_\n\n```\n'examples' =\u003e [\n    'main'            =\u003e 'Examples',\n    'all'             =\u003e 'All Examples',\n    'create'          =\u003e 'Create Example',\n    'deleted'         =\u003e 'Deleted Examples',\n    'view'            =\u003e 'View Example',\n    'edit'            =\u003e 'Edit Example',\n],\n```\n\n**menus.php** under _'backend' =\u003e 'sidebar'_\n\n```\n'examples'  =\u003e 'Examples',\n```\n\n**validation.php** under _'attributes' =\u003e 'backend'_\n\n```\n'examples' =\u003e [\n    'title'            =\u003e 'Title',\n],\n\n_Warning: If you have used the --field option, you should change 'title' to match the field name you have chosen.\n```\n\n**alerts.php** under _'backend'_\n\n```\n'examples' =\u003e [\n    'created'                   =\u003e 'The example was successfully created.',\n    'updated'                   =\u003e 'The example was successfully updated.',\n    'deleted'                   =\u003e 'The example was successfully deleted.',\n    'restored'                  =\u003e 'The example was successfully restored.',\n    'deleted_permanently'       =\u003e 'The example was deleted permanently.',\n],\n```\n\n**buttons.php** under _'backend'_\n\n```\n'examples' =\u003e [\n    'restore' =\u003e 'Restore Example',\n    'delete_permanently'    =\u003e 'Permanently delete Example',\n],\n```\n\n**exceptions.php** under _'backend'_\n\n```\n'examples' =\u003e [\n    'cant_restore'          =\u003e 'This Example is not deleted so it can not be restored.',\n    'delete_first'          =\u003e 'This Example must be deleted first before it can be destroyed permanently.',\n]\n```\n\n## Files created\n\n### Model\n\n```\napp/Models/Example.php\n```\n\n### Trait Attribute\n\n```\napp/Models/Traits/Attribute/ExampleAttribute.php\n```\n\nThis is where the action buttons for the new object are.\n\n### Controller\n\n```\napp/Http/Controllers/Backend/ExampleController.php\n```\n\nIt contains the CRUD methods: _index_, _create_, _store_, _show_, _edit_, _update_, _destroy_, _delete_, _restore_ and _deleted_.\n\n### Repository\n\n```\napp/Repositories/Backend/ExampleRepository.php\n```\n\nContains database logic.\n\n### Requests\n\n```\napp/Http/Requests/Backend/ManageExampleRequest.php\napp/Http/Requests/Backend/StoreExampleRequest.php\napp/Http/Requests/Backend/UpdateExampleRequest.php\n```\n\nValidation manage, store and update Requests.\n\n### Events\n\n```\napp/Events/Backend/Example/ExampleCreated.php\napp/Events/Backend/Example/ExampleUpdated.php\napp/Events/Backend/Example/ExampleDeleted.php\n```\n\n### Listeners\n\n```\napp/Listeners/Backend/Example/ExampleEventListener.php\n```\n\n### Migrations\n\n```\ndatabase/migrations/\\YYYY_MM_DD_create_examples_table.php\n```\n\n### Routes\n\n```\nroutes/backend/examples.php\n```\n\nContains the named routes _admin.examples.index_, _admin.examples.deleted_, _admin.examples.restore_, _delete-permanently_, _admin.examples.create_, _admin.examples.store_, _admin.examples.show_, _admin.examples.edit_, _admin.examples.update_ and _admin.examples.destroy_.\n\n### Breadcrumbs\n\n```\nroutes/breadcrumbs/backend/example.php\n```\n\nThis has the breadcrumbs for the routes\n_admin.examples.index_, _admin.examples.create_, _admin.examples.show_, _admin.examples.edit_ and _admin.examples.deleted_.\n\nThe following line is added to _routes/breadcrumbs/backend/backend.php_:\n\n```\nrequire **DIR**.'/example.php';\n```\n\nIf you delete the _routes/breadcrumbs/backend/example.php_ file created by this command, don't forget to delete this line or your whole project will crash.\n\n### Views\n\n```\nresources/views/backend/example/index.blade.php\nresources/views/backend/example/show.blade.php\nresources/views/backend/example/create.blade.php\nresources/views/backend/example/edit.blade.php\nresources/views/backend/example/deleted.blade.php\nresources/views/backend/example/includes/breadcrumb-links.blade.php\nresources/views/backend/example/includes/header-buttons.blade.php\n```\n\nIf you add more fields to your datatable, you'll have to edit _show.blade.php_, _create.blade.php_ and _edit.blade.php_ to suit your needs.\n\n### Menu item\n\n```\nsidebar-examples.blade.php\n```\n\nHTML code for the menu item for your Laravel 5 starterkit sidebar.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleogopal%2Flaravel-startercrud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleogopal%2Flaravel-startercrud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleogopal%2Flaravel-startercrud/lists"}