© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
4 replies
πTeR

It is possible do use __construct on Edit Page?

I'm using a service on a __construct inside a create page, and it is working like a charm.
But when I use it in a EditPage, I have this error message

Target [App\Http\Services\PaymentTransaction\PaymentTransactionServiceContract] is not instantiable while building [App\Filament\Resources\PaymentIntentionResource\Pages\EditPaymentIntention].
Solution
Ok I tryed it:

    public function mount(int|string $record): void
    {
        parent::mount($record);
        $this->paymentTransactionService = app()->make(PaymentTransactionServiceContract::class);
    }
    public function mount(int|string $record): void
    {
        parent::mount($record);
        $this->paymentTransactionService = app()->make(PaymentTransactionServiceContract::class);
    }

But it still not working, and I solved using app()->make() directly on beforeSave() method..

Something like this:

    protected function beforeSave(): void
    {
        app()->make(PaymentTransactionServiceContract::class)->createTransaction($this->data, $this->getRecord());
    }
    protected function beforeSave(): void
    {
        app()->make(PaymentTransactionServiceContract::class)->createTransaction($this->data, $this->getRecord());
    }


Nice hint @awcodes 🙏
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

"use" table/infolist fields on edit page
FilamentFFilament / ❓┊help
3y ago
__construct being called twice on custom page
FilamentFFilament / ❓┊help
3y ago
IT IS POSSIBLE TO ADD "EDIT BUTTON" on VIEW MODAL?
FilamentFFilament / ❓┊help
2y ago
Is it possible to show multiple modals on page
FilamentFFilament / ❓┊help
2y ago