{"id":13453119,"url":"https://github.com/GrafiteInc/Builder","last_synced_at":"2025-03-24T01:31:11.307Z","repository":{"id":57085666,"uuid":"49742205","full_name":"GrafiteInc/Builder","owner":"GrafiteInc","description":"Prepare your Laravel apps incredibly fast, with various commands, services, facades and boilerplates. ","archived":true,"fork":false,"pushed_at":"2020-01-10T03:50:54.000Z","size":1157,"stargazers_count":987,"open_issues_count":8,"forks_count":110,"subscribers_count":56,"default_branch":"master","last_synced_at":"2025-03-16T01:32:49.305Z","etag":null,"topics":["api","billing","crud","feature-flags","laravel","notifications","socialite","starterkit"],"latest_commit_sha":null,"homepage":"https://builder.grafite.ca","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/GrafiteInc.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-15T20:07:15.000Z","updated_at":"2025-02-22T04:01:32.000Z","dependencies_parsed_at":"2022-08-24T22:50:35.367Z","dependency_job_id":null,"html_url":"https://github.com/GrafiteInc/Builder","commit_stats":null,"previous_names":[],"tags_count":106,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrafiteInc%2FBuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrafiteInc%2FBuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrafiteInc%2FBuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrafiteInc%2FBuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GrafiteInc","download_url":"https://codeload.github.com/GrafiteInc/Builder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245194198,"owners_count":20575723,"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":["api","billing","crud","feature-flags","laravel","notifications","socialite","starterkit"],"created_at":"2024-07-31T08:00:33.345Z","updated_at":"2025-03-24T01:31:10.525Z","avatar_url":"https://github.com/GrafiteInc.png","language":"PHP","readme":"# Grafite Builder\n\n\u003e Grafite has archived this project and no longer supports or develops the code. We recommend using only as a source of ideas for your own code.\n\n**Builder** - A handful of tools for Rapid Laravel Development\n\n[![Build Status](https://travis-ci.org/GrafiteInc/Builder.svg?branch=master)](https://travis-ci.org/GrafiteInc/Builder)\n[![Packagist](https://img.shields.io/packagist/dt/grafite/builder.svg)](https://packagist.org/packages/grafite/builder)\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://packagist.org/packages/grafite/builder)\n\nThis is a set of tools to help speed up development of Laravel apps. You can start an app with various parts prewritten (Users, User Meta, Roles, Teams). And it comes with a powerful FormMaker which can generate form content from tables, and objects. It can generate epic CRUD prototypes rapidly with full testing scripts prepared for you, requiring very little editing. It also provides an elegant Cryptography tool which is URL friendly. Finally it brings along some friends with LaravelCollective as a vendor.\n\n##### Author(s):\n* [Matt Lantz](https://github.com/mlantz) ([@mattylantz](http://twitter.com/mattylantz), mattlantz at gmail dot com)\n\n## General Requirements\n1. PHP 7.1.3+\n2. OpenSSL\n\n## Compatibility and Support\n| Laravel Version | Package Tag | Supported |\n|-----------------|-------------|-----------|\n| 5.7.x | 2.5.x | no |\n| 5.6.x | 2.4.x | no |\n| 5.5.x | 2.3.x | no |\n| 5.4.x | 2.2.x | no |\n| 5.3.x | 2.0.x - 2.1.x | no |\n| 5.1.x - 5.2.x | 1.9.x | no |\n\n## Installation\n\nStart a new Laravel project:\n\n```\nlaravel new {project_name}\n```\nor\n```\ncomposer create-project laravel/laravel {project_name}\n```\n\nThen run the following to add the Grafite Builder\n\n```php\ncomposer require \"grafite/builder\"\n```\n\nTime to publish those assets! Grafite Builder uses CrudMaker and FormMaker which have publishable assets.\n\n```php\nphp artisan vendor:publish\n```\nor\n```php\nphp artisan vendor:publish --provider=\"Yab\\CrudMaker\\CrudMakerProvider\"\nphp artisan vendor:publish --provider=\"Yab\\FormMaker\\FormMakerProvider\"\n```\n\nYou now have Grafite Builder installed. Try out the *Starter Kit*.\n\n### Application Starter Kit\n\n!!! warning \"Make sure you followed the getting started instructions!\"\n\nGrafite Builder provides an elegant solution for starting an application by building the most basic views, controllers, models and migrations for your application. No need to use the `php artisan make:auth` because now you can easily start your whole application with this single command:\n\n```\nphp artisan grafite:starter\n```\n!!! tip \"BUT, before we do that lets get a few things set up.\"\n\nIn order to make use of the \u003cu\u003estarter kit\u003c/u\u003e you will need to modify some files. Check out the modifications below:\n\nAdd the following to your `app/Http/Kernel.php` in the `$routeMiddleware` array.\n\n```php\n'admin' =\u003e \\App\\Http\\Middleware\\Admin::class,\n'permissions' =\u003e \\App\\Http\\Middleware\\Permissions::class,\n'roles' =\u003e \\App\\Http\\Middleware\\Roles::class,\n'active' =\u003e \\App\\Http\\Middleware\\Active::class,\n```\n\nIf you don't want to worry about email activation then remove this from the route's middleware array:\n```php\n'active'\n```\n\nUpdate the `App\\User::class` in: 'config/auth.php' and 'database/factories/UserFactory.php' to this:\n\n```php\nApp\\Models\\User::class\n```\n\nAdd the following to 'app/Providers/AuthServiceProvider.php' in the boot method\n\n```php\nGate::define('admin', function ($user) {\n    return ($user-\u003eroles-\u003efirst()-\u003ename === 'admin');\n});\n\nGate::define('team-member', function ($user, $team) {\n    return ($user-\u003eteams-\u003efind($team-\u003eid));\n});\n```\n\nAdd the following to 'app/Providers/EventServiceProvider.php' in the $listen property\n\n```php\n'App\\Events\\UserRegisteredEmail' =\u003e [\n    'App\\Listeners\\UserRegisteredEmailListener',\n],\n```\n\nYou will want to create an sqlite memory test database in the `config/database.php`\n\n```php\n'testing' =\u003e [\n    'driver'   =\u003e 'sqlite',\n    'database' =\u003e ':memory:',\n    'prefix'   =\u003e '',\n],\n```\n\nAdd the following line to the 'phpunit.xml' file\n```xml\n\u003cenv name=\"DB_CONNECTION\" value=\"testing\"/\u003e\n\u003cenv name=\"MAIL_DRIVER\" value=\"log\"/\u003e\n```\n\n### Regarding Email Activation\n\nThe Starter kit has an email activation component added to the app to ensure your users have validated their email address.\nYou can disable it by removing the `active` middleware from the `web` routes. You will also have to disable the Notification but it\nwon't cause any problems if you remove the email activation.\n\n### For Laravel 5.2 and later\nYou will also need to set the location of the email for password reminders. (config/auth.php - at the bottom)\n\n```php\n'passwords' =\u003e [\n    'users' =\u003e [\n        'provider' =\u003e 'users',\n        'email' =\u003e 'emails.password',\n        'table' =\u003e 'password_resets',\n        'expire' =\u003e 60,\n    ],\n],\n```\n\n#### Things to note\nYou may try and start quickly by testing the registration but please make sure your app's \u003cu\u003eemail\u003c/u\u003e is configured or it will throw an exception.\nYou can do this in the `.env` file easily by setting it to 'log' temporarily\n\n```php\nMAIL_DRIVER=log\n```\n\n#### Last Steps\n\nOnce you've added in all these parts you will want to run the starter command!\n\n```php\nphp artisan grafite:starter\n```\n\nThen you'll have to refresh the list of all classes that need to be included in the project.\n\n```php\ncomposer dump-autoload\n```\n\nThen you'll need to migrate to add in the users, user meta, roles and teams tables. The seeding is run to set the initial roles for your application.\n\n```php\nphp artisan migrate --seed\n```\n\nOnce you get the starter kit running you can register and login to your app. You can then you can visit the settings section of the app and set your role to admin to take full control of the app.\n\n### What Starter Publishes\n\n#### Controllers\nGrafite Builder updated the basic controllers to handle things like creating a profile when a user is registered, as well as setting default return routes to `dashboard` etc. It also provides contollers for handling profile modifications and pages, team management etc. The admin controller handles the admin of users, modifying a user provided the user has the admin role.\n\n* app/Http/Controllers/\n    * Admin/\n        * DashboardController.php\n        * UserController.php\n        * RoleController.php\n    * Auth/\n        * ActivateController.php\n        * ForgotPasswordController.php\n        * LoginController.php\n        * RegisterController.php\n        * ResetPasswordController.php\n    * User/\n        * PasswordController.php\n        * SettingsController.php\n    * PagesController.php\n    * TeamController.php\n\n#### Middleware\nGrafite Builder overwrites the default middleware due to changes in the redirects. It also provides the `Admin` middleware for route level protection relative to roles.\n\n* app/Http/Middleware/\n    * Active.php\n    * Admin.php\n    * Permissions.php\n    * RedirectIfAuthenticated.php\n    * Roles.php\n\n#### Requests\nThere are requests provided for handling the creation of Teams and updating of all components. Here we integrate the rules required that are able to run the validations and return errors. (If you're using Grafite Builder FormMaker Facade then it will even handling accepting the errors and highlighting the appropriate fields.)\n\n* app/Http/Requests/\n    * PasswordUpdateRequest.php\n    * RoleCreateRequest.php\n    * TeamCreateRequest.php\n    * TeamUpdateRequest.php\n    * UserInviteRequest.php\n    * UserUpdateRequest.php\n\n#### Routes\nGiven that there are numerous routes added to handle teams, profiles, password etc all routes are overwritten with the starter kit.\n\n* routes/web.php\n\n#### Config\nThe permissions config file is published, this is a way for you to set access levels and types of permissions `Roles` can have\n\n* config/permissions.php\n\n#### Events\nThe events for various actions.\n\n* app/Events/\n    * UserRegisteredEmail.php\n\n#### Listeners\nThe event listeners for various actions.\n\n* app/Listeners/\n    * UserRegisteredEmailListener.php\n\n#### Models\nModels are obvious, but when we then integrate Services below which handle all the buisness logic etc which make the calls to the models we implement SOLID practices, the Controller, Console or other Service, which calls the service only accesses the model through it. Once these have been integrated please ensure you delete the `User.php` model file and ensure that you have followed the installation and config instructions.\n\n* app/Models/\n    * UserMeta.php\n    * User.php\n    * Team.php\n    * Role.php\n\n#### Notifications\nThese are all our emails that we need to send out to the users in the application. These are amazing since they use the power of Laravel's notifcation component.\n\n* app/Notficiations/\n    * ActivateUserEmail.php\n    * NewAccountEmail.php\n    * ResetPasswordEmail.php\n\n#### Services\nService structure allows us to keep the buisness logic outside of the models, and controllers. This approach is best suited for apps that may wish to integrate an API down the road or other things. It also allows for a highly testable structure to the application.\n\n* app/Services/\n    * Traits/\n        * HasRoles.php\n        * HasTeams.php\n    * ActivateService.php\n    * RoleService.php\n    * TeamService.php\n    * UserService.php\n\n#### Database\nPlease ensure that all migrations and seeds are run post installation. These seeds set the default roles available in your application.\n\n* database/factories/\n    * RoleFactory.php\n    * TeamFactory.php\n    * UserFactory.php\n    * UserMetaFactory.php\n* database/migrations/\n    * 2015_11_30_191713_create_user_meta_table.php\n    * 2015_11_30_215038_create_roles_table.php\n    * 2015_11_30_215040_create_role_user_table.php\n    * 2015_12_04_155900_create_teams_table.php\n    * 2015_12_04_155900_create_teams_users_table.php\n* database/seeds/\n    * DatabaseSeeder.php\n    * RolesTableSeeder.php\n    * UserTableSeeder.php\n\n#### Views\nThe views consist of as little HTML as possible to perform the logical actions. These are intended to be the most basic, and all of which are intended to be modified.\n\n* resources/views/\n    * admin/\n        * roles/\n            * edit.blade.php\n            * index.blade.php\n            * invite.blade.php\n        * users/\n            * edit.blade.php\n            * index.blade.php\n            * invite.blade.php\n        * dashboard.blade.php\n    * auth/\n        * activate/\n            * email.blade.php\n            * token.blade.php\n        * passwords/\n            * email.blade.php\n            * reset.blade.php\n        * login.blade.php\n        * register.blade.php\n    * errors/\n        * 401.blade.php\n        * 404.blade.php\n        * 503.blade.php\n    * partials/\n        * errors.blade.php\n        * message.blade.php\n        * status.blade.php\n    * team/\n        * create.blade.php\n        * edit.blade.php\n        * index.blade.php\n        * show.blade.php\n    * user/\n        * meta.blade.php\n        * password.blade.php\n        * settings.blade.php\n    * dashboard.blade.php\n\n#### Tests\nGrafite Builder starter kit provides the basic unit tests for each of its own parts. This provides some great examples of testing for building an application quickly.\n\n* tests/\n    * Feature/\n        * TeamIntegrationTest.php\n    * Unit/\n        * UserServiceTest.php\n        * TeamServiceTest.php\n        * RoleServiceTest.php\n\n## After Setup\n\n### Dashboard access\n\nThe application dashboard is found by browsing to the /dashboard endpoint.\nThe default admin user login credentials are:\n\n* email: admin@example.com\n* password: admin\n\n### User\n\nThe user model is expanded with Grafite Builder Starter Kit. It adds to the basic user model: roles, teams, and user meta. The relationships are as follows:\n\n* Meta: hasOne\n* Roles: belongsToMany\n* Team: belongsToMany\n\nIt also provides the following methods:\n\n```\nmeta() // The relationship method\nroles() // The relationship method\nhasRole(role_name) // checks if user has role\nteams() // The relationship method\nisTeamMember(team_id) // checks if user is member\nisTeamAdmin(team_id) // checks if user is admin level member\n```\n\n### Middleware\n\n#### Admin\nThe Admin middleware acts as a tool for setting admin level permissions on the routes or controller level.\n\n```\n['middleware' =\u003e 'admin']\n```\n\nThis simple addition to a route will ensure the user has access to the admin level, if not it will return them from where they came.\n\n#### Active\nThe Active middleware acts checks if the account as been activated by accessing the activate url with the emailed token.\n\n```\n['middleware' =\u003e 'active']\n```\n\nThis simple addition to a route will ensure the user has an activated account, if not it will redirect them to the /active page so they can request another activation token if necessary.\n\n#### Roles\nThe Roles middleware allows you to set custom roles for your routes.\n\n```\n['middleware' =\u003e 'roles:admin|member']\n```\n\n#### Permissions\nThe Permissions middleware allows you to set custom permissions (a subset of roles) for your routes\n\n```\n['middleware' =\u003e 'permissions:admin|somethingDescriptive']\n```\n\nYou can set permissions in the `config/permissions.php`\n\n### Bootstrap UI\n\n!!! Tip \"Bootstrap Version 4\"\n\nIf you feel like opting in for the Application starter kit. You also have a great bootstrapping option for the views. You can blast through the initial building of an app and hit the ground running!\n\n```\nphp artisan grafite:bootstrap\n```\n\n!!! Tip \"This will also ensure that your webpack file is prepared to run\"\n\n#### What Boostrap Publishes\n\nThe command will overwrite any existing files with the bootstrap version of them:\n\n* resources/views/\n    * user/\n        * meta.blade.php\n        * password.blade.php\n        * settings.blade.php\n    * admin/\n        * users/\n            * edit.blade.php\n            * index.blade.php\n            * invite.blade.php\n    * auth/\n        * login.blade.php\n        * password.blade.php\n        * register.blade.php\n        * reset.blade.php\n    * dashboard/\n        * main.blade.php\n        * panel.blade.php\n    * emails/\n        * new-user.blade.php\n        * password.blade.php\n    * errors/\n        * 404.blade.php\n        * 503.blade.php\n    * partials/\n        * errors.blade.php\n        * message.blade.php\n    * team/\n        * create.blade.php\n        * edit.blade.php\n        * index.blade.php\n        * show.blade.php\n\n### Application Activities\n\nSometimes its handy to know what your users are up to when they browse your site or application. The Activity kit gives you everything you need to track your users and their every action. The middleware does most of it for you, but your welcome to customize it to fit your needs.\n\n#### Setup\n\n```php\nphp artisan grafite:activity\n```\n\nAdd to your `config/app.php` the following:\n\n```php\nApp\\Providers\\ActivityServiceProvider::class,\n```\n\n##### Facades\nProvides the following tool for in app features:\n\n```php\nActivity::log($description);\nActivity::getByUser($userId);\n```\n\n##### Helper\n\n```php\nactivity($description) // will log the activity\n```\n\n### Application Features\n\nSometimes what we need is a simple way to toggle parts of an app on and off, or hey, maybe the client wants it. Either way, using the feature management kit can\ntake care of all that. Now you or your clients can toggle signups on an off, or any other features in the app. Just utilize the blade or helper components to take full control of your app.\n\n#### Setup\n\n```php\nphp artisan grafite:features\n```\n\nYou may want to add this line to your navigation:\n\n```html\n\u003cli class=\"nav-item\"\u003e\u003ca class=\"nav-link\" href=\"{!! url('admin/features') !!}\"\u003e\u003cspan class=\"fa fa-cog\"\u003e\u003c/span\u003e Features\u003c/a\u003e\u003c/li\u003e\n```\n\nAdd to your `config/app.php` the following:\n\n```php\nApp\\Providers\\FeatureServiceProvider::class,\n```\n\nAdd this to the `app/Providers/RouteServiceProvider.php` in the `mapWebRoutes(Router $router)` function:\n\n```php\nrequire base_path('routes/features.php');\n```\n\n##### Facades\nProvides the following tool for in app features:\n\n```php\nFeatures::isActive($key);\n```\n\n##### Blade\n\n```php\n@feature($key)\n// code goes here\n@endfeature\n```\n\n##### Helper\n\n```php\nfeature($key) // will return true|false\n```\n\n##### What Features Publishes:\n\nThe command will overwrite any existing files with the features version of them:\n\n* app/Facades/Features.php\n* app/Http/Controllers/Admin/FeatureController.php\n* app/Http/Requests/FeatureCreateRequest.php\n* app/Http/Requests/FeatureUpdateRequest.php\n* app/Models/Feature.php\n* app/Providers/FeatureServiceProvider.php\n* app/Services/FeatureService.php\n* database/migrations/2016_04_14_210036_create_features_table.php\n* resources/views/admin/features/create.blade.php\n* resources/views/admin/features/edit.blade.php\n* resources/views/admin/features/index.blade.php\n* routes/features.php\n* tests/Feature/FeatureIntegrationTest.php\n* tests/Unit/FeatureServiceTest.php\n\n### Application Logs\n\nThe logs tool simply add a view of the app logs to your admin panel. This can be of assistance durring development or in keeping an application in check.\n\n#### Setup\n\n```php\nphp artisan grafite:logs\n```\n\nYou may want to add this line to your navigation:\n\n```html\n\u003cli class=\"nav-item\"\u003e\u003ca href=\"{!! url('admin/logs') !!}\"\u003e\u003cspan class=\"fa fa-line-chart\"\u003e\u003c/span\u003e Logs\u003c/a\u003e\u003c/li\u003e\n```\n\nAdd this to the `app/Providers/RouteServiceProvider.php` in the `mapWebRoutes(Router $router)` function:\n\n```php\nrequire base_path('routes/logs.php');\n```\n\n### Application Notifications\n\nGrafite Builder's notifications will build a basic controller, service, and views for both users and admins so you can easily notifiy your users, in bulk or specifically.\n\n##### Setup\n\n```php\nphp artisan grafite:notifications\n```\n\nYou may want to add this line to your navigation:\n\n```html\n\u003cli\u003e\u003ca href=\"{!! url('user/notifications') !!}\"\u003e\u003cspan class=\"fa fa-envelope-o\"\u003e\u003c/span\u003e Notifications\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"{!! url('admin/notifications') !!}\"\u003e\u003cspan class=\"fa fa-envelope-o\"\u003e\u003c/span\u003e Notifications\u003c/a\u003e\u003c/li\u003e\n```\n\nAdd this to the `app/Providers/RouteServiceProvider.php` in the `mapWebRoutes(Router $router)` function:\n\n```php\nrequire base_path('routes/notification.php');\n```\n\n##### Facades\nProvides the following tool for in app notifications:\n\n```php\nNotifications::notify($userId, $flag, $title, $details);\n```\n\n\u003csmall\u003eFlags can be any bootstrap alert: default, info, success, warning, danger\u003c/small\u003e\n\n##### What Notifications Publishes:\n\nThe command will overwrite any existing files with the notification version of them:\n\n* app/Facades/Notifications.php\n* app/Http/Controllers/Admin/NotificationController.php\n* app/Http/Controllers/User/NotificationController.php\n* app/Http/Requests/NotificationRequest.php\n* app/Models/Notification.php\n* app/Services/NotificationService.php\n* database/migrations/2016_04_14_180036_create_notifications_table.php\n* resources/views/admin/notifications/create.blade.php\n* resources/views/admin/notifications/edit.blade.php\n* resources/views/admin/notifications/index.blade.php\n* resources/views/notifications/index.blade.php\n* resources/views/notifications/show.blade.php\n* routes/notification.php\n* tests/NotificationIntegrationTest.php\n* tests/NotificationServiceTest.php\n\n### Forge Integration\n\nThe FORGE component provides you with access to the FORGE API in your admin panel. Rather than having to log into FORGE for each adjustment, now\nyou can simply log into your own application and in the admin panel adjust the scheduler, or workers on your server configuration.\n\n##### Requires\n```php\ncomposer require themsaid/forge-sdk\n```\n\n##### Setup\n\n```php\nphp artisan grafite:forge\n```\n\nYou may want to add this line to your navigation:\n\n```html\n\u003cli class=\"nav-item\"\u003e\u003ca href=\"{{ url('admin/forge/settings') }}\"\u003e\u003cspan class=\"fa fa-fw fa-server\"\u003e\u003c/span\u003e Forge Settings\u003c/a\u003e\u003c/li\u003e\n\u003cli class=\"nav-item\"\u003e\u003ca href=\"{{ url('admin/forge/scheduler') }}\"\u003e\u003cspan class=\"fa fa-fw fa-calendar\"\u003e\u003c/span\u003e Forge Calendar\u003c/a\u003e\u003c/li\u003e\n\u003cli class=\"nav-item\"\u003e\u003ca href=\"{{ url('admin/forge/workers') }}\"\u003e\u003cspan class=\"fa fa-fw fa-cogs\"\u003e\u003c/span\u003e Forge Workers\u003c/a\u003e\u003c/li\u003e\n```\n\nAdd this to the `app/Providers/RouteServiceProvider.php` in the `mapWebRoutes(Router $router)` function:\n\nYou will see a line like: `-\u003egroup(base_path('routes/web.php'));`\n\nYou need to change it to resemble this:\n```php\n-\u003egroup(function () {\n    require base_path('routes/web.php');\n    require base_path('routes/forge.php');\n}\n```\n\nAdd these to the .env:\n```php\nFORGE_TOKEN=\nFORGE_SERVER_ID=\nFORGE_SITE_ID=\n```\n\n### Application API\n\nIf you feel like opting in for the Laracogs starter kit. You can also easily build in an API layer. Running the \u003ccode\u003egrafite:api\u003c/code\u003e command will set up the bare bones components, but you can also use the API tools as a part of the CRUD now by using the \u003ccode\u003e--api\u003c/code\u003e option.\n\n##### Requires\n```php\ncomposer require tymon/jwt-auth\n```\n\n##### Setup\n```\nphp artisan grafite:api\n```\n\nEssentially you want to do all the basic setup for JWT such as everything in here:\nThen follow the directions regarding installation on: [https://github.com/tymondesigns/jwt-auth/wiki/Installation](https://github.com/tymondesigns/jwt-auth/wiki/Installation)\n\nAdd this to the `app/Providers/RouteServiceProvider.php` file in the `mapWebRoutes(Router $router)` function:\n```php\nrequire base_path('routes/api.php');\n```\n\nAdd to the app/Http/Kernal.php under routeMiddleware:\n```php\n'jwt.auth' =\u003e \\Tymon\\JWTAuth\\Middleware\\GetUserFromToken::class,\n'jwt.refresh' =\u003e \\Tymon\\JWTAuth\\Middleware\\RefreshToken::class,\n```\n\nAdd to except attribute the app/Http/Middleware/VerifyCsrfToken.php (You also have to do this for CRUDs you add):\n```php\n'api/v1/login',\n'api/v1/user/profile',\n```\n\nIf you use Apache add this to the .htaccess file:\n```php\nRewriteEngine On\nRewriteCond %{HTTP:Authorization} ^(.*)\nRewriteRule .* - [e=HTTP_AUTHORIZATION:%1]\n```\n\nAlso update your jwt config file and set the user to:\n\n```php\n\\App\\Models\\User::class\n```\n\n##### What API publishes\nThe command will overwrite any existing files with the api version of them:\n\n* app/Http/Controllers/Api/AuthController.php\n* app/Http/Controllers/Api/UserController.php\n* routes/api.php\n\n### Application Queue\n\nHorizon is amazing if you've got a redis instance configured and are running your queue through that, but not all apps need that nor do that have to start there.\nIf you've got a database driven queue and are looking for an easy management component to handle job retrying and cancellations then this will be a perfect\naddition to your app.\n\n##### Setup\n\n```php\nphp artisan grafite:queue\n```\n\nAdd this to the `app/Providers/RouteServiceProvider.php` in the `mapWebRoutes(Router $router)` function:\n\n```php\nrequire base_path('routes/queue.php');\n```\n\nYou may want to add this line to your navigation:\n\n```html\n\u003cli\u003e\u003ca href=\"{!! url('admin/queue') !!}\"\u003e\u003cspan class=\"fa fa-list\"\u003e\u003c/span\u003e Queue\u003c/a\u003e\u003c/li\u003e\n```\n\n### Social Media Logins\n\nIf you're looking to offer social media logins on your application and want a simple way to get started then look no further. Simply run the command and follow the steps below and you'll have GitHub login out of the box. Integrating Facebook etc afterward is easy when you look at the code base.\n\n##### Requires\n```php\ncomposer require laravel/socialite\n```\n\n##### Setup\n```\nphp artisan grafite:socialite\n```\n\nThe next step is to prepare your app with socialite:\n\nAdd this to your app config under providers:\n```php\nLaravel\\Socialite\\SocialiteServiceProvider::class\n```\n\nAdd this to your app config under aliases:\n```php\n'Socialite' =\u003e Laravel\\Socialite\\Facades\\Socialite::class,\n```\n\nAdd `require base_path('routes/socialite.php');` to the `app/Providers/RouteServiceProvider.php` in the `mapWebRoutes(Router $router)` function:\n```php\nRoute::middleware('web')\n    -\u003enamespace($this-\u003enamespace)\n    -\u003egroup(function () {\n        require base_path('routes/socialite.php');\n        require base_path('routes/web.php');\n    });\n```\n\nFinally set the access details in the services config:\n```php\n'github' =\u003e [\n    'client_id' =\u003e 'id code',\n    'client_secret' =\u003e 'secret code',\n    'redirect' =\u003e 'http://your-domain/auth/github/callback',\n    'scopes' =\u003e ['user:email'],\n],\n```\n\n##### What Socialite publishes\nThe command will overwrite any existing files with the socialite version of them:\n\n* app/Http/Controllers/Auth/SocialiteAuthController.php\n* routes/socialite.php\n\n### Application Billing\n\nIf you feel like opting in for the Grafite Builder starter kit. You can also get your app's billing handled quickly with Grafite Builder billing command and `Laravel/Cashier`. Grafite Builder's billing will build a basic controller, views etc so you can stay focused on what makes your application amazing!\n\n##### Requires\n```php\ncomposer require laravel/cashier\n```\n\n##### Setup\n```\nphp artisan grafite:billing\n```\n\nYou have to modify the `app/Providers/RouteServiceProvider.php` in the `mapWebRoutes(Router $router)` function:\n\nYou will see a line like: `-\u003egroup(base_path('routes/web.php'));`\n\nYou need to change it to resemble this:\n```php\n-\u003egroup(function () {\n    require base_path('routes/web.php');\n    require base_path('routes/billing.php');\n}\n```\n\nAdd these to the .env:\n```php\nSUBSCRIPTION=app_basic\nSTRIPE_SECRET=secret-key\nSTRIPE_PUBLIC=public-key\n```\n\nAdd this to the app/Providers/AuthServiceProvider.php:\n```php\nGate::define('access-billing', function ($user) {\n    return ($user-\u003emeta-\u003esubscribed('main') \u0026\u0026 is_null($user-\u003emeta-\u003esubscription('main')-\u003eendDate));\n});\n```\n\nAnd for the `config/services.php` you will want yours to resemble:\n```php\n'stripe' =\u003e [\n    'model'  =\u003e App\\Models\\UserMeta::class,\n    'key'    =\u003e env('STRIPE_PUBLIC'),\n    'secret' =\u003e env('STRIPE_SECRET'),\n],\n```\n\nFinally run migrate to add the subscriptions and bind them to the user meta:\n```php\nphp artisan migrate\n```\n\nYou will also want to update your webpack mix file to resemble (webpack.mix.js):\n```js\n.js([\n    'resources/assets/js/app.js',\n    'resources/assets/js/card.js',\n    'resources/assets/js/subscription.js'\n], 'public/js');\n```\n\n##### After Setup\nYou may want to add this line to your navigation:\n\n```php\n\u003cli\u003e\u003ca href=\"{{ url('user/billing/details') }}\"\u003e\u003cspan class=\"fa fa-dollar\"\u003e\u003c/span\u003e Billing\u003c/a\u003e\u003c/li\u003e\n```\n\n##### Notes\nYou may want to switch the line in the view vendor.receipt to:\n\n```php\n\u003cstrong\u003eTo:\u003c/strong\u003e {{ $user-\u003euser()-\u003eemail }}\n```\n\nWe do this because rather than bind the billing to the User, we bound it to the UserMeta.\n\n##### What Billing Publishes\n\nThe command will overwrite any existing files with the billing version of them:\n\n* app/Http/Controllers/User/BillingController.php\n* app/Models/UserMeta.php\n* config/invoice.php\n* config/plans.php\n* database/migrations/2016_02_26_000647_create_subscriptions_table.php\n* database/migrations/2016_02_26_000658_add_billings_to_user_meta.php\n* resources/assets/js/card.js\n* resources/assets/js/subscription.js\n* resources/views/billing/card-form.blade.php\n* resources/views/billing/change-card.blade.php\n* resources/views/billing/details.blade.php\n* resources/views/billing/invoices.blade.php\n* resources/views/billing/coupons.blade.php\n* resources/views/billing/subscribe.blade.php\n* resources/views/billing/tabs.blade.php\n* routes/billing.php\n\n##### Accounts\n\nThe Account service is a tool for handling your subscription details, meaning you can limit your applications based on various clauses using the plans config. You're free to set these plan details restricting things within a billing cycle or just in general.\n\nThese are relative to *billing* only. They provide extra tools for handling restrictions in your application based on the plan the user subscribed to. Unless you implment the cashier billing system with the UserMeta structure provided by Laracogs it will not benefit you.\n\n##### Config\nThis is the basic config for `config/plans.php`. This is for a single plan, either be subscribed or not.\n\n!!! tip \"Remember you need to have corresponding plans on Stripe ex. app_basic by default\"\n\n```\n'subscription' =\u003e env('SUBSCRIPTION'),\n'subscription_name' =\u003e 'main',\n'plans' =\u003e [\n    'app_basic' =\u003e [\n        'access' =\u003e [\n            'some name'\n        ],\n        'limits' =\u003e [\n            'Model\\Namespace' =\u003e 5,\n            'pivot_table' =\u003e 1\n        ],\n        'credits' =\u003e [\n            'column' =\u003e 'credits_spent',\n            'limit' =\u003e 10\n        ],\n        'custom' =\u003e [\n            'anything' =\u003e 'anything'\n        ],\n    ],\n]\n```\n\n##### Multiple Plans\n\nIn this config you can define multiple plans which can have different rules per plan. By default the kit uses a single plan. You can define this in the env as mentioned above. But if you want to do multiple plans you can change the following code:\n\n1. Line 45 of the `BillingController.php` change `config('plans.subscription')` to: `$payload['plan']`\n2. Add `name`, and `stripe_id` to the config\n```\n'subscription_name' =\u003e 'main',\n'plans' =\u003e [\n    'basic' =\u003e [\n        'name' =\u003e 'Basic Subscription',\n        'stripe_id' =\u003e 'basic_subscription',\n        'access' =\u003e [\n            'some name'\n        ],\n        'limits' =\u003e [\n            'Model\\Namespace' =\u003e 5,\n            'pivot_table' =\u003e 1\n        ],\n        'credits' =\u003e [\n            'column' =\u003e 'credits_spent',\n            'limit' =\u003e 10\n        ],\n        'custom' =\u003e [\n            'anything' =\u003e 'anything'\n        ],\n    ],\n]\n```\n3. Then add the following code in `resources/views/billing/subscribe.blade.php` above the card form include:\n\n```html\n\u003cdiv class=\"form-group\"\u003e\n    \u003clabel class=\"form-label\" for=\"plan\"\u003ePlan\u003c/label\u003e\n    \u003cselect class=\"form-control\" name=\"plan\" id=\"plan\"\u003e\n        @foreach (config('plans.plans') as $plan)\n            \u003coption value=\"{{ $plan['stripe_id'] }}\"\u003e{{ $plan['name'] }}\u003c/option\u003e\n        @endforeach\n    \u003c/select\u003e\n\u003c/div\u003e\n```\n\n!!! tip \"You may also want to add a component to your app to allow users to switch plans. You can use the swap method to achieve this: `auth()-\u003euser()-\u003emeta-\u003esubscription(config('plans.subscription_name'))-\u003eswap($request-\u003eplan)`\"\n\n##### Service Methods\n\n\u003cbr\u003e\n#### currentBillingCycle()\nBy using this method at the beginning and chaining another method after it you enable the restriction of the query to be performed but restricting itself to the current billing cycle.\n\n\u003cbr\u003e\n#### canAccess($area)\nReturns a boolean if the user can enter\n\n\u003cbr\u003e\n#### cannotAccess($area)\nReturns a boolean if the user cannot enter\n\n\u003cbr\u003e\n#### getClause($key)\nReturns the specified clause of the plans\n\n\u003cbr\u003e\n#### getLimit($model)\nReturns the specified limit of a model or pivot table\n\n\u003cbr\u003e\n#### withinLimit($model, $key = 'user_id', $value = {user's id})\nConfirms that the specified model only has the specified amount collected by the $key and $value.\n* If you add the `currentBillingCycle()` before this then it would add the further restrictions.\n\n\u003cbr\u003e\n#### creditsUsed($model, $key = 'user_id', $value = {user's id})\nReports back the specified amount collected by the $key and $value.\n* If you add the `currentBillingCycle()` before this then it would add the further restrictions.\n\n\u003cbr\u003e\n#### creditsAvailable($model)\nReturns the number of credits remaining based on the config and the previous method.\n* If you add the `currentBillingCycle()` before this then it would add the further restrictions.\n\n\u003cbr\u003e\n#### clause($key, $method, $model = null)\nPerforms a custom method with rules defined by the clause name in the config. The Closure method in this is provided with the following parameters: $user, $subscription, $clause, $query\n\n## License\nGrafite Builder is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)\n\n### Bug Reporting and Feature Requests\nPlease add as many details as possible regarding submission of issues and feature requests\n\n### Disclaimer\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["Starter Projects","PHP","Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGrafiteInc%2FBuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGrafiteInc%2FBuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGrafiteInc%2FBuilder/lists"}