Laravel Eloquent

Use Laravel's beautiful Eloquent ORM with SoliDB. Build elegant applications with type-safe models, relationships, and query builders.

Why Eloquent with SoliDB?

Familiar API

Use the same Eloquent patterns you know from MySQL, PostgreSQL, or SQLite with SoliDB.

Type Safety

Leverage PHP's type system with full IDE autocompletion and documentation.

Zero Config

Install via Composer and configure your .env - that's it!

Installation

via Composer

Install the Package

composer require solidb/laravel-eloquent

Configuration

# .env
DB_CONNECTION=solidb
SOLIDB_HOST=127.0.0.1
SOLIDB_PORT=6745
SOLIDB_DATABASE=mydb
SOLIDB_USERNAME=admin
SOLIDB_PASSWORD=secret

Or in config/database.php

'connections' => [
    'solidb' => [
        'driver' => 'solidb',
        'host' => env('SOLIDB_HOST', '127.0.0.1'),
        'port' => env('SOLIDB_PORT', 6745),
        'database' => env('SOLIDB_DATABASE', 'mydb'),
        'username' => env('SOLIDB_USERNAME', ''),
        'password' => env('SOLIDB_PASSWORD', ''),
    ],
],

Usage

Define models just like regular Eloquent

Basic Model

<?php

namespace App\Models;

use SoliDB\Laravel\Eloquent\SoliDBModel;

class User extends SoliDBModel
{
    protected $collection = 'users';
    
    // SoliDB automatically generates _key if not provided
    protected $fillable = ['name', 'email', 'password'];
}

CRUD Operations

// Create
$user = User::create([
    'name' => 'John Doe',
    'email' => '[email protected]',
    'password' => bcrypt('secret')
]);

// Read
$user = User::find('abc123');
$users = User::where('age', '>', 25)->get();

// Update
$user->update(['name' => 'Jane Doe']);
User::where('email', 'like', '%@example.com')->update(['active' => true]);

// Delete
$user->delete();
User::destroy('abc123');

Query Builder

// All users
$users = User::all();

// With conditions
$users = User::where('age', '>=', 18)
    ->where('active', true)
    ->orderBy('name')
    ->limit(10)
    ->get();

// Aggregations
$count = User::count();
$avgAge = User::avg('age');

// Raw SDBQL (if needed)
$results = DB::table('users')
    ->whereRaw('doc.age > @minAge', ['minAge' => 18])
    ->get();

Relationships

// One to Many
class User extends SoliDBModel
{
    public function posts()
    {
        return $this->hasMany(Post::class);
    }
}

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

// Usage
$posts = User::find('abc123')->posts;

Supported Features

What works out of the box

CRUD Operations

Full create, read, update, delete support

Query Builder

where(), orderBy(), limit(), etc.

Relationships

hasMany, belongsTo, hasOne

Transactions

DB::transaction() support

Scopes

Local and global scopes

Mass Assignment

fillable, guarded, $timestamps

Collections

Eloquent collections with map, filter

Migrations

Limited - SoliDB is schemaless

Package API

Key classes and their location

Class Path Purpose
SoliDBModel SoliDB\Laravel\Eloquent\SoliDBModel Base model class
SoliDBConnection SoliDB\Laravel\Connections\SoliDBConnection Database connection
SoliDBServiceProvider SoliDB\Laravel\SoliDBServiceProvider Laravel service provider