PHPackages                             grafite/builder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. grafite/builder

Abandoned → [https://github.com/grafiteinc/scaffold](/?search=https%3A%2F%2Fgithub.com%2Fgrafiteinc%2Fscaffold)ArchivedLibrary[Mail &amp; Notifications](/categories/mail)

grafite/builder
===============

Prepare your Laravel apps incredibly fast, with various commands, services, facades and boilerplates.

v2.5.1(7y ago)98221.4k↓100%109[4 issues](https://github.com/GrafiteInc/Builder/issues)[4 PRs](https://github.com/GrafiteInc/Builder/pulls)MITPHPPHP &gt;=7.1.3

Since Jan 15Pushed 6y ago56 watchersCompare

[ Source](https://github.com/GrafiteInc/Builder)[ Packagist](https://packagist.org/packages/grafite/builder)[ RSS](/packages/grafite-builder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (108)Used By (0)

Grafite Builder
===============

[](#grafite-builder)

> 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.

**Builder** - A handful of tools for Rapid Laravel Development

[![Build Status](https://camo.githubusercontent.com/b0d6f75fe83a190ed33111332d56475025896f5694c3b13cacb0c852f321477f/68747470733a2f2f7472617669732d63692e6f72672f47726166697465496e632f4275696c6465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/GrafiteInc/Builder)[![Packagist](https://camo.githubusercontent.com/bf3b1f6c9cc4cd2e0fd39c1145ccce9bde3a9c95d1f706cd775c7cdd9d506e08/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f677261666974652f6275696c6465722e737667)](https://packagist.org/packages/grafite/builder)[![license](https://camo.githubusercontent.com/850eae1099d2b05f53383473d7cd51f9bc1ab09b7d0d9e5122f1dd930efdcc6d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6173686170652f6170697374617475732e737667)](https://packagist.org/packages/grafite/builder)

This 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.

##### Author(s):

[](#authors)

- [Matt Lantz](https://github.com/mlantz) ([@mattylantz](http://twitter.com/mattylantz), mattlantz at gmail dot com)

General Requirements
--------------------

[](#general-requirements)

1. PHP 7.1.3+
2. OpenSSL

Compatibility and Support
-------------------------

[](#compatibility-and-support)

Laravel VersionPackage TagSupported5.7.x2.5.xno5.6.x2.4.xno5.5.x2.3.xno5.4.x2.2.xno5.3.x2.0.x - 2.1.xno5.1.x - 5.2.x1.9.xnoInstallation
------------

[](#installation)

Start a new Laravel project:

```
laravel new {project_name}

```

or

```
composer create-project laravel/laravel {project_name}

```

Then run the following to add the Grafite Builder

```
composer require "grafite/builder"
```

Time to publish those assets! Grafite Builder uses CrudMaker and FormMaker which have publishable assets.

```
php artisan vendor:publish
```

or

```
php artisan vendor:publish --provider="Yab\CrudMaker\CrudMakerProvider"
php artisan vendor:publish --provider="Yab\FormMaker\FormMakerProvider"
```

You now have Grafite Builder installed. Try out the *Starter Kit*.

### Application Starter Kit

[](#application-starter-kit)

!!! warning "Make sure you followed the getting started instructions!"

Grafite 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:

```
php artisan grafite:starter

```

!!! tip "BUT, before we do that lets get a few things set up."

In order to make use of the starter kit you will need to modify some files. Check out the modifications below:

Add the following to your `app/Http/Kernel.php` in the `$routeMiddleware` array.

```
'admin' => \App\Http\Middleware\Admin::class,
'permissions' => \App\Http\Middleware\Permissions::class,
'roles' => \App\Http\Middleware\Roles::class,
'active' => \App\Http\Middleware\Active::class,
```

If you don't want to worry about email activation then remove this from the route's middleware array:

```
'active'
```

Update the `App\User::class` in: 'config/auth.php' and 'database/factories/UserFactory.php' to this:

```
App\Models\User::class
```

Add the following to 'app/Providers/AuthServiceProvider.php' in the boot method

```
Gate::define('admin', function ($user) {
    return ($user->roles->first()->name === 'admin');
});

Gate::define('team-member', function ($user, $team) {
    return ($user->teams->find($team->id));
});
```

Add the following to 'app/Providers/EventServiceProvider.php' in the $listen property

```
'App\Events\UserRegisteredEmail' => [
    'App\Listeners\UserRegisteredEmailListener',
],
```

You will want to create an sqlite memory test database in the `config/database.php`

```
'testing' => [
    'driver'   => 'sqlite',
    'database' => ':memory:',
    'prefix'   => '',
],
```

Add the following line to the 'phpunit.xml' file

```

```

### Regarding Email Activation

[](#regarding-email-activation)

The Starter kit has an email activation component added to the app to ensure your users have validated their email address. You can disable it by removing the `active` middleware from the `web` routes. You will also have to disable the Notification but it won't cause any problems if you remove the email activation.

### For Laravel 5.2 and later

[](#for-laravel-52-and-later)

You will also need to set the location of the email for password reminders. (config/auth.php - at the bottom)

```
'passwords' => [
    'users' => [
        'provider' => 'users',
        'email' => 'emails.password',
        'table' => 'password_resets',
        'expire' => 60,
    ],
],
```

#### Things to note

[](#things-to-note)

You may try and start quickly by testing the registration but please make sure your app's email is configured or it will throw an exception. You can do this in the `.env` file easily by setting it to 'log' temporarily

```
MAIL_DRIVER=log
```

#### Last Steps

[](#last-steps)

Once you've added in all these parts you will want to run the starter command!

```
php artisan grafite:starter
```

Then you'll have to refresh the list of all classes that need to be included in the project.

```
composer dump-autoload
```

Then 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.

```
php artisan migrate --seed
```

Once 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.

### What Starter Publishes

[](#what-starter-publishes)

#### Controllers

[](#controllers)

Grafite 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.

- app/Http/Controllers/
    - Admin/
        - DashboardController.php
        - UserController.php
        - RoleController.php
    - Auth/
        - ActivateController.php
        - ForgotPasswordController.php
        - LoginController.php
        - RegisterController.php
        - ResetPasswordController.php
    - User/
        - PasswordController.php
        - SettingsController.php
    - PagesController.php
    - TeamController.php

#### Middleware

[](#middleware)

Grafite Builder overwrites the default middleware due to changes in the redirects. It also provides the `Admin` middleware for route level protection relative to roles.

- app/Http/Middleware/
    - Active.php
    - Admin.php
    - Permissions.php
    - RedirectIfAuthenticated.php
    - Roles.php

#### Requests

[](#requests)

There 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.)

- app/Http/Requests/
    - PasswordUpdateRequest.php
    - RoleCreateRequest.php
    - TeamCreateRequest.php
    - TeamUpdateRequest.php
    - UserInviteRequest.php
    - UserUpdateRequest.php

#### Routes

[](#routes)

Given that there are numerous routes added to handle teams, profiles, password etc all routes are overwritten with the starter kit.

- routes/web.php

#### Config

[](#config)

The permissions config file is published, this is a way for you to set access levels and types of permissions `Roles` can have

- config/permissions.php

#### Events

[](#events)

The events for various actions.

- app/Events/
    - UserRegisteredEmail.php

#### Listeners

[](#listeners)

The event listeners for various actions.

- app/Listeners/
    - UserRegisteredEmailListener.php

#### Models

[](#models)

Models 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.

- app/Models/
    - UserMeta.php
    - User.php
    - Team.php
    - Role.php

#### Notifications

[](#notifications)

These 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.

- app/Notficiations/
    - ActivateUserEmail.php
    - NewAccountEmail.php
    - ResetPasswordEmail.php

#### Services

[](#services)

Service 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.

- app/Services/
    - Traits/
        - HasRoles.php
        - HasTeams.php
    - ActivateService.php
    - RoleService.php
    - TeamService.php
    - UserService.php

#### Database

[](#database)

Please ensure that all migrations and seeds are run post installation. These seeds set the default roles available in your application.

- database/factories/
    - RoleFactory.php
    - TeamFactory.php
    - UserFactory.php
    - UserMetaFactory.php
- database/migrations/
    - 2015\_11\_30\_191713\_create\_user\_meta\_table.php
    - 2015\_11\_30\_215038\_create\_roles\_table.php
    - 2015\_11\_30\_215040\_create\_role\_user\_table.php
    - 2015\_12\_04\_155900\_create\_teams\_table.php
    - 2015\_12\_04\_155900\_create\_teams\_users\_table.php
- database/seeds/
    - DatabaseSeeder.php
    - RolesTableSeeder.php
    - UserTableSeeder.php

#### Views

[](#views)

The 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.

- resources/views/
    - admin/
        - roles/
            - edit.blade.php
            - index.blade.php
            - invite.blade.php
        - users/
            - edit.blade.php
            - index.blade.php
            - invite.blade.php
        - dashboard.blade.php
    - auth/
        - activate/
            - email.blade.php
            - token.blade.php
        - passwords/
            - email.blade.php
            - reset.blade.php
        - login.blade.php
        - register.blade.php
    - errors/
        - 401.blade.php
        - 404.blade.php
        - 503.blade.php
    - partials/
        - errors.blade.php
        - message.blade.php
        - status.blade.php
    - team/
        - create.blade.php
        - edit.blade.php
        - index.blade.php
        - show.blade.php
    - user/
        - meta.blade.php
        - password.blade.php
        - settings.blade.php
    - dashboard.blade.php

#### Tests

[](#tests)

Grafite 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.

- tests/
    - Feature/
        - TeamIntegrationTest.php
    - Unit/
        - UserServiceTest.php
        - TeamServiceTest.php
        - RoleServiceTest.php

After Setup
-----------

[](#after-setup)

### Dashboard access

[](#dashboard-access)

The application dashboard is found by browsing to the /dashboard endpoint. The default admin user login credentials are:

- email:
- password: admin

### User

[](#user)

The 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:

- Meta: hasOne
- Roles: belongsToMany
- Team: belongsToMany

It also provides the following methods:

```
meta() // The relationship method
roles() // The relationship method
hasRole(role_name) // checks if user has role
teams() // The relationship method
isTeamMember(team_id) // checks if user is member
isTeamAdmin(team_id) // checks if user is admin level member

```

### Middleware

[](#middleware-1)

#### Admin

[](#admin)

The Admin middleware acts as a tool for setting admin level permissions on the routes or controller level.

```
['middleware' => 'admin']

```

This 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.

#### Active

[](#active)

The Active middleware acts checks if the account as been activated by accessing the activate url with the emailed token.

```
['middleware' => 'active']

```

This 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.

#### Roles

[](#roles)

The Roles middleware allows you to set custom roles for your routes.

```
['middleware' => 'roles:admin|member']

```

#### Permissions

[](#permissions)

The Permissions middleware allows you to set custom permissions (a subset of roles) for your routes

```
['middleware' => 'permissions:admin|somethingDescriptive']

```

You can set permissions in the `config/permissions.php`

### Bootstrap UI

[](#bootstrap-ui)

!!! Tip "Bootstrap Version 4"

If 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!

```
php artisan grafite:bootstrap

```

!!! Tip "This will also ensure that your webpack file is prepared to run"

#### What Boostrap Publishes

[](#what-boostrap-publishes)

The command will overwrite any existing files with the bootstrap version of them:

- resources/views/
    - user/
        - meta.blade.php
        - password.blade.php
        - settings.blade.php
    - admin/
        - users/
            - edit.blade.php
            - index.blade.php
            - invite.blade.php
    - auth/
        - login.blade.php
        - password.blade.php
        - register.blade.php
        - reset.blade.php
    - dashboard/
        - main.blade.php
        - panel.blade.php
    - emails/
        - new-user.blade.php
        - password.blade.php
    - errors/
        - 404.blade.php
        - 503.blade.php
    - partials/
        - errors.blade.php
        - message.blade.php
    - team/
        - create.blade.php
        - edit.blade.php
        - index.blade.php
        - show.blade.php

### Application Activities

[](#application-activities)

Sometimes 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.

#### Setup

[](#setup)

```
php artisan grafite:activity
```

Add to your `config/app.php` the following:

```
App\Providers\ActivityServiceProvider::class,
```

##### Facades

[](#facades)

Provides the following tool for in app features:

```
Activity::log($description);
Activity::getByUser($userId);
```

##### Helper

[](#helper)

```
activity($description) // will log the activity
```

### Application Features

[](#application-features)

Sometimes 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 take 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.

#### Setup

[](#setup-1)

```
php artisan grafite:features
```

You may want to add this line to your navigation:

```
 Features
```

Add to your `config/app.php` the following:

```
App\Providers\FeatureServiceProvider::class,
```

Add this to the `app/Providers/RouteServiceProvider.php` in the `mapWebRoutes(Router $router)` function:

```
require base_path('routes/features.php');
```

##### Facades

[](#facades-1)

Provides the following tool for in app features:

```
Features::isActive($key);
```

##### Blade

[](#blade)

```
@feature($key)
// code goes here
@endfeature
```

##### Helper

[](#helper-1)

```
feature($key) // will return true|false
```

##### What Features Publishes:

[](#what-features-publishes)

The command will overwrite any existing files with the features version of them:

- app/Facades/Features.php
- app/Http/Controllers/Admin/FeatureController.php
- app/Http/Requests/FeatureCreateRequest.php
- app/Http/Requests/FeatureUpdateRequest.php
- app/Models/Feature.php
- app/Providers/FeatureServiceProvider.php
- app/Services/FeatureService.php
- database/migrations/2016\_04\_14\_210036\_create\_features\_table.php
- resources/views/admin/features/create.blade.php
- resources/views/admin/features/edit.blade.php
- resources/views/admin/features/index.blade.php
- routes/features.php
- tests/Feature/FeatureIntegrationTest.php
- tests/Unit/FeatureServiceTest.php

### Application Logs

[](#application-logs)

The 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.

#### Setup

[](#setup-2)

```
php artisan grafite:logs
```

You may want to add this line to your navigation:

```
 Logs
```

Add this to the `app/Providers/RouteServiceProvider.php` in the `mapWebRoutes(Router $router)` function:

```
require base_path('routes/logs.php');
```

### Application Notifications

[](#application-notifications)

Grafite 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.

##### Setup

[](#setup-3)

```
php artisan grafite:notifications
```

You may want to add this line to your navigation:

```
 Notifications
 Notifications
```

Add this to the `app/Providers/RouteServiceProvider.php` in the `mapWebRoutes(Router $router)` function:

```
require base_path('routes/notification.php');
```

##### Facades

[](#facades-2)

Provides the following tool for in app notifications:

```
Notifications::notify($userId, $flag, $title, $details);
```

Flags can be any bootstrap alert: default, info, success, warning, danger

##### What Notifications Publishes:

[](#what-notifications-publishes)

The command will overwrite any existing files with the notification version of them:

- app/Facades/Notifications.php
- app/Http/Controllers/Admin/NotificationController.php
- app/Http/Controllers/User/NotificationController.php
- app/Http/Requests/NotificationRequest.php
- app/Models/Notification.php
- app/Services/NotificationService.php
- database/migrations/2016\_04\_14\_180036\_create\_notifications\_table.php
- resources/views/admin/notifications/create.blade.php
- resources/views/admin/notifications/edit.blade.php
- resources/views/admin/notifications/index.blade.php
- resources/views/notifications/index.blade.php
- resources/views/notifications/show.blade.php
- routes/notification.php
- tests/NotificationIntegrationTest.php
- tests/NotificationServiceTest.php

### Forge Integration

[](#forge-integration)

The 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 you can simply log into your own application and in the admin panel adjust the scheduler, or workers on your server configuration.

##### Requires

[](#requires)

```
composer require themsaid/forge-sdk
```

##### Setup

[](#setup-4)

```
php artisan grafite:forge
```

You may want to add this line to your navigation:

```
 Forge Settings
 Forge Calendar
 Forge Workers
```

Add this to the `app/Providers/RouteServiceProvider.php` in the `mapWebRoutes(Router $router)` function:

You will see a line like: `->group(base_path('routes/web.php'));`

You need to change it to resemble this:

```
->group(function () {
    require base_path('routes/web.php');
    require base_path('routes/forge.php');
}
```

Add these to the .env:

```
FORGE_TOKEN=
FORGE_SERVER_ID=
FORGE_SITE_ID=
```

### Application API

[](#application-api)

If you feel like opting in for the Laracogs starter kit. You can also easily build in an API layer. Running the `grafite:api` 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 `--api` option.

##### Requires

[](#requires-1)

```
composer require tymon/jwt-auth
```

##### Setup

[](#setup-5)

```
php artisan grafite:api

```

Essentially you want to do all the basic setup for JWT such as everything in here: Then follow the directions regarding installation on:

Add this to the `app/Providers/RouteServiceProvider.php` file in the `mapWebRoutes(Router $router)` function:

```
require base_path('routes/api.php');
```

Add to the app/Http/Kernal.php under routeMiddleware:

```
'jwt.auth' => \Tymon\JWTAuth\Middleware\GetUserFromToken::class,
'jwt.refresh' => \Tymon\JWTAuth\Middleware\RefreshToken::class,
```

Add to except attribute the app/Http/Middleware/VerifyCsrfToken.php (You also have to do this for CRUDs you add):

```
'api/v1/login',
'api/v1/user/profile',
```

If you use Apache add this to the .htaccess file:

```
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
```

Also update your jwt config file and set the user to:

```
\App\Models\User::class
```

##### What API publishes

[](#what-api-publishes)

The command will overwrite any existing files with the api version of them:

- app/Http/Controllers/Api/AuthController.php
- app/Http/Controllers/Api/UserController.php
- routes/api.php

### Application Queue

[](#application-queue)

Horizon 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. If 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 addition to your app.

##### Setup

[](#setup-6)

```
php artisan grafite:queue
```

Add this to the `app/Providers/RouteServiceProvider.php` in the `mapWebRoutes(Router $router)` function:

```
require base_path('routes/queue.php');
```

You may want to add this line to your navigation:

```
 Queue
```

### Social Media Logins

[](#social-media-logins)

If 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.

##### Requires

[](#requires-2)

```
composer require laravel/socialite
```

##### Setup

[](#setup-7)

```
php artisan grafite:socialite

```

The next step is to prepare your app with socialite:

Add this to your app config under providers:

```
Laravel\Socialite\SocialiteServiceProvider::class
```

Add this to your app config under aliases:

```
'Socialite' => Laravel\Socialite\Facades\Socialite::class,
```

Add `require base_path('routes/socialite.php');` to the `app/Providers/RouteServiceProvider.php` in the `mapWebRoutes(Router $router)` function:

```
Route::middleware('web')
    ->namespace($this->namespace)
    ->group(function () {
        require base_path('routes/socialite.php');
        require base_path('routes/web.php');
    });
```

Finally set the access details in the services config:

```
'github' => [
    'client_id' => 'id code',
    'client_secret' => 'secret code',
    'redirect' => 'http://your-domain/auth/github/callback',
    'scopes' => ['user:email'],
],
```

##### What Socialite publishes

[](#what-socialite-publishes)

The command will overwrite any existing files with the socialite version of them:

- app/Http/Controllers/Auth/SocialiteAuthController.php
- routes/socialite.php

### Application Billing

[](#application-billing)

If 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!

##### Requires

[](#requires-3)

```
composer require laravel/cashier
```

##### Setup

[](#setup-8)

```
php artisan grafite:billing

```

You have to modify the `app/Providers/RouteServiceProvider.php` in the `mapWebRoutes(Router $router)` function:

You will see a line like: `->group(base_path('routes/web.php'));`

You need to change it to resemble this:

```
->group(function () {
    require base_path('routes/web.php');
    require base_path('routes/billing.php');
}
```

Add these to the .env:

```
SUBSCRIPTION=app_basic
STRIPE_SECRET=secret-key
STRIPE_PUBLIC=public-key
```

Add this to the app/Providers/AuthServiceProvider.php:

```
Gate::define('access-billing', function ($user) {
    return ($user->meta->subscribed('main') && is_null($user->meta->subscription('main')->endDate));
});
```

And for the `config/services.php` you will want yours to resemble:

```
'stripe' => [
    'model'  => App\Models\UserMeta::class,
    'key'    => env('STRIPE_PUBLIC'),
    'secret' => env('STRIPE_SECRET'),
],
```

Finally run migrate to add the subscriptions and bind them to the user meta:

```
php artisan migrate
```

You will also want to update your webpack mix file to resemble (webpack.mix.js):

```
.js([
    'resources/assets/js/app.js',
    'resources/assets/js/card.js',
    'resources/assets/js/subscription.js'
], 'public/js');
```

##### After Setup

[](#after-setup-1)

You may want to add this line to your navigation:

```
 Billing
```

##### Notes

[](#notes)

You may want to switch the line in the view vendor.receipt to:

```
To: {{ $user->user()->email }}
```

We do this because rather than bind the billing to the User, we bound it to the UserMeta.

##### What Billing Publishes

[](#what-billing-publishes)

The command will overwrite any existing files with the billing version of them:

- app/Http/Controllers/User/BillingController.php
- app/Models/UserMeta.php
- config/invoice.php
- config/plans.php
- database/migrations/2016\_02\_26\_000647\_create\_subscriptions\_table.php
- database/migrations/2016\_02\_26\_000658\_add\_billings\_to\_user\_meta.php
- resources/assets/js/card.js
- resources/assets/js/subscription.js
- resources/views/billing/card-form.blade.php
- resources/views/billing/change-card.blade.php
- resources/views/billing/details.blade.php
- resources/views/billing/invoices.blade.php
- resources/views/billing/coupons.blade.php
- resources/views/billing/subscribe.blade.php
- resources/views/billing/tabs.blade.php
- routes/billing.php

##### Accounts

[](#accounts)

The 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.

These 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.

##### Config

[](#config-1)

This is the basic config for `config/plans.php`. This is for a single plan, either be subscribed or not.

!!! tip "Remember you need to have corresponding plans on Stripe ex. app\_basic by default"

```
'subscription' => env('SUBSCRIPTION'),
'subscription_name' => 'main',
'plans' => [
    'app_basic' => [
        'access' => [
            'some name'
        ],
        'limits' => [
            'Model\Namespace' => 5,
            'pivot_table' => 1
        ],
        'credits' => [
            'column' => 'credits_spent',
            'limit' => 10
        ],
        'custom' => [
            'anything' => 'anything'
        ],
    ],
]

```

##### Multiple Plans

[](#multiple-plans)

In 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:

1. Line 45 of the `BillingController.php` change `config('plans.subscription')` to: `$payload['plan']`
2. Add `name`, and `stripe_id` to the config

```
'subscription_name' => 'main',
'plans' => [
    'basic' => [
        'name' => 'Basic Subscription',
        'stripe_id' => 'basic_subscription',
        'access' => [
            'some name'
        ],
        'limits' => [
            'Model\Namespace' => 5,
            'pivot_table' => 1
        ],
        'credits' => [
            'column' => 'credits_spent',
            'limit' => 10
        ],
        'custom' => [
            'anything' => 'anything'
        ],
    ],
]

```

3. Then add the following code in `resources/views/billing/subscribe.blade.php` above the card form include:

```

    Plan

        @foreach (config('plans.plans') as $plan)
            {{ $plan['name'] }}
        @endforeach

```

!!! 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()->user()->meta->subscription(config('plans.subscription_name'))->swap($request->plan)`"

##### Service Methods

[](#service-methods)

\#### currentBillingCycle() By 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.
\#### canAccess($area) Returns a boolean if the user can enter
\#### cannotAccess($area) Returns a boolean if the user cannot enter
\#### getClause($key) Returns the specified clause of the plans
\#### getLimit($model) Returns the specified limit of a model or pivot table
\#### withinLimit($model, $key = 'user\_id', $value = {user's id}) Confirms that the specified model only has the specified amount collected by the $key and $value. \* If you add the `currentBillingCycle()` before this then it would add the further restrictions.
\#### creditsUsed($model, $key = 'user\_id', $value = {user's id}) Reports back the specified amount collected by the $key and $value. \* If you add the `currentBillingCycle()` before this then it would add the further restrictions.
\#### creditsAvailable($model) Returns the number of credits remaining based on the config and the previous method. \* If you add the `currentBillingCycle()` before this then it would add the further restrictions.
\#### clause($key, $method, $model = null) Performs 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 License
-------

[](#license)

Grafite Builder is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

### Bug Reporting and Feature Requests

[](#bug-reporting-and-feature-requests)

Please add as many details as possible regarding submission of issues and feature requests

### Disclaimer

[](#disclaimer)

THE 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.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community33

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 87.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Recently: every ~43 days

Total

106

Last Release

2802d ago

Major Versions

v1.9.37 → v2.0.02016-08-24

v1.9.38 → v2.0.12016-08-28

PHP version history (4 changes)v1.0.0PHP &gt;=5.5.9

v2.0.1PHP &gt;=5.6.4

v2.3.0PHP &gt;=7.0

v2.4.0PHP &gt;=7.1.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/81d026d950739c978b844ac79e6b454e7fedc95ceffdcc4da09893c2497c7255?d=identicon)[mlantz](/maintainers/mlantz)

---

Top Contributors

[![mlantz](https://avatars.githubusercontent.com/u/1065551?v=4)](https://github.com/mlantz "mlantz (562 commits)")[![casperboone](https://avatars.githubusercontent.com/u/15815208?v=4)](https://github.com/casperboone "casperboone (18 commits)")[![thinkstylestudio](https://avatars.githubusercontent.com/u/322368?v=4)](https://github.com/thinkstylestudio "thinkstylestudio (14 commits)")[![jayjfletcher](https://avatars.githubusercontent.com/u/5743488?v=4)](https://github.com/jayjfletcher "jayjfletcher (5 commits)")[![amranidev](https://avatars.githubusercontent.com/u/12874619?v=4)](https://github.com/amranidev "amranidev (5 commits)")[![bretto36](https://avatars.githubusercontent.com/u/6217994?v=4)](https://github.com/bretto36 "bretto36 (4 commits)")[![tmaly1980](https://avatars.githubusercontent.com/u/7697371?v=4)](https://github.com/tmaly1980 "tmaly1980 (4 commits)")[![vool](https://avatars.githubusercontent.com/u/441840?v=4)](https://github.com/vool "vool (4 commits)")[![fabulous-php](https://avatars.githubusercontent.com/u/1531941?v=4)](https://github.com/fabulous-php "fabulous-php (3 commits)")[![absalomedia](https://avatars.githubusercontent.com/u/3776787?v=4)](https://github.com/absalomedia "absalomedia (2 commits)")[![emamalias](https://avatars.githubusercontent.com/u/13638285?v=4)](https://github.com/emamalias "emamalias (2 commits)")[![jagroop](https://avatars.githubusercontent.com/u/12444128?v=4)](https://github.com/jagroop "jagroop (2 commits)")[![morrismukiri](https://avatars.githubusercontent.com/u/804653?v=4)](https://github.com/morrismukiri "morrismukiri (2 commits)")[![raphaelbadia](https://avatars.githubusercontent.com/u/1901628?v=4)](https://github.com/raphaelbadia "raphaelbadia (2 commits)")[![codydh](https://avatars.githubusercontent.com/u/11252?v=4)](https://github.com/codydh "codydh (1 commits)")[![joxper](https://avatars.githubusercontent.com/u/7101877?v=4)](https://github.com/joxper "joxper (1 commits)")[![CaddyDz](https://avatars.githubusercontent.com/u/13698160?v=4)](https://github.com/CaddyDz "CaddyDz (1 commits)")[![amirulahmad](https://avatars.githubusercontent.com/u/78335?v=4)](https://github.com/amirulahmad "amirulahmad (1 commits)")[![Yo1L](https://avatars.githubusercontent.com/u/15970286?v=4)](https://github.com/Yo1L "Yo1L (1 commits)")[![sooonmitch](https://avatars.githubusercontent.com/u/8207726?v=4)](https://github.com/sooonmitch "sooonmitch (1 commits)")

---

Tags

apibillingcrudfeature-flagslaravelnotificationssocialitestarterkit

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/grafite-builder/health.svg)

```
[![Health](https://phpackages.com/badges/grafite-builder/health.svg)](https://phpackages.com/packages/grafite-builder)
```

###  Alternatives

[mckenziearts/laravel-notify

Flexible flash notifications for Laravel

1.7k1.1M5](/packages/mckenziearts-laravel-notify)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[laravel-notification-channels/apn

Apple APN Push Notification Channel

2021.9M4](/packages/laravel-notification-channels-apn)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1603.0M7](/packages/laravel-notification-channels-microsoft-teams)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[illuminate/mail

The Illuminate Mail package.

5910.1M390](/packages/illuminate-mail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
