Aminne
Aminne
FFilament
Created by Aminne on 10/19/2024 in #❓┊help
I can't make a feature test on custom action
I have this custom action with two forms,
<x-filament-panels::page>
<x-filament-panels::form wire:submit="approveTransaction">
<div style="display: flex; gap: 20px; align-items: stretch">
<div class="flex-1">
{{ $this->approveTransactionForm }}
</div>
@if ($media = $this->getTransaction($this->record)->getFirstMedia('images'))
<div class="flex-1">
<img src="{{ $media->getUrl() }}" alt="Avatar" class="h-auto w-full object-cover" />
</div>
@endif
</div>

@if ($this->getTransaction($this->record)->getFirstMedia('images'))
<div class="mt-2">
{{ $this->confirmedTransactionForm }}
</div>
@endif

@if (

$this->transactionData['meta']['status'] === 'pending' &&
isset($this->transactionData['meta']['type']) &&
$this->transactionData['meta']['type'] === 'transaction' )
<x-filament-panels::form.actions :actions="$this->getApproveTransactionFormActions()" />
@endif
</x-filament-panels::form>
</x-filament-panels::page>
<x-filament-panels::page>
<x-filament-panels::form wire:submit="approveTransaction">
<div style="display: flex; gap: 20px; align-items: stretch">
<div class="flex-1">
{{ $this->approveTransactionForm }}
</div>
@if ($media = $this->getTransaction($this->record)->getFirstMedia('images'))
<div class="flex-1">
<img src="{{ $media->getUrl() }}" alt="Avatar" class="h-auto w-full object-cover" />
</div>
@endif
</div>

@if ($this->getTransaction($this->record)->getFirstMedia('images'))
<div class="mt-2">
{{ $this->confirmedTransactionForm }}
</div>
@endif

