Pckg Documentation
Pckg Documentation
  • About
  • Concept
  • Start
  • Deployment
  • Tests
  • Ecosystem
    • Docker images
    • Skeleton
  • Core packages
    • Auth
    • Cache
    • Collection
    • Concept
    • Database
      • Repository
        • Driver
      • Entity
        • Relations
        • Query
      • Record
        • Fields
        • Model
      • Events
      • Extensions
    • Framework
      • Environment
        • Console
        • Development
        • Production
        • Test
      • Application
      • Providers
      • Config
      • Router
      • Request
      • Response
      • Controller
        • Middleware
        • Afterware
      • View
      • Events
      • Exception
    • Generic
      • Dynamic
      • Generic
      • Maestro
    • Htmlbuilder
      • Elements
        • Form
        • Fields
      • Datasources
      • Validators
      • Decorators
    • Locale
    • Mail
      • Drivers
      • Template
      • Mail
    • Manager
      • Asset manager
      • SEO manager
      • Meta manager
      • Upload manager
      • Vue manager
      • Job manager
      • Locale manager
      • Page manager
    • Migrator
      • Migrations
      • Fields
    • Queue
      • Driver
      • Publisher
      • Subscriber
    • Storage
      • Driver
      • Media
    • Translator
  • More packages
    • API
    • HTTP QL
      • Read
      • Write
      • Uploads
    • Task
      • Async
    • Websocket
      • Server
      • Client
  • Frontend
    • Helpers JS
    • Helpers CSS
  • Extras
    • Parser
    • Payment
    • Tenant
Powered by GitBook
On this page
  • Fetching all rows (Collection)
  • Fetching single row (Record)
  • Applying filters
  • Sorting data
  • Joining relations
  • Applying limits
  • Lazy loading
  • Eager loading
  • Counting data

Was this helpful?

  1. Core packages
  2. Database
  3. Entity

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();
PreviousRelationsNextRecord

Last updated 9 months ago

Was this helpful?