{"id":19876216,"url":"https://github.com/miladimos/laravel-repository","last_synced_at":"2025-08-01T23:07:18.235Z","repository":{"id":62528786,"uuid":"291697555","full_name":"miladimos/laravel-repository","owner":"miladimos","description":"Laravel / Lumen Repository pattern [Alpha version]","archived":false,"fork":false,"pushed_at":"2023-10-21T15:46:36.000Z","size":115,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-02T11:43:58.824Z","etag":null,"topics":["laravel","laravel-helpers","laravel-package","laravel-repositories","laravel-repository","laravel-repository-pattern","lumen-package","lumen-repository-pattern","repository-pattern","repository-pattern-maker"],"latest_commit_sha":null,"homepage":"","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/miladimos.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"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},"funding":{"custom":["https://idpay.ir/laravelir"]}},"created_at":"2020-08-31T11:32:33.000Z","updated_at":"2023-10-08T05:22:48.000Z","dependencies_parsed_at":"2022-11-02T14:16:58.618Z","dependency_job_id":"8ebdd9e9-47cc-4a3f-bdf4-15e2a0e6830c","html_url":"https://github.com/miladimos/laravel-repository","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/miladimos/laravel-repository","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miladimos%2Flaravel-repository","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miladimos%2Flaravel-repository/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miladimos%2Flaravel-repository/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miladimos%2Flaravel-repository/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miladimos","download_url":"https://codeload.github.com/miladimos/laravel-repository/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miladimos%2Flaravel-repository/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268310788,"owners_count":24230185,"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":"2025-08-01T02:00:08.611Z","response_time":67,"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","laravel-helpers","laravel-package","laravel-repositories","laravel-repository","laravel-repository-pattern","lumen-package","lumen-repository-pattern","repository-pattern","repository-pattern-maker"],"created_at":"2024-11-12T16:31:22.324Z","updated_at":"2025-08-01T23:07:18.157Z","avatar_url":"https://github.com/miladimos.png","language":"PHP","funding_links":["https://idpay.ir/laravelir"],"categories":[],"sub_categories":[],"readme":"- [![Starts](https://img.shields.io/github/stars/miladimos/laravel-repository?style=flat\u0026logo=github)](https://github.com/miladimos/laravel-repository/forks)\n- [![Forks](https://img.shields.io/github/forks/miladimos/laravel-repository?style=flat\u0026logo=github)](https://github.com/miladimos/laravel-repository/stargazers)\n\n### in your project\n\n`composer require miladimos/laravel-repository`\n\n### for install package\n\n`php artisan repository:install`\n\n### for create new repository\n\n`php artisan make:repository {ModelName}`\n\n### Example:\n\n`php artisan make:repository Tag`\n\nthis create a TagRepository and TagEloquentRepositoryInterface\n\nnext you must add Repository to RepositoryServiceProvider in repositories property like:\n\n```php\nprotected $repositories = [\n    [\n        TagEloquentRepositoryInterface::class,\n        TagRepository::class,\n    ],\n];\n```\n\nnext in your controller add this:\n\n```php\nprivate $tagRepo;\npublic function __construct(TagEloquentRepositoryInterface $tagRepo)\n{\n    $this-\u003etagRepo = $tagRepo;\n}\n\n```\n\nadd custom methods in TagEloquentRepositoryInterface and implement them.\n\nyou must have a provider with below content and register it:\n\n```php\n\u003c?php\n\nnamespace App\\Providers;\n\nuse Illuminate\\Support\\ServiceProvider;\n\nclass RepositoryServiceProvider extends ServiceProvider\n{\n\n    /**\n    * define your repositories here\n    */\n    protected $repositories = [\n        [\n            ModelEloquentRepositoryInterface::class,\n            ModelRepository::class\n        ],\n    ];\n\n    public function register()\n    {\n        foreach ($this-\u003erepositories as $repository) {\n            $this-\u003eapp-\u003ebind($repository[0], $repository[1]);\n        }\n    }\n}\n```\n\nor create it automatically by below command:\n\n```php\nphp artisan make:repository:provider\n```\n\nand add to app.php providers:\n\n```php\nApp\\Providers\\RepositoryServiceProvider::class,\n```\n\n#### Methods:\n\n```php\n$model-\u003eall($columns = ['*']);\n\n$model-\u003ecreate(array $data);\n\n$model-\u003eupdate(array $data, $id, $attribute = \"id\");\n\n$model-\u003efind($id);\n\n$model-\u003efindOrFail($id);\n\n$model-\u003efindWhere(string $field, $condition, $columns);\n\n$model-\u003efirst();\n\n$model-\u003elast();\n\n$model-\u003efirstOrCreate();\n\n$model-\u003ewhereIn($attribute, array $values);\n\n$model-\u003emax($column);\n\n$model-\u003emin($column);\n\n$model-\u003eavg($column);\n\n$model-\u003edelete($id);\n\n$model-\u003etruncate();\n\n$model-\u003ecount($columns = ['*']);\n\n$model-\u003epaginate($columns = ['*'], $perPage = 8);\n\n$model-\u003esimplePaginate($limit = null, $columns = ['*']);\n\n$model-\u003esearch(array $query, $columns = [\"*\"]);\n\n$model-\u003epluck($value, $key = null);\n\n$model-\u003ewith($relations);\n\n$model-\u003etoSql();\n\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiladimos%2Flaravel-repository","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiladimos%2Flaravel-repository","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiladimos%2Flaravel-repository/lists"}