Is it possible to use Filament fields inside custom "Livewire" Action classes?

So, if you are aware of the Action classes that are implemented in a plugin similar to Jetstream, you might understand what I am speaking about. If not, I will explain.

In the hierarchy of a Custom Action class, first there is a registered class/callback such as an Interface using the singleton() design pattern. This Interface contains methods needed to implement the Action class. First, there is a Livewire Component that contains a method using Interface Injection variant of the Dependency Injection design pattern like this.

The Livewire Component:
namespace Wallo\FilamentCompanies\Http\Livewire;

use Livewire\Component;
use Wallo\FilamentCompanies\Contracts\UpdatesCompanyNames;

class UpdateCompanyNameForm extends Component
{
    /**
     * Update the company's name.
     */
    public function updateCompanyName(UpdatesCompanyNames $updater): void
    {
        $updater->update($this->user, $this->company, $this->state);
    }
}


This is then extended by the Action class like this:
namespace App\Actions\FilamentCompanies;

use App\Models\Company;
use App\Models\User;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Validator;
use Wallo\FilamentCompanies\Contracts\UpdatesCompanyNames;

class UpdateCompanyName implements UpdatesCompanyNames
{
    public function update(User $user, Company $company, array $input): void
    {
        Gate::forUser($user)->authorize('update', $company);

        Validator::make($input, [
            'name' => ['required', 'string', 'max:255'],
        ])->validateWithBag('updateCompanyName');

        $company->forceFill([
            'name' => $input['name'],
        ])->save();
    }
}

My question:
Is it possible to use Filament fields in the Action class instead of what is used here so that Users of my package can change the fields without touching the blade view? If so, how could this be done?
Was this page helpful?