PHPackages                             simp/modal - 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. simp/modal

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

simp/modal
==========

This is package that will be standalone modal creations

v1.0.2(8mo ago)0111MITPHP

Since Sep 11Pushed 8mo agoCompare

[ Source](https://github.com/CHANCENY/modal)[ Packagist](https://packagist.org/packages/simp/modal)[ RSS](/packages/simp-modal/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (2)Versions (4)Used By (1)

Simp Modal
==========

[](#simp-modal)

This project demonstrates a lightweight PHP Modal system with **CRUD operations, relations, and query building**.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Initializing Modals](docs/modal.md)
- [Inserting Records](docs/modal.md#inserting-records)
- [Selecting Specific Columns](docs/modal.md#selecting-specific-columns)
- [Relations](docs/modal.md#relations)
    - [User ↔ Role Relations](docs/modal.md#user-%E2%86%94-role-relations)
- [Usage Examples](docs/modal.md#usage-examples)
    - [Has One Relation (User -&gt; Role)](docs/modal.md#has-one-relation-user--role)
    - [Has Many Relation (User -&gt; Roles)](docs/modal.md#has-many-relation-user--roles)
    - [Belongs To Relation (Role -&gt; User)](docs/modal.md#belongs-to-relation-role--user)
- [Complex Query Example](docs/modal.md#complex-query-example)
- [Update Example](docs/modal.md#update-example)
- [Delete Example](docs/modal.md#delete-example)
- [Migrations](docs/migration.md)
    - [Create Migration](docs/migration.md#create-migration)
    - [Run Migrate](docs/migrate.md#run-migrate)
    - [Modify Migration](docs/modify.md#modify-migration)
    - [Drop Tables](docs/drop.md#drop-tables)
- [Notes](#notes)

---

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

[](#installation)

```
composer require simp/modal
```

Make sure your database is running and accessible. Update the database connection settings in `example.php`:

```
$db = new PDO('mysql:host=database;dbname=lamp', 'lamp', 'lamp');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
```

---

Initializing Modals
-------------------

[](#initializing-modals)

```
$userModal = UserTestModal::getModal($db);
$roleModal = RoleTestModal::getModal($db);
```

Clear tables before seeding:

```
$db->exec("DELETE FROM {$roleModal->getTable()}");
$db->exec("ALTER TABLE {$roleModal->getTable()} AUTO_INCREMENT = 1");
$db->exec("DELETE FROM {$userModal->getTable()}");
$db->exec("ALTER TABLE {$userModal->getTable()} AUTO_INCREMENT = 1");
```

---

Inserting Records
-----------------

[](#inserting-records)

```
$aliceId   = $userModal->fill(['name' => 'Alice', 'email' => 'alice@example.com', 'password' => 'secret'])->insert();
$bobId     = $userModal->fill(['name' => 'Bob', 'email' => 'bob@example.com', 'password' => 'pass'])->insert();
$charlieId = $userModal->fill(['name' => 'Charlie', 'email' => 'charlie@example.com', 'password' => '1234'])->insert();

$roleModal->fill(['role_name' => 'Admin', 'uid' => $aliceId])->insert();
$roleModal->fill(['role_name' => 'Editor', 'uid' => $bobId])->insert();
$roleModal->fill(['role_name' => 'Subscriber', 'uid' => $bobId])->insert();
$roleModal->fill(['role_name' => 'Viewer', 'uid' => $charlieId])->insert();
```

---

Selecting Specific Columns
--------------------------

[](#selecting-specific-columns)

```
$usersSelected = $userModal
    ->select(['id', 'name'])
    ->limit(3)
    ->orderBy('id', 'ASC')
    ->get();
```

---

Relations
---------

[](#relations)

### User ↔ Role Relations

[](#user--role-relations)

```
User -> hasOne Role
User -> hasMany Roles
Role -> belongsTo User

```

#### Diagram

[](#diagram)

```
+-----------------+        hasOne        +-----------------+
|      User       |--------------------->|       Role      |
|-----------------|                      |-----------------|
| id              |                      | id              |
| name            |                      | role_name       |
| email           |                      | uid (user_id)   |
| password        |                      | description     |
+-----------------+                      +-----------------+
       | 1
       | hasMany
       v
+-----------------+
|      Role       |
|-----------------|
| id              |
| role_name       |
| uid (user_id)   |
| description     |
+-----------------+

```

---

Usage Examples
--------------

[](#usage-examples)

### Has One Relation (User -&gt; Role)

[](#has-one-relation-user---role)

```
$alice = $userModal->where('id', '=', $aliceId)->first();
$aliceRole = $roleModal->where('uid', '=', $alice['id'])
                       ->select(['role_name', 'uid'])
                       ->first();
```

### Has Many Relation (User -&gt; Roles)

[](#has-many-relation-user---roles)

```
$bob = $userModal->where('id', '=', $bobId)->first();
$bobRoles = $roleModal->where('uid', '=', $bob['id'])
                      ->select(['role_name','uid'])
                      ->get();
```

### Belongs To Relation (Role -&gt; User)

[](#belongs-to-relation-role---user)

```
$editorRole = $roleModal->where('role_name', '=', 'Editor')->first();
$editorUser = $userModal->where('id', '=', $editorRole['uid'])
                        ->select(['name', 'email'])
                        ->first();
```

---

Complex Query Example
---------------------

[](#complex-query-example)

```
$complexUsers = $userModal
    ->whereIn('id', [$aliceId, $bobId])
    ->orWhere('name', '=', 'Charlie')
    ->select(['id', 'name', 'email'])
    ->orderBy('id', 'DESC')
    ->get();

// Attach hasMany roles for each user
foreach ($complexUsers as &$user) {
    $user['roles'] = $roleModal->where('uid', '=', $user['id'])
                               ->select(['role_name','uid'])
                               ->get();
}
```

---

Update Example
--------------

[](#update-example)

```
$updateCount = $userModal->where('id', '=', $aliceId)
                         ->fill(['name' => 'Alice Updated'])
                         ->update();

$updatedUser = $userModal->where('id', '=', $aliceId)->first();
```

---

Delete Example
--------------

[](#delete-example)

```
$deleteCount = $roleModal->where('role_name', '=', 'Viewer')->delete();
$remainingRoles = $roleModal->get();
```

---

Notes
-----

[](#notes)

- **Select**: Choose specific columns with `select()`.
- **Where In / Or Where**: Build complex queries with `whereIn()` and `orWhere()`.
- **Relations**: Use `hasOne`, `hasMany`, and `belongsTo` to link modals.
- **Query Reset**: Each query resets automatically after execution.
- **Mass Assignment**: Use `fill()` for safe attribute assignment.

---

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance61

Regular maintenance activity

Popularity5

Limited adoption so far

Community8

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

Total

3

Last Release

247d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25077813?v=4)[Chance007](/maintainers/Chance007)[@CHANCE007](https://github.com/CHANCE007)

---

Top Contributors

[![CHANCENY](https://avatars.githubusercontent.com/u/96126430?v=4)](https://github.com/CHANCENY "CHANCENY (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/simp-modal/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M420](/packages/drupal-core-recommended)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

318123.0k1](/packages/cognesy-instructor-php)

PHPackages © 2026

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