Skip to content

v2.0.0

Choose a tag to compare

@SoloPHP SoloPHP released this 26 Dec 22:57
· 29 commits to main since this release

Here's the cleaned-up version:


Breaking Changes

  • Relation configuration now uses DTO classes instead of arrays
    • Old format ['belongsTo', 'repo', 'fk', 'setter'] no longer supported
  • Operator syntax changed from positional to associative arrays
    • Old: ['!=', 'value'] → New: ['!=' => 'value']
  • Removed useAutoIncrement property (custom IDs now auto-detected)

New Features

  • BelongsToMany relation for many-to-many via pivot tables
  • Relation DTO classes: BelongsTo, HasOne, HasMany, BelongsToMany
  • Automatic custom ID detection in create()
  • Support for custom/UUID primary keys in all relation types

Improvements

  • Unambiguous operator syntax — no conflicts between ['!=', 'val'] and IN-lists ['a', 'b']
  • Lazy initialization of EagerLoadingService

Migration

Relations:

// Before
'user' => ['belongsTo', 'userRepository', 'user_id', 'setUser']

// After
'user' => new BelongsTo(
    repository: 'userRepository',
    foreignKey: 'user_id',
    setter: 'setUser',
)

Operators:

// Before
['status' => ['!=', 'deleted'], 'age' => ['>=', 18]]

// After
['status' => ['!=' => 'deleted'], 'age' => ['>=' => 18]]

Custom IDs:

// Before
protected bool $useAutoIncrement = false; // Remove this

// After — auto-detected:
$repo->create(['uuid' => 'custom-123', ...]); // Uses provided ID
$repo->create(['name' => 'Test']);            // Uses lastInsertId()