PHPackages                             tschucki/filament-workflows - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. tschucki/filament-workflows

ActiveLibrary

tschucki/filament-workflows
===========================

Add workflows to your filament app

0.0.5(1y ago)171.4k3[4 PRs](https://github.com/Tschucki/filament-workflows/pulls)MITPHPPHP ^8.1CI passing

Since Jan 28Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/Tschucki/filament-workflows)[ Packagist](https://packagist.org/packages/tschucki/filament-workflows)[ Docs](https://github.com/tschucki/filament-workflows)[ GitHub Sponsors](https://github.com/Tschucki)[ RSS](/packages/tschucki-filament-workflows/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (12)Versions (11)Used By (0)

Add workflows to your filament app
==================================

[](#add-workflows-to-your-filament-app)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c512a1b8778eb939435f4e742e730a6821d119ae7c742e01909566256626e5f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7473636875636b692f66696c616d656e742d776f726b666c6f77732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tschucki/filament-workflows)[![GitHub Tests Action Status](https://camo.githubusercontent.com/f083ef0a0abac811312808914ebd2b5931cf9ead0722cbf5bf4a8e21166221d3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7473636875636b692f66696c616d656e742d776f726b666c6f77732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/tschucki/filament-workflows/actions?query=workflow%3Arun-tests+branch%3Amain)[![Fix PHP Code Styling](https://github.com/Tschucki/filament-workflows/actions/workflows/fix-php-code-styling.yml/badge.svg)](https://github.com/Tschucki/filament-workflows/actions/workflows/fix-php-code-styling.yml)[![Total Downloads](https://camo.githubusercontent.com/db68a13bf8de5af0265fad57f39967c1c4c6f6bf219e5e38da30f488015a6c67/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7473636875636b692f66696c616d656e742d776f726b666c6f77732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tschucki/filament-workflows)

This plugin lets you add workflows to your filament app. You can attach triggers and dispatchable actions to your workflows. The plugin will automatically execute the actions when the trigger conditions are met.

Table of Contents
-----------------

[](#table-of-contents)

- [Images](#images)
- [Installation](#installation)
- [Usage](#usage)
    - [Basics](#basics)
    - [Add the trait to your model](#add-the-trait-to-your-model)
    - [Create an Action](#create-an-action)
- [Configuration](#configuration)
    - [Define searchable field](#define-searchable-field)
    - [Max Search Results](#max-search-results)
- [Testing](#testing)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Security Vulnerabilities](#security-vulnerabilities)
- [Credits](#credits)
- [License](#license)

Images
------

[](#images)

[![Screenshot 1](.github/images/Basic-Form.png)](.github/images/Basic-Form.png)[![Screenshot 2](.github/images/Trigger-Form.png)](.github/images/Trigger-Form.png)[![Screenshot 3](.github/images/Actions-Form.png)](.github/images/Actions-Form.png)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require tschucki/filament-workflows
```

You can install the plugin using:

```
php artisan filament-workflows:install
```

You can publish and run the migrations manually with:

```
php artisan vendor:publish --tag="filament-workflows-migrations"
php artisan migrate
```

Register the plugin in your `AdminPanelServiceProvider`:

```
use Tschucki\FilamentWorkflows\FilamentWorkflowsPlugin;

->plugins([
    FilamentWorkflowsPlugin::make()
])
```

Usage
-----

[](#usage)

### Basics

[](#basics)

In order to let your models use workflows, you need to add the `InteractsWithWorkflows` trait to your model. By adding this trait, the plugin will automatically add a global observer to your model. So when ever a workflow matches the event and trigger conditions, the workflow will execute the actions.

### Add the trait to your model

[](#add-the-trait-to-your-model)

```
use Tschucki\FilamentWorkflows\Concerns\InteractsWithWorkflow;

class User extends Model {
  use InteractsWithWorkflow;
}
```

### Create an Action

[](#create-an-action)

In order to attach an action to your workflows, you will have to create a class within the `App\Jobs\Actions` folder. The class must extend the `BaseAction` class. This requires you to implement the `handle` method. This method will be called when the workflow is executed.

The action class is very similar to a job. When ever the action get executed, the model will be passed to the `__construct` method. You can use the model to do whatever you want.

The plugin will find this class on its own. So you don't have to register it anywhere.

```
