PHPackages                             corepine/actions - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. corepine/actions

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

corepine/actions
================

Polymorphic action tracking for Laravel (likes, dislikes, reactions) with synced counters.

v0.1.1(2mo ago)13MITPHPPHP ^8.2

Since Mar 8Pushed 1mo agoCompare

[ Source](https://github.com/corepine/actions)[ Packagist](https://packagist.org/packages/corepine/actions)[ RSS](/packages/corepine-actions/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (12)Versions (3)Used By (0)

Corepine Actions
================

[](#corepine-actions)

`corepine/actions` is a Laravel package for polymorphic user actions (upvotes, downvotes, reactions) with synced aggregate counters.

Install
-------

[](#install)

```
composer require corepine/actions
php artisan actions:install
```

This publishes:

- `config/corepine-actions.php`
- actions migrations
- `app/Casts/ActionType.php` cast stub

Optional flags:

```
php artisan actions:install --migrate
php artisan actions:install --force
```

Quick Start (Service / Facade)
------------------------------

[](#quick-start-service--facade)

```
use Corepine\Actions\Facades\Actions;

$isUpvoted = Actions::for($comment)->by($user)->upvote(); // true = set, false = removed
$isDownvoted = Actions::for($comment)->by($user)->downvote();

Actions::for($comment)->by($user)->reaction('👋');
Actions::for($comment)->by($user)->reaction(null); // remove reaction

$upvotes = Actions::for($comment)->count('upvote');
$downvotes = Actions::for($comment)->count('downvote');
```

Custom Action Types
-------------------

[](#custom-action-types)

Option A: add extra types directly in config:

```
'action_types' => ['bookmark'],
```

Option B: publish `app/Casts/ActionType.php`, override `types()`, and point config:

```
'action_type_cast' => \App\Casts\ActionType::class,
```

If you omit `action_type_cast`, the package uses `Corepine\Actions\Casts\ActionType` by default.

Then use custom actions:

```
Actions::for($comment)->by($user)->toggle('bookmark');
Actions::for($comment)->count('bookmark');
```

HasActions Concern
------------------

[](#hasactions-concern)

Use the built-in concern on your actionable models:

```
use Corepine\Actions\Models\Concerns\HasActions;

class Comment extends Model
{
    use HasActions;
}
```

Then call helpers directly from the model:

```
$comment->upvoteBy($user);
$comment->downvoteBy($user);
$comment->reactBy($user, '👋');

$comment->upvotedBy($user);
$comment->upvotesCount();
$comment->formattedUpvotesCount();
$comment->syncAllActionCounts();

// Manual cleanup for this actionable:
$comment->clearActionsAndCounts();

// Alias:
$comment->deleteActionsAndCounts();
```

When the actionable model is deleted, `HasActions` auto-cleans related `actions` and `action_counts` rows.

Reaction Groups (Render Ready)
------------------------------

[](#reaction-groups-render-ready)

For emoji reaction chips like `👋 6` or `❤️ 2.5K`, use grouped reactions:

```
$groups = $comment->reactionGroups();

// Each item has:
// ['reaction' => '👋', 'count' => 6, 'formatted_count' => '6']
// ['reaction' => '❤️', 'count' => 2500, 'formatted_count' => '2.5K']
```

If you already have a precomputed count, format it directly:

```
$comment->formattedReactionsCount(2500); // 2.5K
```

Counter Consistency
-------------------

[](#counter-consistency)

Counters are stored in `action_counts` and updated automatically from `Action` model created/deleted events (including service writes).

If you need to rebuild counters for a specific model:

```
Actions::for($comment)->syncAllCounts();
```

If you want `syncAllCounts()` to include custom zero-bucket types, append them:

```
Actions::for($comment)->syncAllCounts(['bookmark']);
```

If you need to delete everything for one actionable and keep tables in sync:

```
Actions::for($comment)->clear();
```

Tables
------

[](#tables)

- `actions`: one row per actor + actionable + type
- `action_counts`: aggregate count per actionable + type

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance86

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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 ~20 days

Total

2

Last Release

86d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cf89919ce854f04abccb2aa73519bd822548a310a17770f34b143fb238eaa6b0?d=identicon)[namu](/maintainers/namu)

---

Top Contributors

[![namumakwembo](https://avatars.githubusercontent.com/u/77463693?v=4)](https://github.com/namumakwembo "namumakwembo (15 commits)")

---

Tags

laravelactionslikesreactionscounters

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/corepine-actions/health.svg)

```
[![Health](https://phpackages.com/badges/corepine-actions/health.svg)](https://phpackages.com/packages/corepine-actions)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.6k](/packages/larastan-larastan)[laravel/ai

The official AI SDK for Laravel.

9782.1M161](/packages/laravel-ai)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M152](/packages/spatie-laravel-health)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)[laracraft-tech/laravel-useful-additions

A collection of useful Laravel additions!

58122.8k](/packages/laracraft-tech-laravel-useful-additions)

PHPackages © 2026

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