Soft Delete
Configurable soft delete with deleted_at column. Safe by default — only active records returned.
Built-in soft delete, eager loading, and rich criteria syntax. Powered by Doctrine DBAL.
Deprecated
Solo Base Repository is no longer maintained and will receive no new features or fixes. Use Solo Repository instead (composer require solophp/repository). It is a new package with its own API, not a drop-in replacement.
use Solo\BaseRepository\BaseRepository;
use Solo\BaseRepository\Relation\BelongsTo;
use Solo\BaseRepository\Relation\HasMany;
class PostRepository extends BaseRepository
{
protected ?string $deletedAtColumn = 'deleted_at';
protected array $relationConfig = [];
public function __construct(
Connection $connection,
public UserRepository $userRepository,
public CommentRepository $commentRepository
) {
$this->relationConfig = [
'user' => new BelongsTo(
repository: 'userRepository',
foreignKey: 'user_id',
setter: 'setUser',
),
'comments' => new HasMany(
repository: 'commentRepository',
foreignKey: 'post_id',
setter: 'setComments',
),
];
parent::__construct($connection, Post::class, 'posts');
}
}
// Usage
$posts = $postRepository
->with(['user', 'comments'])
->findBy(['status' => 'published'], ['created_at' => 'DESC'], 20, 1);composer require solophp/base-repositoryRequirements: PHP 8.3+, Doctrine DBAL ^4.3