PHPackages                             axolote-source/laravel-logics - 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. axolote-source/laravel-logics

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

axolote-source/laravel-logics
=============================

Logics library for Laravel projects

1.0.0(3mo ago)455↓71.1%MITPHPPHP ^8.4

Since Mar 25Pushed 2mo agoCompare

[ Source](https://github.com/AxoloteSource/laravel-logics)[ Packagist](https://packagist.org/packages/axolote-source/laravel-logics)[ RSS](/packages/axolote-source-laravel-logics/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

Laravel Logics
==============

[](#laravel-logics)

[![Latest Version on Packagist](https://camo.githubusercontent.com/05354b2a4466282fcc5b8f62f055ca21ded19a0b6ee46004c389c2a36d8fe29c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61786f6c6f74652d736f757263652f6c61726176656c2d6c6f676963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/axolote-source/laravel-logics)[![Total Downloads](https://camo.githubusercontent.com/9c562af43d02e8b6a662b4c06ce1e556ad814176657cd6d2ea927aedd9122a4b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61786f6c6f74652d736f757263652f6c61726176656c2d6c6f676963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/axolote-source/laravel-logics)

A library for Laravel that provides a structured way to handle business logic using specialized classes (Logics) injected into controllers. This approach helps keep controllers thin and promotes code reuse and testability.

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

[](#installation)

You can install the package via composer:

```
composer require axolote-source/laravel-logics
```

AI Agent Skills
---------------

[](#ai-agent-skills)

This package includes a command to install "skills" (rules and guides) for AI agents like Codex, Claude, and Junie. These skills help the AI understand how to work with the Logics in your project, providing context about lifecycle, validation, and naming conventions.

To install the skills, run:

```
php artisan logics:install-skills
```

### Available Skills

[](#available-skills)

Once installed, the following skills will be available to your AI agent:

- **logics-index**: Instructions for listing resources, pagination, and filtering.
- **logics-store**: Guidance for creating new resources and automatic model filling.
- **logics-show**: Instructions for retrieving a single resource.
- **logics-update**: Guidance for updating existing resources.
- **logics-delete**: Instructions for removing resources (hard/soft deletes).
- **logics-endpoint**: Comprehensive guide on how to link routes, controllers, permissions (`isAllow`), and requirements for creating new features, including testing.

### How to use them

[](#how-to-use-them)

When you use an AI agent (like Junie, Codex, or Claude), it will automatically pick up these rules if it supports them. You can also explicitly ask the agent to:

- "Create a new index endpoint for the Product model using the logics-index skill."
- "Implement a StoreLogic for the Order model following logics-store."
- "Add a new route in `routes/modules/` and a permission in `config/actions.php` using the logics-endpoint guide."

Core Concept: Logics
--------------------

[](#core-concept-logics)

Logics are classes that encapsulate a specific action on a model (or multiple models). They follow a predefined execution flow:

1. **`before()`**: Validation or pre-processing logic. Returns `bool`.
2. **`action()`**: The main business logic execution. Returns `self`.
3. **`after()`**: Post-processing logic (e.g., logging, notifications). Returns `bool`.

### Base Logic Class

[](#base-logic-class)

The `Logic` class is the foundation for all other logics. It provides common functionality like error handling and response formatting. Use it when your action doesn't fit into standard CRUD operations.

```
use AxoloteSource\Logics\Logics\Logic;

class CustomActionLogic extends Logic {
    protected function before(): bool {
        // Validation logic
        return true;
    }

    protected function action(): self {
        // Business logic here
        return $this;
    }

    protected function after(): bool {
        // Post-action logic
        return true;
    }
}
```

Specialized Logics
------------------

[](#specialized-logics)

The package includes pre-built abstract classes for standard CRUD operations:

### 1. IndexLogic

[](#1-indexlogic)

Used for listing resources. It includes built-in support for:

- **Pagination**: Automatic handling of `limit` and `page`.
- **Filtering**: Flexible system for applying filters to the query.
- **Search**: Basic search functionality on a specified column.

### 2. StoreLogic

[](#2-storelogic)

Used for creating new resources. It handles:

- Data mapping from `input` to the `model`.
- Automatic saving of the model.

### 3. ShowLogic

[](#3-showlogic)

Used for retrieving a single resource by its ID or a specific attribute.

### 4. UpdateLogic

[](#4-updatelogic)

Used for updating an existing resource. Similar to `StoreLogic`, but works on an existing model instance.

### 5. DeleteLogic

[](#5-deletelogic)

Used for removing a resource. It can handle both hard and soft deletes.

Flow: Automated Logic Execution
-------------------------------

[](#flow-automated-logic-execution)

The `Flow` sub-package allows for a more automated way to handle CRUD operations by mapping routes to models and resources dynamically.

It uses traits like `FlowLogic` to:

- Validate if a model is allowed for the current operation.
- Automatically transform the result using the mapped Eloquent Resource.
- Handle permissions based on user actions.

Example components of Flow:

- `FlowIndexLogicBase`: Base for automated listing.
- `FlowStoreLogicBase`: Base for automated creation.
- `FlowShowLogicBase`: Base for automated single resource retrieval.
- `FlowUpdateLogicBase`: Base for automated updating.
- `FlowDeleteLogicBase`: Base for automated deletion.

Benefits
--------

[](#benefits)

- **Structured Code**: Clearly defined execution steps (`before`, `action`, `after`).
- **Consistency**: Standardized way of handling CRUD across the application.
- **Reusability**: Core logic is decoupled from controllers.
- **Extensibility**: Easily extend base classes to add custom behavior.

Testing
-------

[](#testing)

To run the package tests, install dependencies and execute PHPUnit:

```
composer install
vendor/bin/phpunit
```

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance86

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Unknown

Total

1

Last Release

93d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15320788?v=4)[Luis Ozuna](/maintainers/LuisOzParr)[@LuisOzParr](https://github.com/LuisOzParr)

---

Top Contributors

[![LuisOzParr](https://avatars.githubusercontent.com/u/15320788?v=4)](https://github.com/LuisOzParr "LuisOzParr (5 commits)")

### Embed Badge

![Health badge](/badges/axolote-source-laravel-logics/health.svg)

```
[![Health](https://phpackages.com/badges/axolote-source-laravel-logics/health.svg)](https://phpackages.com/packages/axolote-source-laravel-logics)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

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

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45344.0k1](/packages/pressbooks-pressbooks)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)

PHPackages © 2026

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