Query
Fetching all rows (Collection)
$collection = (new Foos())
->all();
Fetching single row (Record)
$record = (new Foos())
->one();
Applying filters
$records = (new Foos())
->where('foo', 'value')
->where('bar', 10, '>=')
->all();
Sorting data
$records = (new Foos())
->orderBy('foo', 'DESC')
->all();
Joining relations
$records = (new Foos())
->joinFoo()
->join('bar')
->join('foo.bar')
->join(['foo' => ['bar' => ['baz', 'bud']]])
->all();
Applying limits
$records = (new Foos())
->limit(10)
->all();
Lazy loading
$record = (new Foos())
->one();
$bar = $record->bar; // Record
$bars = $record->bars; // Collection of Records
Eager loading
$record = (new Foos())
->withBar()
->with('baz')
->one();
Counting data
$total = (new Foos())
->total();
Last updated
Was this helpful?