Coder Social home page Coder Social logo

grafiteinc / builder Goto Github PK

View Code? Open in Web Editor NEW
990.0 58.0 113.0 1.13 MB

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

Home Page: https://builder.grafite.ca

License: MIT License

PHP 65.56% CSS 0.97% JavaScript 0.32% HTML 32.98% Vue 0.17%
starterkit laravel billing notifications api crud socialite feature-flags

builder's Introduction

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 Packagist license

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

General Requirements

  1. PHP 7.1.3+
  2. OpenSSL

Compatibility and Support

Laravel Version Package Tag Supported
5.7.x 2.5.x no
5.6.x 2.4.x no
5.5.x 2.3.x no
5.4.x 2.2.x no
5.3.x 2.0.x - 2.1.x no
5.1.x - 5.2.x 1.9.x no

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

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

<env name="DB_CONNECTION" value="testing"/>
<env name="MAIL_DRIVER" value="log"/>

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

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

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

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

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

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

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

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

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

The events for various actions.

  • app/Events/
    • UserRegisteredEmail.php

Listeners

The event listeners for various actions.

  • app/Listeners/
    • UserRegisteredEmailListener.php

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

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

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

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

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

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

Dashboard access

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

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

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

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

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

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

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

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

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

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

php artisan grafite:activity

Add to your config/app.php the following:

App\Providers\ActivityServiceProvider::class,
Facades

Provides the following tool for in app features:

Activity::log($description);
Activity::getByUser($userId);
Helper
activity($description) // will log the activity

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

php artisan grafite:features

You may want to add this line to your navigation:

<li class="nav-item"><a class="nav-link" href="{!! url('admin/features') !!}"><span class="fa fa-cog"></span> Features</a></li>

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

Provides the following tool for in app features:

Features::isActive($key);
Blade
@feature($key)
// code goes here
@endfeature
Helper
feature($key) // will return true|false
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

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

php artisan grafite:logs

You may want to add this line to your navigation:

<li class="nav-item"><a href="{!! url('admin/logs') !!}"><span class="fa fa-line-chart"></span> Logs</a></li>

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

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

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
php artisan grafite:notifications

You may want to add this line to your navigation:

<li><a href="{!! url('user/notifications') !!}"><span class="fa fa-envelope-o"></span> Notifications</a></li>
<li><a href="{!! url('admin/notifications') !!}"><span class="fa fa-envelope-o"></span> Notifications</a></li>

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

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

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:

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

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
composer require themsaid/forge-sdk
Setup
php artisan grafite:forge

You may want to add this line to your navigation:

<li class="nav-item"><a href="{{ url('admin/forge/settings') }}"><span class="fa fa-fw fa-server"></span> Forge Settings</a></li>
<li class="nav-item"><a href="{{ url('admin/forge/scheduler') }}"><span class="fa fa-fw fa-calendar"></span> Forge Calendar</a></li>
<li class="nav-item"><a href="{{ url('admin/forge/workers') }}"><span class="fa fa-fw fa-cogs"></span> Forge Workers</a></li>

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

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
composer require tymon/jwt-auth
Setup
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: https://github.com/tymondesigns/jwt-auth/wiki/Installation

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

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

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

<li><a href="{!! url('admin/queue') !!}"><span class="fa fa-list"></span> Queue</a></li>

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
composer require laravel/socialite
Setup
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

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

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

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
composer require laravel/cashier
Setup
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

You may want to add this line to your navigation:

<li><a href="{{ url('user/billing/details') }}"><span class="fa fa-dollar"></span> Billing</a></li>
Notes

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

<strong>To:</strong> {{ $user->user()->email }}

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

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

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

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

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'
        ],
    ],
]
  1. Then add the following code in resources/views/billing/subscribe.blade.php above the card form include:
<div class="form-group">
    <label class="form-label" for="plan">Plan</label>
    <select class="form-control" name="plan" id="plan">
        @foreach (config('plans.plans') as $plan)
            <option value="{{ $plan['stripe_id'] }}">{{ $plan['name'] }}</option>
        @endforeach
    </select>
</div>

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

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

