{"id":15740346,"url":"https://github.com/michaeltintiuc/laravel-component","last_synced_at":"2026-05-05T05:33:19.436Z","repository":{"id":62528094,"uuid":"76407396","full_name":"michaeltintiuc/laravel-component","owner":"michaeltintiuc","description":":bulb: Several starter interfaces and abstract classes for laravel projects","archived":false,"fork":false,"pushed_at":"2017-10-05T19:59:42.000Z","size":42,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-06T09:23:00.286Z","etag":null,"topics":["abstract","boilerplate","helper","interface","laravel"],"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/michaeltintiuc.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}},"created_at":"2016-12-13T23:35:56.000Z","updated_at":"2017-07-16T21:31:01.000Z","dependencies_parsed_at":"2022-11-02T14:16:49.377Z","dependency_job_id":null,"html_url":"https://github.com/michaeltintiuc/laravel-component","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/michaeltintiuc%2Flaravel-component","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeltintiuc%2Flaravel-component/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeltintiuc%2Flaravel-component/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeltintiuc%2Flaravel-component/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaeltintiuc","download_url":"https://codeload.github.com/michaeltintiuc/laravel-component/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246418644,"owners_count":20773938,"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":["abstract","boilerplate","helper","interface","laravel"],"created_at":"2024-10-04T02:20:55.626Z","updated_at":"2026-05-05T05:33:14.418Z","avatar_url":"https://github.com/michaeltintiuc.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# laravel-component\n:bulb: Several starter interfaces and abstract classes for laravel projects\n\n## Contents\n1. [Installation](#installation)\n2. [Usage](#usage)\n3. [Contribution](#contribution)\n\n## Installation\n\nRequire via composer\n```shell\ncomposer require michaeltintiuc/laravel-component\n``````\n\n## Usage\n\n### Directory structure\n`app/Components/` - holds all component dirs like Users, Posts, Tags, etc\n\n`app/Components/Users` - holds the model class (i.e. User) and all environment dirs like Admin, Site, etc\n\n`app/Components/Users/{ENV}` - holds all classes and `routes.php` related to the environment specific implementation of a component\n\n`app/Components/Users/{ENV}/Requests` - holds form validation classes specific to an environment and component\n\n---\n### Controllers\n```php\nnamespace Acme\\Components\\Users\\Admin;\n\nuse Illuminate\\Http\\Request;\nuse MichaelT\\Component\\Admin\\ComponentController;\n\nclass UsersController extends ComponentController\n{\n    public function __construct(Request $request, PostTagsRepo $repo)\n    {\n        parent::__construct($request, $repo);\n        $this-\u003esetComponent('user');\n        $this-\u003esetBaseView('admin.users');\n        $this-\u003esetSearchRoute('admin.users.index');\n    }\n\n    public function index(Request $request)\n    {\n        if ($request-\u003ehas('search')) {\n            return $this-\u003esearch($request-\u003esearch);\n        }\n\n        $this-\u003esetTitle('All users');\n        $this-\u003esetHeading('Users list');\n        $users = $this-\u003erepo-\u003eall();\n\n        return $this-\u003eview('index')\n            -\u003ewith(compact('users'));\n    }\n    \n    ...\n}\n```\n\n---\n### Repositories\n#### Interfaces _aka_ Contracts\n```php\nnamespace Acme\\Components\\Users\\Admin;\n\nuse MichaelT\\Component\\Admin\\Contracts\\RepoContract;\nuse MichaelT\\Component\\Admin\\Contracts\\Searchable;\n\ninterface UsersRepoContract extends RepoContract, Searchable\n{\n}\n```\n\n#### Repository\n```php\nnamespace Acme\\Components\\Users\\Admin;\n\nuse Acme\\Components\\Users\\User;\nuse MichaelT\\Component\\Admin\\ComponentRepo;\nuse Acme\\Components\\Users\\Admin\\UsersRepoContract;\n\nclass UsersRepo extends ComponentRepo implements UsersRepoContract\n{\n    public function __construct(User $model)\n    {\n        parent::__construct($model);\n        $this-\u003esetComponent('user');\n    }\n\n    public function all()\n    {\n        return $this-\u003emodel-\u003eget();\n    }\n\n    public function paginate()\n    {\n        return $this-\u003emodel\n            -\u003epaginate($this-\u003egetPerPage());\n    }\n\n    public function find($id)\n    {\n        try {\n            return $this-\u003emodel-\u003efindOrFail($id);\n        } catch (\\Exception $e) {\n            throw new \\FindAdminException($this-\u003eerror('find'));\n        }\n    }\n    \n    ...\n}\n```\n\n---\n### Routes\n#### Component\n```php\nRoute::group(['namespace' =\u003e 'Acme\\Components\\Users\\Admin'], function () {\n    Route::resource('users', 'UsersController');\n});\n```\n\n#### Loading routes\n```php\nRoute::group(['prefix' =\u003e 'admin', 'as' =\u003e 'admin.'], function () {\n    Route::group(['middleware' =\u003e ['auth']], function () {\n        require_once app_path().'/Components/Users/Admin/routes.php';\n    });\n});\n```\n\n---\n### Contribution\n\nContributions, bug-reports, feature and pull requests are always welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaeltintiuc%2Flaravel-component","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaeltintiuc%2Flaravel-component","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaeltintiuc%2Flaravel-component/lists"}