定制 forjix/orm 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

forjix/orm

最新稳定版本:0.1.0

Composer 安装命令:

composer require forjix/orm

包简介

Forjix Framework ORM

README 文档

README

Active Record ORM for the Forjix framework with relationships support.

Installation

composer require forjix/orm

Defining Models

use Forjix\Orm\Model;

class User extends Model
{
    protected string $table = 'users';

    protected array $fillable = ['name', 'email'];

    protected array $hidden = ['password'];
}

Basic Operations

// Create
$user = User::create([
    'name' => 'John',
    'email' => 'john@example.com',
]);

// Find
$user = User::find(1);
$user = User::findOrFail(1);

// Query
$users = User::where('active', true)
    ->orderBy('name')
    ->get();

// Update
$user->name = 'Jane';
$user->save();

// Delete
$user->delete();

Relationships

Has One

class User extends Model
{
    public function profile(): HasOne
    {
        return $this->hasOne(Profile::class);
    }
}

Has Many

class User extends Model
{
    public function posts(): HasMany
    {
        return $this->hasMany(Post::class);
    }
}

Belongs To

class Post extends Model
{
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}

Belongs To Many

class User extends Model
{
    public function roles(): BelongsToMany
    {
        return $this->belongsToMany(Role::class);
    }
}

Eager Loading

$users = User::with('posts', 'profile')->get();

License

GPL-3.0

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2026-01-05