Grafite Builder is open-sourced software licensed under the MIT license

Bug Reporting and Feature Requests

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

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.

builder's People

Contributors

absalomedia avatar amirulahmad avatar amranidev avatar ashbeats avatar austinkregel avatar bretto36 avatar caddydz avatar casperboone avatar codydh avatar coolgoose avatar danjfletcher avatar emamalias avatar fabulous-php avatar jagroop avatar jayjfletcher avatar joxper avatar mlantz avatar morrismukiri avatar raphaelbadia avatar sooonmitch avatar tannermccoleman avatar tharun148 avatar thinkstylestudio avatar tmaly1980 avatar vool avatar yo1l avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

builder's Issues

AuthServiceProvider.php - Call to a member function first() on null

Hi,

I have this error when I access after the login to the dashboard.
My database is seeded with all information.
How can I do ?

` public function boot()
{
$this->registerPolicies();

    Gate::define('admin', function ($user) {
        return ($user->roles->first()->name === 'admin'); // this line is the problem
    });

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

P.S : I've done a composer dump-autoload and a composer update.
I'm on the last Laravel 5.3.*

Regards

vendor.receipt

In the docs of the Billing kit it has this line
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.

Where is this view?

CRUD Service update() function seems to be calling Eloquent with the wrong parameters

Hi,

I generated a Laracogs service using the following command:

php artisan crudmaker:new people --api --ui=bootstrap --withFacade --migration --schema="id:increments,user_id:integer|unsigned,title:string|nullable,first_name:string,last_name:string" --relationships="belongsTo|user|user"

This created the update() functions within the controller and service, which look like this:

Controller:

/**
 * Update the people in storage.
 *
 * @param  \Illuminate\Http\PersonRequest  $request
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function update(PersonRequest $request, $id)
{
    $result = $this->service->update($id, $request->except('_token'));

    if ($result) {
        return back()->with('message', 'Successfully updated');
    }

    return back()->with('message', 'Failed to update');
}

Service:

/**
 * Model update.
 *
 * @param  int $id
 * @param  array $input
 * @return bool
 */
public function update($id, $input)
{
    return $this->model->update($id, $input);
}

All good so far... If I do a dd($id, $input) in the service update() function, before calling $this->model->update($id, $input) I can see the correct database ID and input data - all works well so far.

However - when the $this->model->update($id, $input) function is called, it throws the following error from Eloquent:

Type error: Argument 1 passed to Illuminate\Database\Eloquent\Model::update() must be of the type array, string given, called in /home/vagrant/Sites/laravel/app/Services/PersonService.php on line 107

Line 107 is the call to $this->model->update($id, $input).

Eloquent isn't expecting an $id string for a model update call. It's expecting to operate on an already-defined object. I can fix it by rewriting the Service update() function as follows:

public function update($id, $input)
{
    $person = $this->model->find($id);
    return $person->update($input);
}

Am I doing something wrong, or is this a Laracogs bug?

Instructions mismatch

After running php artisan laracogs:starter I get

Update the model in: config/auth.php, database/factory/ModelFactory.php


App\Repositories\User\User::class


Build something worth sharing!

Don't forget to run:
composer dump
Then:
artisan migrate

while the docs say:
Update the App\User::class in: 'config/auth.php' and 'database/factory/ModelFactory.php' to this:

App\Models\User::class

The generator uses the docs style.

[ReflectionException] Class Api\AuthController does not exist

I've done the install twice now just to make sure I didn't miss anything. Fresh version of Laravel, with artisan starter and artisan api run, and all the associated changes and updates made.

I can see the properly namespaced Api\AuthController there, and it's included in the RouteServiceProvider via api-routes.php. Tried composer dump/update etc and still no go.

Tried the biling component and get the same issue.. can't find the Billing Controller.

php artisan route:list fails as well with the error.

Any suggestions?

Example for use {--relationships}?

Where i can find a doc about --relationships command option?
in example with belongsToMany or hasManyThrough, and can i create multiple relationships when i run crudmaker:new?

Validation Errors Display

After defining the rules in the Repository/{Model Name}/{Model Name}.php, the page just seems to refresh and not display the error or session information. The layout is including the /partials/message.blade.php and /partial/error.blade.php

Any ideas?

Crud maker with relationships problem

I have a laravel running the version of it is Laravel Framework version 5.3.6 and I have laracogs at his version 2.1.1.

After running the command:

php artisan crudmaker:new posts --api --ui=bootstrap --migration --schema="id:increments,name:string,body:text,startdate:date,owner_id:integer|unsigned" --relationships="hasOne|\App\Models\User|owner"

I noticed the following:

  1. The relationship was not done on migration, I had to add "owner_id" on schema command and later on modify the migration table to add the relationship.
  2. Form has no relationship, just the id field.

I do not know if this is normal or not, but I suppose that is not, because on the documentation there is the following description:

This will add in the relationships to your models, as well as add the needed name_id field to your tables. Just one more thing you don't have to worry about.

Update User Error

When updated a user (attempting to change role but happens if saving no change) I get an error which is related to the UserRepo - assignRole. It's expecting RoleName not RoleId.

Not sure if it needs to be changed to store the RoleName in the form, or change the code to get the rolename from the roleid.

I will do the necessary code changes, just want to know which one i should do?

Line 105 in UserRepository

The phpdocs are also incorrect (order of parameters)

/**
     * Assign a role
     *
     * @param  int $userId
     * @param  string $roleName
     * @return boolean
     */
    public function assignRole($roleName, $userId)
    {

Semantic UI: semantic.min.css not properly built

I'm following the steps for beginning with Laracogs, I successfully add the starter kit, and then move to add Semantic UI.

I run php artisan laracogs:semantic and am presented with these instructions:

You will need to install semantic-ui:
npm install semantic-ui

When prompted set the directory to:
semantic

Then run:
cd semantic && gulp build

Then run:
cd ../ && gulp

Make sure you set the PagesController@dashboard to use the following view:
'dashboard.main'

Finished setting up semantic-ui in your app

I successfully run npm install semantic-ui.

When running cd semantic && gulp build, I get the following error:

Potentially unhandled rejection [2] TypeError: Cannot call method 'match' of undefined
    at DestroyableTransform.module.exports.settings.plumber.less.errorHandler (/home/cdehaan/prism-laracogs/semantic/tasks/config/tasks.js:96:29)
    at DestroyableTransform.emit (events.js:117:20)
    at afterTransform (/home/cdehaan/prism-laracogs/node_modules/gulp-less/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:74:26)
    at TransformState.afterTransform (/home/cdehaan/prism-laracogs/node_modules/gulp-less/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:58:12)
    at /home/cdehaan/prism-laracogs/node_modules/gulp-less/index.js:58:14
    at tryCatchReject (/home/cdehaan/prism-laracogs/node_modules/gulp-less/node_modules/accord/node_modules/when/lib/makePromise.js:845:30)
    at runContinuation1 (/home/cdehaan/prism-laracogs/node_modules/gulp-less/node_modules/accord/node_modules/when/lib/makePromise.js:804:4)
    at Rejected.when (/home/cdehaan/prism-laracogs/node_modules/gulp-less/node_modules/accord/node_modules/when/lib/makePromise.js:625:4)
    at Pending.run (/home/cdehaan/prism-laracogs/node_modules/gulp-less/node_modules/accord/node_modules/when/lib/makePromise.js:483:13)
    at Scheduler._drain (/home/cdehaan/prism-laracogs/node_modules/gulp-less/node_modules/accord/node_modules/when/lib/Scheduler.js:62:19)

And then when I get to the cd ../ && gulp step, I get the following output:

[cdehaan@localhost prism-laracogs]$ gulp
[12:00:23] Using gulpfile ~/prism-laracogs/gulpfile.js
[12:00:23] Starting 'default'...
[12:00:23] Starting 'copy'...

Fetching Copy Source Files...
   - semantic/dist/semantic.min.css <-- Not Found


Saving To...
   - public/css/semantic.min.css

[12:00:23] Finished 'default' after 41 ms
[12:00:23] Finished 'copy' after 44 ms
[12:00:23] Starting 'sass'...

Fetching Sass Source Files...
   - resources/assets/sass/app.scss


Saving To...
   - public/css/app.css

[12:00:23] gulp-notify: [Laravel Elixir] Sass Compiled!
[12:00:23] Finished 'sass' after 857 ms
[12:00:23] Starting 'copy'...

Fetching Copy Source Files...
   - semantic/dist/semantic.min.js


Saving To...
   - public/js/semantic.min.js

[12:00:23] Finished 'copy' after 15 ms
[12:00:23] Starting 'scripts'...

Fetching Scripts Source Files...
   - resources/assets/js/app.js


Saving To...
   - public/js/all.js

[12:00:24] gulp-notify: [Laravel Elixir] Scripts Merged!
[12:00:24] Finished 'scripts' after 635 ms

So semantic.min.css is not properly built.

Inviting users doesn't assign role correctly.

The generated view for inviting users :

@input_maker_create('roles', ['type' => 'relationship', 'model' => 'App\Repositories\Role\Role', 'label' => 'label'])

Is returning the integer Id of the role dropdown (normal behaviour iirc), which UserService.php

public function create($user, $password, $role = 'member', $sendEmail = true)
    {
        try {
            DB::beginTransaction();
                // create the user meta
                $this->userMetaRepo->findByUserId($user->id);
                // Set the user's role
                $this->userRepo->assignRole($role, $user->id);

is passing to UserRepository.php which is using a method 'findByName' on Repositories\Role.php.

public function assignRole($roleName, $userId)
    {

        $role = Role::findByName($roleName);
        $user = $this->model->find($userId);

        $user->roles()->attach($role);
    }

This causes the user to not be assigned a role.

No repositories included

Hello,

I'm using the sample command to generate CRUD,

php artisan crudmaker:new Book
--migration
--schema="id:increments,title:string,author:string"

However I don't see it generating any repositories files that I read in the docs.

app/Repositories/Book/BookRepository.php
app/Repositories/Book/Book.php

Is there a specific reason for this?

Route [*.delete] does not exist

When using the CRUD builder to create a table/controller/etc, the blade template created by the Bootstrap creator refers to "name.delete" - this then causes an error when displaying all the items, but changing it to "name.destroy" works as expected.

Delete user does not remove their team-user table entries

Using basic Laravel 5.2 with laracogs 1.9.3 and "starter".

Add a new user and invite to one (or more) teams. Then delete the user.
This correctly removes their entry from user, user_meta tables and role_user tables, but does not remove their entries from the team_user table.

All items centered

Semantic ui kit causes all the forms to have their labels centered? Is that intended? Is there any easy way to remove this apart from removing "centered" class from everything

capture

Does Laracogs play well with Laravel 5.3.6?

Having some problems getting the crud to work - the routes are not detected. So before I go down a rabbit hole debugging that, figured I'll check with you first.

What version of laravel has this been tested on? I tried it on 5.3.6.

5.2 & Label Maker

Getting this on a fairly vanilla install of L5.2.29

@input_maker_label('Email') @input_maker_create('email', ['type' => 'string'], $user) @input_maker_label('Name') @input_maker_create('name', ['type' => 'string'], $user) @input_maker_label('Phone') @input_maker_create('meta[phone]', ['type' => 'string'], $user) @input_maker_label('I agree to receive marketing information') @input_maker_create('meta[marketing]', ['type' => 'checkbox'], $user) @input_maker_label('Terms & Conditions') @input_maker_create('meta[terms_and_cond]', ['type' => 'checkbox'], $user)

I've followed the install sequence to the letter. Any reason the Input Maker is broken?

Also getting a similar effect with the CRUD builder & pregenerated form maker:

@form_maker_object($random, FormMaker::getTableColumns('random'))

Typo in Console\Api.php

$ php artisan laracogs:api


  [InvalidArgumentException]
  The "/www/xor/vendor/yab/laracogs/src/Console/../Api" directory does not exist.

changed all occurences of 'Api' in src\Console\Api.php to 'API' fixed it

5.2 php artisan laracogs:starter

so i ran php artisan laracogs:starter and migrated and seeded, then when i want to create a new user, i get this error

Exception in UserService.php line 82:
We were unable to generate your profile, please try again later.

i readed the docs but what im a missing ?

bootstrap columns offset

I'm brand new to laravel and laracogs so I very well may have missed something, but after initiating a brand new laravel project and adding the laracogs starter and bootstrap I have an issue with the layout where the main column is clearing or being pushed under the side column (screenshot attached). Any thoughts?
laracogs-bootstraplayout

meta_blade error

on the following pages:
user/settings
/admin/users/3/edit

ErrorException in InputMaker.php line 199:
Trying to get property of non-object (View: ........./resources/views/user/meta.blade.php) (View: ............../resources/views/user/meta.blade.php)

text is not a valid field for table-crud

$ php artisan laracogs:table-crud customers --bootstrap

** [Exception]
text is not in the array of valid column types: increments, integer, string, datetime, date, float, binary, blob, boolean, datetimetz, time, decimal, bi
gint, smallint, tinyint **

Class `Yab\Laracogs\Encryption\LaracogsEncrypter` not found in `LaravelCrypto.php`

I installed Laracogs starter, bootstrap and notifications, follow the doc in all steps and when i try to add new Notification i get this error:

FatalErrorException in LaravelCrypto.php line 9: 
Class 'Yab\Laracogs\Encryption\LaracogsEncrypter' not found

I checked the package is present and have the right namespace namespace Yab\Laracogs\Encryption; but the file that contain class LaracogsEncrypter is not present anywhere.

What i can do? What hapenned?

i'm on windows 10
php 5.6.12
laravel 5.2.41
laracogs v1.9.37

Default Dashboard View

When using the starter kit, the default dashboard view loads the main layout file and not the 'dashboard.main' blade layout that gets generated.

CRUD builder error with example data (or custom data)

Tried to run:
php artisan crudmaker:new Bike --migration --schema="id:increments,title:string,author:string"

console returns error:
6/7 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░] 85%
[Exception]
Unable to generate your CRUD: Undefined offset: 2

Sysinfo:
Laravel Framework version 5.3.18
laracogs version 2.1
PHP 5.6

Laravel log displays:

[2016-10-14 14:46:29] local.ERROR: exception 'Exception' with message 'Unable to generate your CRUD: Undefined offset: 2' in /Users/michielzoer/Projecten/GIT/moodstudios-app/project/vendor/yab/crudmaker/src/Console/CrudMaker.php:241
Stack trace:
#0 /Users/michielzoer/Projecten/GIT/moodstudios-app/project/vendor/yab/crudmaker/src/Console/CrudMaker.php(197): Yab\CrudMaker\Console\CrudMaker->createCRUD(Array, '', 'Bike', Array)
#1 [internal function]: Yab\CrudMaker\Console\CrudMaker->handle()
#2 /Users/michielzoer/Projecten/GIT/moodstudios-app/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(508): call_user_func_array(Array, Array)
#3 /Users/michielzoer/Projecten/GIT/moodstudios-app/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(169): Illuminate\Container\Container->call(Array)
#4 /Users/michielzoer/Projecten/GIT/moodstudios-app/project/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /Users/michielzoer/Projecten/GIT/moodstudios-app/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /Users/michielzoer/Projecten/GIT/moodstudios-app/project/vendor/symfony/console/Application.php(820): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /Users/michielzoer/Projecten/GIT/moodstudios-app/project/vendor/symfony/console/Application.php(187): Symfony\Component\Console\Application->doRunCommand(Object(Yab\CrudMaker\Console\CrudMaker), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /Users/michielzoer/Projecten/GIT/moodstudios-app/project/vendor/symfony/console/Application.php(118): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /Users/michielzoer/Projecten/GIT/moodstudios-app/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /Users/michielzoer/Projecten/GIT/moodstudios-app/project/artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 {main}  

Installation documentation

Hi Team,

The installiation documentation is broken this step should come before the publish command:
php artisan vendor:publish --provider="Yab\Laracogs\LaracogsProvider"

Class RolesTableSeeder does not exist

Hi,

Following the documentation, when installing on a clean Laravel, I get the following when doing the php artisan migrate --seed:
[ReflectionException]
Class RolesTableSeeder does not exist

Starter Kit / Bootstrap Routing

Just noted on L5.2.29 that the standard Starter Kit / Bootstrap isn't displaying error messages on the login sequence. This issue also affects the GET/POST responses inside the CRUD generator as well.

Steps to replicate (using Debugbar on vanilla L5.2 install to interrogate issue):

  • Install Laracogs
  • Install Starter Kit
  • Install Bootstrap
  • Create a user once migrations are done
  • Try to create another user with same name / email
  • POST response contains errors / Errorbag reponse with HTTP 302 response
  • Page ends up at GET based register page (HTTP 200). No errors are seen as they were part of the 302 response.

running `npm install` after `php artisan laracogs:bootstrap` stuck at `node scripts/install.js`

When I run npm install it stuck at node scripts/install.js. When I re run it I got this:
npm WARN optional Skipping failed optional dependency /chokidar/fsevents: npm WARN notsup Not compatible with your operating system or architecture: [email protected] npm WARN optional Skipping failed optional dependency /gulp-watch/chokidar/fsevents: npm WARN notsup Not compatible with your operating system or architecture: [email protected]

and then run gulp
[10:59:42] Using gulpfile /var/www/html/testlaracog/gulpfile.js [10:59:42] Starting 'default'... [10:59:42] Starting 'sass'... Bus error (core dumped)

Can anyone help?
Thanks

Suggest use FindOrFail(), firstOrFail() on models

For example, I see that in Role.php
public static function findByName($name) { return Role::where('name', $name)->first(); }
Would it be better to use firstOrFail() so that an exception is thrown at this point if the user asks for a non-existent Role name?
Similarly in other methods such as TeamRepository find() method
public function findByName($name) { return $this->model->where('name', $name)->first(); }
Would it be better to use firstOrFail() ?

Just a suggestion, keep up the good work!
thx

Won't install with Laravel 5.3.4

I just created a new laravel project and it's version 5.3.4, trying to install laracogs results in a failure. Here is what happens:

Using version ^2.0 for yab/laracogs
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for yab/laracogs ^2.0 -> satisfiable by yab/laracogs[v2.0.0].
- Conclusion: remove laravel/framework v5.3.4
- Conclusion: don't install laravel/framework v5.3.4
- yab/laracogs v2.0.0 requires illuminate/support 5.3 -> satisfiable by laravel/framework[v5.3.0], illuminate/support[v5.3.0].
- Can only install one of: laravel/framework[v5.3.0, v5.3.4].
- don't install illuminate/support v5.3.0|don't install laravel/framework v5.3.4
- Installation request for laravel/framework (locked at v5.3.4, required as 5.3.*) -> satisfiable by laravel/framework[v5.3.4].

Installation failed, reverting ./composer.json to its original content.

Addition of Max Nesting Solution to Docs:

I faced this issue initially when setting up Laracogs, turned out to be an issue with xdebug.max_nesting_level configuration.

This is solved by adding

ini_set('xdebug.max_nesting_level', 500);

to bootstrap > autoload.php

Is there a way to customize what the crud generator outputs?

I've just started poking around with this project. I was wondering if I use the crud generator to create the views for a table is the any config options to customize what the view will be like?

For example in my case I have boolean values that I would like to be represented by check boxes. So in the form-maker.php config file I changed 'boolean' => 'number', to 'boolean' => 'checkbox', so I was wondering if there was a way to customize the behavior of the crud generator.

Typo in artisan laracogs:starter

Guys, this repo is bananas, great work. One small thing so far, at the end of running laracogs:starter it says:

Don't forget to run:
composer dump
Then:
artisan migration

It should be artisan migrate

Wrong named route, request and redirect('route.name') are generated

after run the comand for generate CRUD:

php artisan crudmaker:new PriceList_Service --api --ui=bootstrap --migration --schema="id:increments,slug:string,name:string,description:text,active:tinyInteger" --withFacade

and acessing the page /pricelist/services/ i have the error:

ErrorException in UrlGenerator.php line 314: Route [pricelist.services.search] not defined. (View: D:\serverpath\dev2016\yabhq-laracogs\www\laracogs\resources\views\pricelist\services\index.blade.php)

and

InvalidArgumentException in UrlGenerator.php line 314: Route [pricelist.services.search] not defined.

In routes.php i have this code:

Route::group(['namespace' => 'PriceList', 'prefix' => 'pricelist', 'middleware' => ['web']], function () { 

/*
|--------------------------------------------------------------------------
| Service Routes
|--------------------------------------------------------------------------
*/

Route::resource('services', 'ServiceController', ['except' => ['show']]);
Route::post('services/search', [
    'as' => 'services.search',
    'uses' => 'ServiceController@search'
]);

});

and if i change the route name services.search in pricelist.services.search it work:

Route::post('services/search', [
    'as' => 'pricelist.services.search',
    'uses' => 'ServiceController@search'
]);

It's a Laravel error or from Laracogs? My solution go well or i need doing something else for get right?

Artisan crud command not working

Attempting to use the crud command:

$ php artisan laracogs:crud news

or

$ php artisan laracogs:crud news --migration

Both return the following:

[ErrorException]
array_merge(): Argument #2 is not an array

typo in API docs

"Add to the app/Http/Kernel.php under routeMiddleware:"

instead of

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

JWT - Class App\Repositories\User\User::class does not exist

Hi,
i've setup Laracogs for my project and i'm already using it.
Now, i would like to create some API (right now, i have used just web routing).

So, i have moved my route in routes/api.php (because is an AJAX call).
When i call this (jquery, with $.ajax POST) i get the error:

Class App\Repositories\User\User::class does not exist

I have follow the guide on how setup Laracogs for API (JWT) and i have also changed the class in 'user' => '\App\Repositories\User\User::class', inside jwt.php

Suggest updating either the UserTableSeeder or Docs

Thanks for such an awesome toolkit!

I'd like to suggest updating the UserTableSeeder file or the Docs to actually add a user with privileges.

I was getting a few errors when I first installed the cogs and was unclear if it was a installation issue, configuration issue or what.

ErrorException in AuthServiceProvider.php line 30:
Trying to get property of non-object
ErrorException in InputMaker.php line 199:
Trying to get property of non-object
ErrorException in InputMaker.php line 199:
Trying to get property of non-object
(View: /home/vagrant/Projects/site/resources/views/user/meta.blade.php)

I figured it out pretty quickly but it would be nice if it were mentioned in the docs. It would have saved me some time double checking everything.

I was thinking something like the below addition.

<?php

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class UserTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $user = App\Repositories\User\User::create(array(
            'name' => 'Admin',
            'email' => '[email protected]',
            'password' => Hash::make('password'),
            'remember_token' => hash_hmac('sha256', str_random(40), env('APP_KEY')),
        ));

        $user->meta()->save(new \App\Repositories\UserMeta\UserMeta(
            [
                'phone' => '415-555-1212',
                'marketing' => 1,
                'terms_and_cond' => 1
            ]
        ));

        $admin_role = \App\Repositories\Role\Role::findByName('Admin');
        $user->roles()->save($admin_role);
    }
}

Better errors when saving with validation fails

When validation rules are specified if an error happens when saving model the error exception shows a general HttpResponseException without any other explanation. Then after deleting some parts of the model showed me the correct error when I commented the Model::$rules

ways to replicate

  1. Specify validation rules in a model,
    2a) put Model Events of a class not found
    OR
    2b) Send a null value to a not null field in database

InputMaker select field

Because Laracogs use as label the array key and as value the array value, you could have some issue when you try to fill the options with a query on a table where there are more labels with the same values.

Eg.
(Id, name)
0, "A"
1, "B"
2, "A"

You will get from a query converted in array the follow result
["B"=>1,"A"=>2]

I think that the values should be unique over the labels.

Notifications Docs need updated.

These docs could use some updating to include the steps that are listed in the console output after running php artisan laracogs:notifications. I don't have the steps on me a the moment because I don't have the project open; if needed I can get it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.