PHPackages                             kuroragi/general-helper - 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. [Database &amp; ORM](/categories/database)
4. /
5. kuroragi/general-helper

ActiveLibrary[Database &amp; ORM](/categories/database)

kuroragi/general-helper
=======================

General helpers, blameable trait, activity log service, and macros for Laravel ERP applications.

1.2.0(1mo ago)015MITPHPPHP ^8.1

Since Nov 11Pushed 1mo agoCompare

[ Source](https://github.com/kuroragi/general-helper)[ Packagist](https://packagist.org/packages/kuroragi/general-helper)[ Docs](https://github.com/kuroragi/general-helper)[ RSS](/packages/kuroragi-general-helper/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (10)Versions (8)Used By (0)

Kuroragi General Helper
=======================

[](#kuroragi-general-helper)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5c3d33b487cd54a672af8d8d8e0f5bad91d3b8aa6d0e5998d74c835ebfa086ef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b75726f726167692f67656e6572616c2d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kuroragi/general-helper)[![PHP Version Require](https://camo.githubusercontent.com/77363aad10ca8a8a4b34ecf24db4f436f65c62bf0a9fb7bbdc5525c3671d4065/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6b75726f726167692f67656e6572616c2d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kuroragi/general-helper)[![License](https://camo.githubusercontent.com/3a2cb24d494b8818ebb6d47cf192f67ed11f38aab5feb6bf4619465fa07788d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6b75726f726167692f67656e6572616c2d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kuroragi/general-helper)

A Laravel utility package for ERP and general applications provides a **Blameable trait**, **activity logging**, **Blueprint/Eloquent macros**, **authorization exception handling**, and common **helper functions** for Bahasa Indonesia formatting.

Compatible with **Laravel 10, 11, and 12**.

---

Requirements
------------

[](#requirements)

- PHP ^8.1
- Laravel ^10.0 | ^11.0 | ^12.0

### Optional Dependencies

[](#optional-dependencies)

- [`spatie/laravel-permission`](https://github.com/spatie/laravel-permission) for role/permission-based authorization exception handling
- [`barryvdh/laravel-dompdf`](https://github.com/barryvdh/laravel-dompdf) for PDF generation features

---

Installation
------------

[](#installation)

```
composer require kuroragi/general-helper
```

The service provider is auto-discovered via Laravel package auto-discovery.

### Publish Config

[](#publish-config)

```
php artisan vendor:publish --tag=config --provider="Kuroragi\GeneralHelper\Providers\GeneralHelperServiceProvider"
```

---

Configuration
-------------

[](#configuration)

```
// config/kuroragi.php
return [
    'config_version'           => 2,
    'activity_log_path'        => storage_path('logs/activity'),
    'activity_log_file_prefix' => 'activity-',
    'roll_day'                 => 'monday',
    'roll_time'                => '01:00',
    'default_reader_limit'     => 50,
    'auth_model'               => null,

    'authorization_exception' => [
        'enabled'       => true,
        'redirect_type' => 'route',
        'redirect_to'   => 'dashboard',
        'session_key'   => 'no_access',
        'message'       => 'Kamu tidak memiliki hak akses ke halaman tersebut.',
        'json_response' => true,
    ],
];
```

> **`config_version`** compare your local value with the package source after upgrading. If lower, re-publish to get new config keys.

---

Features
--------

[](#features)

### 1. Blameable Trait

[](#1-blameable-trait)

Auto-fills `created_by`, `updated_by`, `deleted_by` on Eloquent model events.

**Migration:**

```
Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->string('title');
    $table->timestamps();
    $table->softDeletes();
    $table->blameable(); // adds all three columns with FK to users
});
```

**Model:**

```
use Kuroragi\GeneralHelper\Traits\Blameable;

class Post extends Model
{
    use Blameable;
}
```

Relations are available automatically:

```
$post->createdBy;  // User
$post->updatedBy;  // User
$post->deletedBy;  // User
```

---

### 2. Blueprint Migration Macros

[](#2-blueprint-migration-macros)

```
$table->blameable();                // created_by, updated_by, deleted_by (FK to 'users')
$table->blameable('admins');        // FK to custom table
$table->blameable(null, false);     // no FK constraint

$table->createdBy();
$table->updatedBy();
$table->deletedBy();

$table->dropBlameable('posts');     // drop columns + FK
```

---

### 3. Eloquent Query Macros

[](#3-eloquent-query-macros)

```
Post::createdBy($userId)->get();
Post::updatedBy($userId)->get();
Post::deletedBy($userId)->get();

Post::createdBy()->get();           // defaults to Auth::id()
```

---

### 4. Activity Logger

[](#4-activity-logger)

```
$logger = app('kuroragi.activity');

$logger->log([
    'level'    => 'info',
    'category' => 'purchase_order',
    'message'  => 'PO #001 created',
    'meta'     => ['po_id' => 1, 'total' => 500000],
]);

$logger->transaction('Invoice finalized', ['invoice_id' => 55]);
```

Daily log files stored at `storage/logs/activity/activity-YYYY-MM-DD.log`. Each line is a JSON object.

---

### 5. Activity Log Reader

[](#5-activity-log-reader)

```
$reader = new \Kuroragi\GeneralHelper\ActivityLog\ActivityLogReader(storage_path('logs/activity'));

$reader->read();                                         // last 50 entries
$reader->read(100);                                      // last 100 entries
$reader->read(null, 'invoice');                          // keyword filter
$reader->read(null, null, 'purchase_order');             // category filter
$reader->read(null, null, null, '2026-04-01', '2026-04-02'); // date range
```

Also reads from `.zip` archives generated by the roll command.

---

### 6. Weekly Log Rotation

[](#6-weekly-log-rotation)

Logs are auto-compressed to a weekly `.zip` archive every Monday at 01:00 (configurable).

```
php artisan kuroragi:roll-activity-logs
```

Ensure the Laravel Scheduler is running:

```
* * * * * cd /path-to-project && php artisan schedule:run >> /dev/null 2>&1
```

---

### 7. Authorization Exception Handler

[](#7-authorization-exception-handler)

Handles `AuthorizationException` (403) with configurable redirect and flash message instead of a raw error page.

**Blade:**

```
@if(session('no_access'))
    {{ session('no_access') }}
@endif
```

`redirect_type`Behaviour`route``redirect()->route($redirect_to)``url``redirect($redirect_to)``back``redirect()->back()``home``redirect('/')`Returns a JSON 403 response for AJAX/Livewire requests when `json_response` is `true`.

---

### 8. General Helper Functions

[](#8-general-helper-functions)

```
use Kuroragi\GeneralHelper\GeneralHelper;

GeneralHelper::getSlug('Halo Dunia!');               // "halo-dunia"
GeneralHelper::convertDateToIndo('2026-04-02');       // "2 April 2026 00:00:00"
GeneralHelper::convertDateToIndoShort('2026-04-02'); // "02 Apr 2026"
GeneralHelper::getTerbilang(12500000);               // "dua belas juta lima ratus ribu"
GeneralHelper::getIndoDate('2026-04-02');             // "Kamis, 2 April 2026"
GeneralHelper::getIndoDateTerbilang('2026-04-02');   // "Kamis, 2 April 2026  dua"
```

---

Testing
-------

[](#testing)

```
composer test
```

---

Package Structure
-----------------

[](#package-structure)

```
kuroragi-general-helper/
 composer.json
 phpunit.xml
 CHANGELOG.md
 config/
    kuroragi.php
 src/
    GeneralHelper.php
    ActivityLog/
       ActivityLogger.php
       ActivityLogReader.php
       Commands/RollActivityLogs.php
    Macros/
       BlueprintMacros.php
       EloquentMacros.php
    Providers/
       GeneralHelperServiceProvider.php
    Traits/
        Blameable.php
 tests/
     TestCase.php
     Unit/
         GeneralHelperTest.php
         ActivityLoggerTest.php
         ActivityLogReaderTest.php
         MacrosTest.php

```

---

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for full history.

---

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance98

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~24 days

Recently: every ~35 days

Total

7

Last Release

37d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/71001c215d2b5822fb01bc072819a0a66ee6b6a127776902c95fb6738f219ba4?d=identicon)[kuroragi](/maintainers/kuroragi)

---

Top Contributors

[![kuroragi](https://avatars.githubusercontent.com/u/54569674?v=4)](https://github.com/kuroragi "kuroragi (20 commits)")

---

Tags

laravelhelpereloquentBlameableERPmacroactivity-logblueprint

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kuroragi-general-helper/health.svg)

```
[![Health](https://phpackages.com/badges/kuroragi-general-helper/health.svg)](https://phpackages.com/packages/kuroragi-general-helper)
```

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[watson/validating

Eloquent model validating trait.

9723.3M46](/packages/watson-validating)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[io238/laravel-iso-countries

Ready-to-use Laravel models and relations for country (ISO 3166), language (ISO 639-1), and currency (ISO 4217) information with multi-language support.

5462.3k](/packages/io238-laravel-iso-countries)

PHPackages © 2026

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