Core concepts
Four words come back everywhere in Eloquentize: source, line, metric and widget. Here is what each one means, from the biggest to the smallest.
How it fits together
Eloquentize has three parts:
- A package that you install in each Laravel app. It adds Artisan commands.
- An API that the package calls for you. You never call it yourself.
- A dashboard at eloquentize.com, where your numbers become charts.
Source
A source is one Laravel app in one environment. It is identified by APP_URL and APP_ENV.
You never create a source by hand. The first time a command runs on a server, its source appears on your dashboard.
Line
A line is one thing that is counted, for one source. It is defined by:
- the source it belongs to;
- the period: one day (for now);
- an Eloquent model, such as
UserorBill; - an event: the date column used,
created_at,updated_atordeleted_at; - an operation:
countby default, orsum,avg,minormaxon a property of the model; - an optional unit, such as EUR, USD or DEGREE;
- an optional divisor, if you store money as integers (for example, cents with a divisor of 100).
Here are two lines:
| Source | Period | Model | Event | Operation | Unit | Divisor |
|---|---|---|---|---|---|---|
| app.myproject.com | day | User | created_at | count | none | none |
| app.myproject.com | day | Bill | created_at | avg of price |
EUR | 100 |
The first line answers "How many users were created each day?". The second answers "What is the average bill price each day, in euros?".
Lines are created automatically when you run the commands.
Metric
A metric is the value of one line for one day.
// How the metric of the "User created" line is calculated for yesterday:
User::whereDate('created_at', $yesterday)->count();
// 32 means "32 users were created yesterday"
When your scheduler runs the commands, each result is sent to Eloquentize as a metric.
Widget
A widget is a chart or a counter on your dashboard. It shows the metrics of one or several lines from one source.
You choose the models to display. For example, a widget can follow only the Report and Patient models of one app, to compare how fast each one grows.
You can build as many widgets as you want and put them side by side, to see all your apps at once.