sectheater/laravel-jarvis
Laravel Jarvis adds an AI assistant to Laravel apps, letting developers interact with their application through natural language. Register tools and actions so Jarvis can query data and perform tasks securely via OpenAI-powered commands and Laravel-native integrations.
Install the package with Composer and let Laravel auto-discover its service provider. If the package publishes config or migrations, publish them first and review the defaults before writing application code.
Start by reading:
$observers property syntax.src/ directory for the Register method and repository bindings.A first practical use case is observing a model column that drives workflow state. For example, map a status column to a snake_case handler method on the model, then use that handler to send notifications, write audit records, or dispatch follow-up jobs when the column changes.
protected $observers = [
'status' => 'handle_status_change',
];
Run the package tests and your own model tests after installing, especially because v2.1.4 includes fixes to repositories and the Register method.
Use the $observers property as a declarative map from database column names to snake_case handler methods. Keep the mapping close to the model so column-level behavior is visible where the model is defined.
protected $observers = [
'status' => 'status_changed',
'published_at' => 'published_at_changed',
];
Keep observer handlers small. Prefer dispatching events or jobs from the handler rather than performing slow I/O directly, because the handler may run during normal model saves. This is especially important if a single request updates multiple models.
Integrate observers with repositories by separating responsibilities:
If the package’s Register method binds repository implementations into the container, verify those bindings in a service provider test. After the v2.1.4 fixes, confirm that resolved repository instances are the expected concrete classes and that custom bindings still take precedence.
Use model saves rather than mass updates when observers must run. Column observers typically depend on model events, so Model::where(...)->update(...) can bypass them.
For testing, assert that the handler is invoked when the observed column changes and is not invoked when unrelated columns change. If the handler dispatches jobs or events, use Laravel’s Event::fake() or Queue::fake() and assert the expected side effect.
The v2.1.4 release is a patch release, but it includes fixes to repositories and the Register method. Re-run your application test suite after upgrading, particularly if you had worked around previous registration or repository-resolution behavior.
Observer array keys must match actual database column names exactly. The handler values should use snake_case as documented; a camelCase method name may not resolve if the package performs string-based method lookup.
Avoid recursive saves inside observer handlers. If a handler updates the same model or triggers another save on the same column, guard with dirty-attribute checks or move the work to a queued job.
Column observers generally do not fire for mass updates, raw queries, or inserts that bypass model events. If those paths matter, dispatch equivalent domain events explicitly.
After upgrading, clear cached config and container bindings:
php artisan config:clear
php artisan cache:clear
composer dump-autoload
If repository resolution behaves unexpectedly, inspect the package’s Register method and your own service provider binding order. Container bindings registered later can override package defaults.
Use the newly added unit tests as debugging documentation. They are useful for confirming edge cases around observer mapping and repository registration. When adding your own handlers, log the old and new column values temporarily during development so you can verify the observer is seeing the transition you expect.
How can I help you explore Laravel packages today?