KingStalker
KingStalker
FFilament
Created by KingStalker on 6/30/2024 in #❓┊help
Help Needed with Testing Tabs in Using Pest
No description
1 replies
FFilament
Created by KingStalker on 6/18/2024 in #❓┊help
Help with table action test
public function test_table_actions()
{
$user = User::factory()->create();

Livewire::test(ListUsers::class)
->callTableAction(DeleteAction::class, $user)
->assertHasNoTableActionErrors();

$this->assertSoftDeleted('users', ['id' => $user->id]);

$user2 = User::factory()->create();

Livewire::test(ListUsers::class)
->assertTableActionHasUrl('view', UserResource::getUrl('view', ['record' => $user2]))
->assertTableActionHasUrl('edit', UserResource::getUrl('edit', ['record' => $user2]));

}
public function test_table_actions()
{
$user = User::factory()->create();

Livewire::test(ListUsers::class)
->callTableAction(DeleteAction::class, $user)
->assertHasNoTableActionErrors();

$this->assertSoftDeleted('users', ['id' => $user->id]);

$user2 = User::factory()->create();

Livewire::test(ListUsers::class)
->assertTableActionHasUrl('view', UserResource::getUrl('view', ['record' => $user2]))
->assertTableActionHasUrl('edit', UserResource::getUrl('edit', ['record' => $user2]));

}
FAILED Tests\Feature\Software\Resources\UserResource\ListUsersTest > table actions TypeError Filament\Resources\Pages\ListRecords::Filament\Resources\Pages{closure}(): Argument #1 ($record) must be of type Illuminate\Database\Eloquent\Model, null given, called in D:\Work\laragon\www\myapp\vendor\filament\support\src\Concerns\EvaluatesClosures.php on line 35
$user2 = User::factory()->create();

Livewire::test(ListUsers::class)
->assertTableActionHasUrl('view', UserResource::getUrl('view', ['record' => $user2]))
->assertTableActionHasUrl('edit', UserResource::getUrl('edit', ['record' => $user2]));
$user2 = User::factory()->create();

Livewire::test(ListUsers::class)
->assertTableActionHasUrl('view', UserResource::getUrl('view', ['record' => $user2]))
->assertTableActionHasUrl('edit', UserResource::getUrl('edit', ['record' => $user2]));
the test fails here i'm not sure why can someone maybe help me
dd($user2);

//result
App\Models\Software\User {#5115
#attributes: array:8 [
"name" => "Pietro Hand"
"email" => "[email protected]"
"email_verified_at" => "2024-06-18 19:55:40"
"password" => "$2y$04$2xYahuL1RFq8aI2IPZuuJ.hXNWr5B.p5DX/TDM0OQJsv1CVs4L7FO"
"remember_token" => "uLr3LbCKDe"
"updated_at" => "2024-06-18 19:55:40"
"created_at" => "2024-06-18 19:55:40"
"id" => 2
]
dd($user2);

//result
App\Models\Software\User {#5115
#attributes: array:8 [
"name" => "Pietro Hand"
"email" => "[email protected]"
"email_verified_at" => "2024-06-18 19:55:40"
"password" => "$2y$04$2xYahuL1RFq8aI2IPZuuJ.hXNWr5B.p5DX/TDM0OQJsv1CVs4L7FO"
"remember_token" => "uLr3LbCKDe"
"updated_at" => "2024-06-18 19:55:40"
"created_at" => "2024-06-18 19:55:40"
"id" => 2
]
12 replies
FFilament
Created by KingStalker on 6/16/2024 in #❓┊help
Github Action Test Failing with brand logo on
ViewException
View [software.settings.logo] not found. (View: /home/runner/work/myapp/myapp/vendor/filament/filament/resources/views/components/logo.blade.php) (View: /home/runner/work/myapp/myapp/vendor/filament/filament/resources/views/components/logo.blade.php) this is the error im getting in github , all my test pass if in my local enviroment and when i remove this line in my panel all test passes in github action
->brandLogo(fn () => view('software.settings.logo'))
->brandLogo(fn () => view('software.settings.logo'))
the view is there cause its working please help
5 replies
FFilament
Created by KingStalker on 5/2/2024 in #❓┊help
widget doesin't update when i use the filter on a table help please
<?php

namespace App\Filament\Resources\OrderResource\Widgets;

use App\Enums\OrderStatus;
use App\Filament\Resources\OrderResource;
use Filament\Widgets\Concerns\InteractsWithPageTable;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;

class OrderStats extends BaseWidget
{
use InteractsWithPageTable;

protected function getStats(): array
{
$orders = OrderResource::getEloquentQuery();

$allOrdersCount = $orders->count();

$paidOrdersCount = OrderResource::getEloquentQuery()->where('status', OrderStatus::Paid->value)->count();

$holdOrdersCount = OrderResource::getEloquentQuery()->where('status', OrderStatus::Hold->value)->count();

return [
Stat::make('Orders', $allOrdersCount),
Stat::make('Paid Orders', $paidOrdersCount),
Stat::make('Hold Orders', $holdOrdersCount),
];
}
}

OrderResource::class

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;

public static function getWidgets(): array
{
return [
OrderStats::class,
];
}

public static function table(Table $table): Table
{
->filters([
DateRangeFilter::make('created_at')->label("Date")->defaultToday(),
],layout: FiltersLayout::AboveContent)
}
<?php

namespace App\Filament\Resources\OrderResource\Widgets;

use App\Enums\OrderStatus;
use App\Filament\Resources\OrderResource;
use Filament\Widgets\Concerns\InteractsWithPageTable;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;

class OrderStats extends BaseWidget
{
use InteractsWithPageTable;

protected function getStats(): array
{
$orders = OrderResource::getEloquentQuery();

$allOrdersCount = $orders->count();

$paidOrdersCount = OrderResource::getEloquentQuery()->where('status', OrderStatus::Paid->value)->count();

$holdOrdersCount = OrderResource::getEloquentQuery()->where('status', OrderStatus::Hold->value)->count();

return [
Stat::make('Orders', $allOrdersCount),
Stat::make('Paid Orders', $paidOrdersCount),
Stat::make('Hold Orders', $holdOrdersCount),
];
}
}

OrderResource::class

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;

public static function getWidgets(): array
{
return [
OrderStats::class,
];
}

public static function table(Table $table): Table
{
->filters([
DateRangeFilter::make('created_at')->label("Date")->defaultToday(),
],layout: FiltersLayout::AboveContent)
}
3 replies