Files
Obsidian-Vault/Career/Resources/Laracast/Eloquent Performance Patterns.md
2025-10-25 20:11:21 +02:00

23 lines
559 B
Markdown

### Getting one recode from a has many relation
addSelect(['value_name' => Model::whereColumn('a','table.b')->take(1)])
### Dynamic Relationships Using Subqueries
The relation column can be added using a addSelect
### Calculate Totals Using Conditional Aggregates
case exists
### Optimize Circular Relationships
Manual set relation to the model instead of loading it again
### Getting LIKE to use an Index
Dont use wildcards on both sides
### Use Unions to Run Queries Independently
Where in
derived table
find users by x
union
find users by y