cryonighter/formula-doctrine-bundle
Pros:
#[Formula] syntax (similar to Hibernate) improves entity clarity.Cons:
doctrine/orm). Assumes Symfony 6.4+ (PHP 8.2+).Bundle system (no Laravel equivalent).cryonighter/formula-doctrine) to Laravel/Eloquent (high effort, requires rewriting Doctrine listeners for Eloquent’s query builder).#[Formula] attribute + Eloquent query macros).selectRaw).select clauses) if integration fails.selectRaw, or database views)?select + accessors) been evaluated?postLoad) doesn’t map 1:1 to Laravel’s model events.getXAttribute).selectRaw or custom queries).#[Formula] as a Laravel attribute macro + Eloquent query macros.
// app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Eloquent;
Eloquent::macro('formula', function ($sql) {
return $this->selectRaw("({$sql}) as formula_value");
});
// Model
class Customer extends Model {
public function getOrderCountAttribute() {
return $this->formula('(SELECT COUNT(*) FROM orders WHERE customer_id = id)');
}
}
cryonighter/formula-doctrine and adapt for Eloquent.
Builder/Query classes.Model::with('relations')->get()).select clauses may bypass cache).getXAttribute).selectRaw or query macros for complex cases.Formula attribute parsing and SQL injection).{this} placeholders).#[Formula] usage, edge cases (e.g., circular references), and performance implications.cryonighter/formula-doctrine is unmaintained (no recent commits, no dependents).select clauses may not scale as efficiently as joins in some databases.select may impact read replicas or sharded setups.| Scenario | Impact | Mitigation |
|---|---|---|
| Formula SQL syntax error | Query fails at |
How can I help you explore Laravel packages today?