PHPackages                             stietotalwin/arif-rh-ci4-dynamic-model-extended - 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. stietotalwin/arif-rh-ci4-dynamic-model-extended

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

stietotalwin/arif-rh-ci4-dynamic-model-extended
===============================================

Creating CodeIgniter 4 Model on-the-fly with Relationship Built-in Feature.

1.0.0(1y ago)0171MITPHPPHP &gt;=7.2

Since May 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/stietotalwin/arif-rh-ci4-dynamic-model-extended)[ Packagist](https://packagist.org/packages/stietotalwin/arif-rh-ci4-dynamic-model-extended)[ Docs](https://github.com/stietotalwin/arif-rh-ci4-dynamic-model-extended)[ RSS](/packages/stietotalwin-arif-rh-ci4-dynamic-model-extended/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (1)

DynaModel
=========

[](#dynamodel)

Dynamic Model for CodeIgniter 4 Extended by Stie Total Win Forked from Arif RH

================================================================================

Feature
-------

[](#feature)

- Dynamically Creating the Model on-the-fly
- Support One-to-One / Many-to-One relationship
- Support One-to-Many relationship
- Can Filter data based on child/related criteria
- Can set the order of One-to-Many relationship result based on child criteria

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

[](#installation)

`composer require stietotalwin/arif-rh-ci4-dynamic-model-extended`

Usage
-----

[](#usage)

### Simple

[](#simple)

```
    // creating postModel on-the-fly, just pass a table name
    $postModel = \StieTotalWin\DynaModel\DB::table('posts');

    // then you can use it, to get all posts
    $postModel->findAll();
```

### Many-to-One Relationship

[](#many-to-one-relationship)

```
    // assume that posts always belongs to one author using author_id
    $postModel->belongsTo('authors);

    // then you can grab author info along with posts
    $postModel->with('authors')->findAll();

    /**
    * by default, primary key of authors will be omit in the column result
    * because its value already exist in the foregin key of relationship
    *
    * if authors has same column name with posts, then it will be aliased with prefix "author_"
    * for example, both posts and authors has "rating" column, then it will become author_rating
    */

    // you can call only spesific column if you need, pass it on the second parameters in array
    $postModel->with('authors', ['name', 'rating'])->findAll();
    // will display all posts column, plus author name and author rating

    // you can filter posts based on author criteria
    $postModel->with('authors')->whereRelation('authors', ['status' => 'active'])->findAll();
    // will display all posts only from active authors
```

### One-to-Many Relationship

[](#one-to-many-relationship)

```
    $postModel->hasMany('comments');

    // this will return posts with all related comments
    $postModel->with('comments')->findAll();

    // you can also filter posts based on comments criteria
    $postModel->with('comments')->whereRelation('comments', ['status' => 'approved'])->findAll();
    // will display all posts with approved comments only
```

Testing
-------

[](#testing)

```
    composer test

    // or

    composer testdox

    // analyse code
    composer analyse
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance49

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity32

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

Unknown

Total

1

Last Release

370d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/929cc5d6fc2e8c4f7c6254b83137ec6edf683a16f4330f07917e13362e1f1453?d=identicon)[yayasanmangunkarsa](/maintainers/yayasanmangunkarsa)

---

Top Contributors

[![aldinokemal](https://avatars.githubusercontent.com/u/14232125?v=4)](https://github.com/aldinokemal "aldinokemal (6 commits)")

---

Tags

modelci4 modelcodeigniter modelcodeigniter4 modelcodeigniter4 relationshipci4 relationship model

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/stietotalwin-arif-rh-ci4-dynamic-model-extended/health.svg)

```
[![Health](https://phpackages.com/badges/stietotalwin-arif-rh-ci4-dynamic-model-extended/health.svg)](https://phpackages.com/packages/stietotalwin-arif-rh-ci4-dynamic-model-extended)
```

###  Alternatives

[arif-rh/ci4-dynamic-model

Creating CodeIgniter 4 Model on-the-fly with Relationship Built-in Feature.

1710.3k4](/packages/arif-rh-ci4-dynamic-model)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[prettus/l5-repository

Laravel 5|6|7|8|9|10|11|12 - Repositories to the database layer

4.2k10.8M145](/packages/prettus-l5-repository)[spatie/laravel-translatable

A trait to make an Eloquent model hold translations

2.4k23.0M413](/packages/spatie-laravel-translatable)[spatie/eloquent-sortable

Sortable behaviour for eloquent models

1.5k22.9M268](/packages/spatie-eloquent-sortable)[venturecraft/revisionable

Keep a revision history for your models without thinking, created as a package for use with Laravel

2.6k6.6M51](/packages/venturecraft-revisionable)

PHPackages © 2026

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