{ Laravel snippets }

ModestasV

ModestasV @ModestasMV

TIP: You want to export #laravel eloquent query to native mysql? Here's a quick way to do it: https://t.co/ORGfKtEHNY - Gives out everything you need to run it in mysql console * Warning, doesn't go friendly with relationships and so on. Works on single queries

Caleb Porzio

Caleb Porzio @calebporzio

@jmlallier Here's when ->zip()'s useful: Taking vertical slices of horizontally grouped data (think rows and columns in a DB). If each row is a "year", & each column is "sales/mo" (12 columns), you could get "January sales over 3 years like so": $year1->zip($year2, $year3)->first()

Tim MacDonald

Tim MacDonald @timacdonald87

Step 2: Return your dedicated builder from the `newEloquentBuilder` method on your model. ? Scopes on your model will continue to function, so you can progressively refactor if you need. https://t.co/mEXv7MZz80

Tim MacDonald

Tim MacDonald @timacdonald87

? Want to thin out your @laravelphp models? You can relocate scopes to dedicated builder object. Gain: ✅ Thinner models ✅ Click through in your editor ✅ Static analysis (if that's ur bag) Lose: ❎ Having every co-located Step 1: Make a custom builder https://t.co/yr8UZs0gB7