2017 © Pedro Peláez
 

library productivity

Productivity - A productivity API by Artisan Pixelworks

image

oburatongoi/productivity

Productivity - A productivity API by Artisan Pixelworks

  • Friday, June 15, 2018
  • by oburatongoi
  • Repository
  • 1 Watchers
  • 1 Stars
  • 314 Installations
  • Vue
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 100 Versions
  • 2 % Grown

The README.md

Productivity

Installation

Compatible with Laravel 5. To install, run:, (*1)

$ composer install oburatongoi/productivity., (*2)

Next, add the service provider to the provider array in the app/config.app file:, (*3)

Oburatongoi\Productivity\Providers\ProductivityServiceProvider::class,, (*4)

In your .env file, add the following variables:, (*5)

SESSION_DOMAIN=.your-domain.com Note the '.' before the domain name., (*6)

PRODUCTIVITY_LOGO=logo-text defaults to 'Productivity', (*7)

PRODUCTIVITY_DOMAIN=your-domain.com, (*8)

PRODUCTIVITY_SUBDOMAIN=productivity, (*9)

If using Scout with Algolia, set the following environment variables, (*10)

FOLDER_INDEX_NAME=the-name-of-your-folder-index defaults to prod_FOLDERS, (*11)

CHECKLIST_INDEX_NAME=the-name-of-your-folder-index defaults to prod_CHECKLISTS, (*12)

Be sure to update your DNS 'A' or 'CNAME' settings to include the new name and add SSL encryption for your desired subdomain if you do not have wildcard subdomain encryption., (*13)

Next, publish the package's views, migrations and routes:, (*14)

$ php artisan vendor:publish, (*15)

You will need to force publish the productivity config. Note that this will add or overwrite the following files in the config folder: productivity.php, fakeid.php and javascript.php:, (*16)

php artisan vendor:publish --tag=productivity --force, (*17)

Next, add the Productive trait to your app's User model:, (*18)

use Oburatongoi\Productivity\Traits\Productive;


class User extends Authenticatable
{
    use Notifiable, Productive;

    // ... User class methods
}

To properly address certain exceptions, add the following to your app\Exceptions\Handler.php file:, (*19)

use Illuminate\Session\TokenMismatchException as TokenMismatchException;
use AlgoliaSearch\AlgoliaException as AlgoliaException;

use Bugsnag;

class Handler extends ExceptionHandler
{
    /**
     * A list of the exception types that should not be reported.
     *
     * @var array
     */
    protected $dontReport = [
        \Illuminate\Session\TokenMismatchException::class,
        \AlgoliaSearch\AlgoliaException::class,
    ];

    /**
     * Report or log an exception.
     *
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
     *
     * @param  \Exception  $exception
     * @return void
     */
    public function report(Exception $exception)
    {
        Bugsnag::notifyException($exception);
        parent::report($exception);
    }

    /**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Exception  $exception
     * @return \Illuminate\Http\Response
     */
    public function render($request, Exception $exception)
    {

        if ($exception instanceof TokenMismatchException) {
            Bugsnag::notifyException($exception);

            if ($request->expectsJson()) return response()->json([
                'tokenMismatch' => true,
                'input' => $request->except(['password']),
                'url' => $request->fullUrl(),
                'method' => $request->method(),
                'token' => csrf_token()
            ]);
        }

        if ($exception instanceof AlgoliaException) {
            Bugsnag::notifyException($exception);

            if ($request->expectsJson()) return response()->json([
                'algoliaException' => true,
                'input' => $request->except(['password'])
            ]);
        }

        return parent::render($request, $exception);
    }

Finally, run the migration to add productivity's folders to the database. Note that productivity's tables all have the productivity_ prefix, so make sure you don't have any naming conflicts in your database:, (*20)

$ php artisan migrate, (*21)

Getting Started

When adding Productivity to a fresh Laravel installation, consider doing the following: * Change app name in config/app * Install Bugsnag * Install and Configure Algolia * Install and Configure Redis * Install and Configure JosephSilber/bouncer package, (*22)

The Versions