{"id":15106242,"url":"https://github.com/lakasir/has-crud-action","last_synced_at":"2026-01-05T11:03:30.146Z","repository":{"id":256026728,"uuid":"853809140","full_name":"lakasir/has-crud-action","owner":"lakasir","description":"laravel package that provides CRUD actions easily.","archived":false,"fork":false,"pushed_at":"2024-09-19T12:41:25.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-23T01:32:05.977Z","etag":null,"topics":["laravel","library","package-development","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/lakasir.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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":"2024-09-07T15:43:29.000Z","updated_at":"2024-09-19T12:41:28.000Z","dependencies_parsed_at":"2024-09-08T16:33:36.573Z","dependency_job_id":"b8a35faa-1e48-4e21-8efa-abb7acdde035","html_url":"https://github.com/lakasir/has-crud-action","commit_stats":null,"previous_names":["lakasir/has-crud-action"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lakasir/has-crud-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lakasir%2Fhas-crud-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lakasir%2Fhas-crud-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lakasir%2Fhas-crud-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lakasir%2Fhas-crud-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lakasir","download_url":"https://codeload.github.com/lakasir/has-crud-action/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lakasir%2Fhas-crud-action/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28216338,"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","status":"online","status_checked_at":"2026-01-05T02:00:06.358Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["laravel","library","package-development","php"],"created_at":"2024-09-25T21:01:06.498Z","updated_at":"2026-01-05T11:03:30.117Z","avatar_url":"https://github.com/lakasir.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Create Read Update Delete (CRUD) Action\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/lakasir/has-crud-action.svg?style=flat-square)](https://packagist.org/packages/lakasir/has-crud-action)\n[![Total Downloads](https://img.shields.io/packagist/dt/lakasir/has-crud-action.svg?style=flat-square)](https://packagist.org/packages/lakasir/has-crud-action)\n![GitHub Actions](https://github.com/lakasir/has-crud-action/actions/workflows/main.yml/badge.svg)\n\n`has-crud-action` is a laravel package that provides CRUD actions easily.\n\n## Features\n\n* **CRUD** - easily create, read, update, and delete data entities.\n* **Rules** - you can add the rules for your CRUD actions on the fly.\n* **Magic Parameters** - magic parameters that can be used in your actions.\n\n## Getting Started\n\n### Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require lakasir/has-crud-action\n```\n\n### Usage\n\n```php\n// in your routes file\nRoute::resource('suppliers', SupplierController::class);\n\n// in your controller file\nuse Lakasir\\HasCrudAction\\Abstracts\\HasCrudActionAbstract;\nuse App\\Models\\Supplier;\n\nclass SupplierController extends HasCrudActionAbstract\n{\n    public static string $model = Supplier::class;\n}\n```\n\n### Methods\n`rules` the rules method allows you to add your own rules to the action.\n```php\npublic static function rules(): array\n{\n    return [\n        'phone_number' =\u003e 'unique:suppliers,phone_number',\n        'name' =\u003e 'required'\n    ];\n}\n```\n\n`beforeStore` the beforeStore method allows you to modify the data before it is stored.\n```php\npublic static function beforeStore($data, $model): Model\n{\n    $model-\u003ename = strtoupper($data['name']);\n\n    return $model;\n}\n```\n\n`beforeUpdate` the beforeUpdate method allows you to modify the data before it is updated.\n```php\npublic static function beforeUpdate($data, $model): Model\n{\n    $model-\u003ename = strtoupper($data['name']);\n\n    return $model;\n}\n```\n\n`beforeDestroy` the beforeDestroy method allows you to modify the data before it is destroyed.\n```php\npublic static function beforeDestroy($model): Model\n{\n    dd($model);\n\n    return $model;\n}\n```\n\n`response` the response method allows you to modify the response data.\n```php\npublic static function response($record)\n{\n    return [\n        'data' =\u003e $record,\n        'success' =\u003e true,\n    ];\n}\n```\n\n### Magic Parameters\n\n* $id - The ID of the record\n* $method - The HTTP method (GET, POST, PUT, PATCH, DELETE)\n* $model - The model class name\n* $data - The data sent from the request\n* $record - The record object associated with the action\n* $action - The current method action name\n* $route - The current route name\n\n\n### Testing\n\n```bash\ncomposer test\n```\n\n### Todo\n\n* [ ] Pagination support\n* [ ] Filter support\n* [ ] ModifyQuery\n* [ ] Error handler for unsupported magic parameter\n* [ ] Relation support\n* [ ] Unit test\n* [ ] Pipeline\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n### Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email lakasirapp@gmail.com instead of using the issue tracker.\n\n### Credits\n\n-   [lakasir](https://github.com/lakasir)\n-   [All Contributors](../../contributors)\n\n### License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n### Laravel Package Boilerplate\n\nThis package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flakasir%2Fhas-crud-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flakasir%2Fhas-crud-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flakasir%2Fhas-crud-action/lists"}