-
Notifications
You must be signed in to change notification settings - Fork 4
docs: restructure to 13-page IA + verified content audit [1.x] #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
52f149e
6ca85c6
cfc360b
2ff7025
546d55c
c68ea23
338e73a
0bcce68
170f672
388b2e2
91cd055
3d3fb7e
5105f52
b494282
c3aedca
a1717ee
13eb869
0ffa9ad
3820179
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,4 @@ composer.lock | |
| .phpunit.cache | ||
| .phpunit.result.cache | ||
| .DS_Store | ||
| .planning/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| --- | ||
| title: Quick start | ||
| description: Working timeline in 5 minutes — Person model, spatie log, infolist render. | ||
| navigation: | ||
| icon: i-lucide-rocket | ||
| seo: | ||
| description: 5-minute quickstart for relaticle/activity-log — minimal model setup and first timeline render in a Filament resource. | ||
| ogImage: /preview.png | ||
| --- | ||
|
|
||
| The smallest end-to-end path: log activity on one model with spatie, mount the timeline infolist on its Filament resource, watch entries appear. Once it works, see [/essentials/sources](/essentials/sources) to compose more sources. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Package installed (`composer require relaticle/activity-log`) — see [/getting-started/installation](/getting-started/installation). | ||
| - `spatie/laravel-activitylog`'s `activity_log` table migrated. | ||
| - At least one Filament resource ready to host the timeline (this guide uses `PersonResource`). | ||
|
|
||
| ## Step 1 — Make a model timeline-capable | ||
|
|
||
| ```php [app/Models/Person.php] | ||
| namespace App\Models; | ||
|
|
||
| use Illuminate\Database\Eloquent\Model; | ||
| use Relaticle\ActivityLog\Concerns\InteractsWithTimeline; | ||
| use Relaticle\ActivityLog\Contracts\HasTimeline; | ||
| use Relaticle\ActivityLog\Timeline\TimelineBuilder; | ||
| use Spatie\Activitylog\LogOptions; | ||
| use Spatie\Activitylog\Traits\LogsActivity; | ||
|
|
||
| final class Person extends Model implements HasTimeline | ||
| { | ||
| use InteractsWithTimeline; | ||
| use LogsActivity; | ||
|
|
||
| protected $fillable = ['name', 'email']; | ||
|
|
||
| public function getActivitylogOptions(): LogOptions | ||
| { | ||
| return LogOptions::defaults()->logFillable(); | ||
| } | ||
|
|
||
| public function timeline(): TimelineBuilder | ||
| { | ||
| return TimelineBuilder::make($this)->fromActivityLog(); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| `LogsActivity` (paired with `getActivitylogOptions`) makes spatie record create / update / delete events into the `activity_log` table. `HasTimeline` plus the `InteractsWithTimeline` trait give you `timeline()`, `paginateTimeline()`, and `forgetTimelineCache()` on the model. `fromActivityLog()` is the simplest source — the subject's own log. | ||
|
|
||
| ## Step 2 — Render the timeline on the resource view page | ||
|
|
||
| ```php [app/Filament/Resources/PersonResource.php] | ||
| namespace App\Filament\Resources; | ||
|
|
||
| use Filament\Schemas\Schema; | ||
| use Relaticle\ActivityLog\Filament\Infolists\Components\ActivityLog; | ||
|
|
||
| public function infolist(Schema $schema): Schema | ||
| { | ||
| return $schema->components([ | ||
| // ... your existing entries | ||
| ActivityLog::make('activity')->columnSpanFull(), | ||
| ]); | ||
| } | ||
| ``` | ||
|
|
||
| ::callout{icon="i-lucide-info" color="info"} | ||
| `ActivityLog` must live on a page that renders the model record (typically `ViewRecord` or `EditRecord`). The component reads the active record from the page context. | ||
| :: | ||
|
|
||
| ## Step 3 — Trigger an activity | ||
|
|
||
| Edit a Person via the Filament UI, or via tinker: | ||
|
|
||
| ```bash [Terminal] | ||
| php artisan tinker --execute 'App\Models\Person::find(1)->update(["name" => "New name"]);' | ||
| ``` | ||
|
|
||
| Refresh the view page — an entry titled "updated" appears, with the changed-fields diff inline (rendered by the built-in `ActivityLogRenderer`). | ||
|
|
||
| ## Where to next? | ||
|
|
||
| - **Compose more sources** — pull in events from related models (`fromActivityLogOf`), timestamp columns (`fromRelation`), or external APIs (`fromCustom`). See [/essentials/sources](/essentials/sources). | ||
| - **Use the relation manager or header action** — alternative Filament surfaces for the timeline. See [/essentials/filament-ui](/essentials/filament-ui). | ||
| - **Customize the rendering** — replace the spatie diff renderer per event or wholesale. See [/essentials/customization](/essentials/customization). | ||
| - **See it in context** — full real-world wiring patterns at [/recipes/crm-person-feed](/recipes/crm-person-feed). | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| title: Concepts | ||
| icon: i-lucide-compass |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,122 @@ | ||||||
| --- | ||||||
| title: How it works | ||||||
| description: The mental model and vocabulary behind the timeline pipeline. | ||||||
| navigation: | ||||||
| icon: i-lucide-compass | ||||||
| seo: | ||||||
| description: Mental model, vocabulary, and pipeline behind relaticle/activity-log timelines. | ||||||
| ogImage: /preview.png | ||||||
| --- | ||||||
|
|
||||||
| This page is the canonical reference for the package's mental model: the pipeline, the building blocks, the type taxonomy, and the dedup/priority rules. Read it once before configuring sources, writing renderers, or debugging missing entries. | ||||||
|
|
||||||
| ## The pipeline | ||||||
|
|
||||||
| ```text | ||||||
| $record->timeline() [TimelineBuilder] | ||||||
| ↓ resolves | ||||||
| TimelineSource(s) per source [resolve(subject, Window)] | ||||||
| ↓ yields | ||||||
| TimelineEntry stream [filter → dedup → sort] | ||||||
| ↓ paginated | ||||||
| LengthAwarePaginator → Renderer → Blade view | ||||||
| ``` | ||||||
|
|
||||||
| A call to `$record->timeline()` returns a fluent `TimelineBuilder`. Each registered source is asked to `resolve()` entries inside a shared `Window`. The combined stream is filtered, deduplicated, sorted, and either paginated or returned whole. Renderers turn each `TimelineEntry` into HTML at view time. | ||||||
|
|
||||||
| ## Core building blocks | ||||||
|
|
||||||
| **Subject.** Any Eloquent model implementing `Relaticle\ActivityLog\Contracts\HasTimeline`. In practice you get this for free by using the `Relaticle\ActivityLog\Concerns\InteractsWithTimeline` trait, which provides `timeline()`, `paginateTimeline()`, and `forgetTimelineCache()`. The subject is passed into every source's `resolve()` call. | ||||||
|
||||||
| **Subject.** Any Eloquent model implementing `Relaticle\ActivityLog\Contracts\HasTimeline`. In practice you get this for free by using the `Relaticle\ActivityLog\Concerns\InteractsWithTimeline` trait, which provides `timeline()`, `paginateTimeline()`, and `forgetTimelineCache()`. The subject is passed into every source's `resolve()` call. | |
| **Subject.** Any Eloquent model implementing `Relaticle\ActivityLog\Contracts\HasTimeline`. The `Relaticle\ActivityLog\Concerns\InteractsWithTimeline` trait provides helper methods such as `paginateTimeline()` and `forgetTimelineCache()`, but models still need to define `timeline(): TimelineBuilder` to satisfy the contract. The subject is passed into every source's `resolve()` call. |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InteractsWithTimelinedoesn’t providetimeline(); consumers must implement it to satisfyHasTimeline. This paragraph currently implies the trait “gives youtimeline()” — suggest rewording to say it providespaginateTimeline()/forgetTimelineCache()helpers while you definetimeline()yourself.