@if (

$this->transactionData['meta']['status'] === 'pending' &&
isset($this->transactionData['meta']['type']) &&
$this->transactionData['meta']['type'] === 'transaction' )
<x-filament-panels::form.actions :actions="$this->getApproveTransactionFormActions()" />
@endif
</x-filament-panels::form>
</x-filament-panels::page>
and
it('can accepte transaction from client', function () {
actingAs(loginNextJs(), 'api');
$response = postJson('/api/v1/user/deposit-bank-transfer', [
'amount' => 10,
'file' => $this->file,
'currency' => 'USD'
]);
$transaction = Transaction::latest()->first();
$transactionData = [
'meta' => [
'status' => 'confirmed'
],
];

$response = livewire(TransactionResource\Pages\EditTransaction::class, [
'record' => $transaction->getRouteKey()
])
->callAction('approveTransaction', [
'record' => $transaction->getRouteKey(),
'data' => [
'status' => 'confirmed'
]
])
->assertHasNoActionErrors();
});
it('can accepte transaction from client', function () {
actingAs(loginNextJs(), 'api');
$response = postJson('/api/v1/user/deposit-bank-transfer', [
'amount' => 10,
'file' => $this->file,
'currency' => 'USD'
]);
$transaction = Transaction::latest()->first();
$transactionData = [
'meta' => [
'status' => 'confirmed'
],
];

$response = livewire(TransactionResource\Pages\EditTransaction::class, [
'record' => $transaction->getRouteKey()
])
->callAction('approveTransaction', [
'record' => $transaction->getRouteKey(),
'data' => [
'status' => 'confirmed'
]
])
->assertHasNoActionErrors();
});
2 replies
FFilament
Created by Aminne on 10/5/2024 in #❓┊help
Question about unit testing in Filament
I would like to know why are the unit test resources so lacking? Are they too easy, or do people not work with them?
2 replies
FFilament
Created by Aminne on 9/21/2024 in #❓┊help
Add unit testing on ToggleColumn with using Pest
No description
2 replies
FFilament
Created by Aminne on 9/20/2024 in #❓┊help
Writing unit testing using shield plugin filament for role and permissions
How i can create a unit test for application has a filament plugin shield ?
11 replies
FFilament
Created by Aminne on 7/29/2024 in #❓┊help
How to avoid N+1 problem using eager laoding
I want to how i can avoid it.
2 replies
FFilament
Created by Aminne on 7/28/2024 in #❓┊help
How i can translate the validation error message
No description
18 replies
FFilament
Created by Aminne on 7/20/2024 in #❓┊help
Display language switcher in simple page like a login
No description
11 replies
FFilament
Created by Aminne on 7/15/2024 in #❓┊help
Show error field without closing modal in custom action
Actions\Action::make('disabledTwoFactor')->label('Enable Two-Factor Authentication')>requiresConfirmation()->modalSubmitActionLabel('Enable')
->form([
Forms\Components\TextInput::make('password')->password()
->revealable()
->required()])
->action(
function (array $data) { self::EnabledTwoFactor($data['password']);})->modalWidth('lg'),
Actions\Action::make('disabledTwoFactor')->label('Enable Two-Factor Authentication')>requiresConfirmation()->modalSubmitActionLabel('Enable')
->form([
Forms\Components\TextInput::make('password')->password()
->revealable()
->required()])
->action(
function (array $data) { self::EnabledTwoFactor($data['password']);})->modalWidth('lg'),
6 replies
FFilament
Created by Aminne on 6/23/2024 in #❓┊help
Problem on Phone Input
->searchable(),
PhoneInput::make('phone')
->required()
->defaultCountry('my')
->initialCountry('my')
->validationMessages([
'phone:MY' => 'The phone not number'
])
->validateFor(
country: 'MY',
// type: libPhoneNumberType::MOBILE | libPhoneNumberType::FIXED_LINE,
lenient: true,
),
->searchable(),
PhoneInput::make('phone')
->required()
->defaultCountry('my')
->initialCountry('my')
->validationMessages([
'phone:MY' => 'The phone not number'
])
->validateFor(
country: 'MY',
// type: libPhoneNumberType::MOBILE | libPhoneNumberType::FIXED_LINE,
lenient: true,
),
` I got the probelm on libPhoneNumberType not found
4 replies
FFilament
Created by Aminne on 6/23/2024 in #❓┊help
custom select componenet with phone code , and country emoji
Hello, in select componenet of filament i want to display all phone code , and country emoji, with input to enter the phone number , any recommendations to doing this ?
4 replies
FFilament
Created by Aminne on 6/22/2024 in #❓┊help
Custom validation message is not working
TextInput::make('amount')
->numeric()
->required()
->live(onBlur: true)
->validationMessages(['min:0' => 'Invalid balance'])
->minValue(0)
TextInput::make('amount')
->numeric()
->required()
->live(onBlur: true)
->validationMessages(['min:0' => 'Invalid balance'])
->minValue(0)
2 replies
FFilament
Created by Aminne on 6/21/2024 in #❓┊help
Bug in Select Form Component Toggle Disable Enable
I would like to know if this bug is resolved or not ?
7 replies
FFilament
Created by Aminne on 6/21/2024 in #❓┊help
Failed to disabled select before another select
Forms\Components\Select::make('from_id')
->relationship(name: 'from',
modifyQueryUsing: fn (Builder $query, Get $get) => $query->where('id', '!=', $get('to_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live()
->native(false),Forms\Components\Select::make('to_id')
->relationship(name: 'to',
modifyQueryUsing: fn (Builder $query, Get $get) => $query->where('id', '!=', $get('from_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->disabled(function(Get $get) {
return is_null($get('from_id'));
})
->live()
->preload()
->searchable()
->required()
->native(false)
Forms\Components\Select::make('from_id')
->relationship(name: 'from',
modifyQueryUsing: fn (Builder $query, Get $get) => $query->where('id', '!=', $get('to_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live()
->native(false),Forms\Components\Select::make('to_id')
->relationship(name: 'to',
modifyQueryUsing: fn (Builder $query, Get $get) => $query->where('id', '!=', $get('from_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->disabled(function(Get $get) {
return is_null($get('from_id'));
})
->live()
->preload()
->searchable()
->required()
->native(false)
Firstly to_id select is disabled before selected the from_id i have this code , The problem after select the from_id , to_id is disabled but i can't open the options ?
4 replies
FFilament
Created by Aminne on 6/21/2024 in #❓┊help
How i can disable submit button until form is fully validated filament
No description
3 replies
FFilament
Created by Aminne on 6/21/2024 in #❓┊help
How i can display the error message before submit
Forms\Components\Select::make('from_id')
->relationship(name: 'from',
modifyQueryUsing: fn (Builder $query, Get $get) => $query->where('id', '!=', $get('to_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live(onBlur: true)
->afterStateUpdated(function (Forms\Contracts\HasForms $livewire, Forms\Components\Select $component) {
$livewire->validateOnly($component->getStatePath());
})
->rules([
fn () => function (string $attribute, $value, Closure $fail) {
$wallet = Wallet::find($value);
if(intval($wallet->balance) === 0) {
$fail('The :attribute wallet is empty.');
}
},
]),
Forms\Components\Select::make('from_id')
->relationship(name: 'from',
modifyQueryUsing: fn (Builder $query, Get $get) => $query->where('id', '!=', $get('to_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live(onBlur: true)
->afterStateUpdated(function (Forms\Contracts\HasForms $livewire, Forms\Components\Select $component) {
$livewire->validateOnly($component->getStatePath());
})
->rules([
fn () => function (string $attribute, $value, Closure $fail) {
$wallet = Wallet::find($value);
if(intval($wallet->balance) === 0) {
$fail('The :attribute wallet is empty.');
}
},
]),
2 replies
FFilament
Created by Aminne on 6/21/2024 in #❓┊help
How i can custom failure form in custom action
This's my code
Actions\Action::make('newUser')
->action(function (array $data): void {`})->form(function(array data): void {})
Actions\Action::make('newUser')
->action(function (array $data): void {`})->form(function(array data): void {})
30 replies
FFilament
Created by Aminne on 6/20/2024 in #❓┊help
Add a event in user after creation
class CreateUser extends CreateRecord
{
protected static string $resource = UserResource::class;

protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('index');
}

protected function afterCreate(User $record)
{
$record->delete();
}
class CreateUser extends CreateRecord
{
protected static string $resource = UserResource::class;

protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('index');
}

protected function afterCreate(User $record)
{
$record->delete();
}
4 replies
FFilament
Created by Aminne on 6/19/2024 in #❓┊help
Remove the item selected in another select
I tried this but it deson't work
Group::make([
Forms\Components\Select::make('from_id')
->relationship('from', fn (Builder $query, Get $get) => $query->where('id', '!=', $get('to_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live(onBlur: true),
Forms\Components\Select::make('to_id')
->relationship('from', fn (Builder $query, Get $get) => $query->where('id', '!=', $get('from_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live(onBlur: true),
])->columns(2),
Group::make([
Forms\Components\Select::make('from_id')
->relationship('from', fn (Builder $query, Get $get) => $query->where('id', '!=', $get('to_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live(onBlur: true),
Forms\Components\Select::make('to_id')
->relationship('from', fn (Builder $query, Get $get) => $query->where('id', '!=', $get('from_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live(onBlur: true),
])->columns(2),
3 replies
FFilament
Created by Aminne on 6/14/2024 in #❓┊help
Adding where condition for filter in statsOverviewWidget
Tables\Filters\SelectFilter::make('category')
->relationship('categories', 'name')
->searchable()
->preload()
Tables\Filters\SelectFilter::make('category')
->relationship('categories', 'name')
->searchable()
->preload()
use InteractsWithPageTable;

protected function getTablePage(): string
{
return ListPosts::class;
}

protected function getStats(): array
{
return [
BaseWidget\Stat::make('Published Post', $this->getPageTableQuery()
->with('categories')
->whereRelation('category', 'title', '', '')
->where('status', 'published')
->count())
->description('All published posts')
->color('success'),
use InteractsWithPageTable;

protected function getTablePage(): string
{
return ListPosts::class;
}

protected function getStats(): array
{
return [
BaseWidget\Stat::make('Published Post', $this->getPageTableQuery()
->with('categories')
->whereRelation('category', 'title', '', '')
->where('status', 'published')
->count())
->description('All published posts')
->color('success'),
2 replies
FFilament
Created by Aminne on 6/11/2024 in #❓┊help
Tiptap-editor format stored
i stored the html format using this plugin, this the data obtened
{"ms_MY":"<p>malay</p>","en_US":{"type":"doc","content":[{"type":"paragraph","attrs":{"class":null,"style":null,"textAlign":"start"},"content":[{"type":"text","text":"content"}]}]}}
{"ms_MY":"<p>malay</p>","en_US":{"type":"doc","content":[{"type":"paragraph","attrs":{"class":null,"style":null,"textAlign":"start"},"content":[{"type":"text","text":"content"}]}]}}
5 replies