PHP code example of oburatongoi / productivity

1. Go to this page and download the library: Download oburatongoi/productivity library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oburatongoi / productivity example snippets


use Oburatongoi\Productivity\Traits\Productive;


class User extends Authenticatable
{
    use Notifiable, Productive;

    // ... User class methods
}

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);
    }