Skip to content

TableInsights is a powerful package designed specifically for back-end developers using the Laravel framework. It allows for easy conversion of database tables into meaningful statistics and insights using just a model.

License

Notifications You must be signed in to change notification settings

ppranav164/TableInsights

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TableInsights

TableInsights is a powerful package designed specifically for back-end developers using the Laravel framework. It allows for easy conversion of database tables into meaningful statistics and insights using just a model.

Getting Started

Prerequisites

  • Laravel Framework

Installation

You can install the package via composer:

composer require ppranav/table-insights

You can load the package's config file by running:

php artisan vendor:publish --tag=tableinsights

The config file allows you to customize the tableinsights's settings.

You can customize the key names of your Tableinsights array and enable or disable individual keys to better suit your needs. To change a key name, enter/replace the desired key name in the right field.

Usage

Extend the class \Ppranav\TableInsights\TableInsights in your own class and implement a models() method in the following code:

/**
 * Add arrays of models
 * @return array<Model, string>
 */
public function models() {
    return [
        Project::class => 'created_at',
        TaskLog::class => 'committed_at'
    ];
}

You may also update models query using the following code:

public function setQuery(Activity $activity)
{
    return $activity->query()->where(‘user_id’, auth()->id());
}

Finally, Your Implementation class should look like this:

class Dashboard extends TableInsights
{

    /**
     * Add arrays of models
     * @return array<Model, string>
     */
    public function models() {
        return [
            Project::class => 'created_at',
            TaskLog::class => 'committed_at'
        ];
    }

    public function setQuery(Activity $activity)
    {
        return $activity->query()->where('created_for_id', auth()->id());
    }
}

Show insights in a controller

 return (new Dashboard())->getInsights();

Screenshots

App Screenshot

License

MIT

About

TableInsights is a powerful package designed specifically for back-end developers using the Laravel framework. It allows for easy conversion of database tables into meaningful statistics and insights using just a model.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages