Bezhan
Bezhan
FFilament
Created by Prodex on 10/8/2024 in #❓┊help
Weird override behavior
The reason some method overrides work while others don’t is due to how they are scoped and utilized. For example, model label and model plural label overrides do not work because you’re only overriding the RoleResource. To make those overrides work, you also need to extend the ListRoles page of the resource and bind your custom implementation in a service provider, just like you did with the resource. The same applies to sub-navigation. To get sub-navigation working, you need to extend both the EditRole and ViewRole pages of the RoleResource with your custom implementation of those pages. Once you’ve done that, bind them in a service provider. Then, within your custom RoleResource (ShieldOverrideResource) implementation, override the getPages() method to provide your implementation for those pages, and implement getRecordSubNavigation() accordingly.
3 replies
FFilament
Created by JJSanders on 1/20/2024 in #❓┊help
Question about testing my OrderForm
24 replies
FFilament
Created by JJSanders on 1/20/2024 in #❓┊help
Question about testing my OrderForm
for more, test cases and ref, checkout the filament codebase itself.
24 replies
FFilament
Created by JJSanders on 1/20/2024 in #❓┊help
Question about testing my OrderForm
or use the setUp() method.
24 replies
FFilament
Created by JJSanders on 1/20/2024 in #❓┊help
Question about testing my OrderForm
np, cheers!
24 replies
FFilament
Created by JJSanders on 1/20/2024 in #❓┊help
Question about testing my OrderForm
you didn't login()
it('Can only select suppliers related to the brand', function () {
login();

$brand = Brand::factory()->create();
$suppliers = Supplier::factory()
->count(2)
->hasAttached($brand)
->create();
$this->get(OrderResource::getUrl('create'));
livewire(CreateOrder::class)
->fillForm([
'brand_id' => $brand->id,
])->assertFormSet(['supplier_id' => $suppliers->pluck('id')->toArray()]);
});
it('Can only select suppliers related to the brand', function () {
login();

$brand = Brand::factory()->create();
$suppliers = Supplier::factory()
->count(2)
->hasAttached($brand)
->create();
$this->get(OrderResource::getUrl('create'));
livewire(CreateOrder::class)
->fillForm([
'brand_id' => $brand->id,
])->assertFormSet(['supplier_id' => $suppliers->pluck('id')->toArray()]);
});
24 replies
FFilament
Created by JJSanders on 1/20/2024 in #❓┊help
Question about testing my OrderForm
since you are not setting the supplier_id and then asserting that it's set.
24 replies
FFilament
Created by JJSanders on 1/20/2024 in #❓┊help
Question about testing my OrderForm
and what is the result? it should say something like failed asserting that null matches expected ??
24 replies
FFilament
Created by JJSanders on 1/20/2024 in #❓┊help
Question about testing my OrderForm
no, import the CreateOrder class in your test like use App\Filament\Resources\OrderResource\Pages\CreateOrder;
24 replies
FFilament
Created by JJSanders on 1/20/2024 in #❓┊help
Question about testing my OrderForm
could you import the CreateOrder page and try?
24 replies
FFilament
Created by JJSanders on 1/20/2024 in #❓┊help
Question about testing my OrderForm
can i see your test file?
24 replies
FFilament
Created by JJSanders on 1/20/2024 in #❓┊help
Question about testing my OrderForm
add $this->get(OrderResource::getUrl('create')); before livewire(CreateOrder::class) ...
$this->get(OrderResource::getUrl('create'));

livewire(CreateOrder::class)
->fillForm([
'brand_id' => $brand->id,
])->assertFormSet(['supplier_id' => $suppliers->pluck('id')->toArray()]);
$this->get(OrderResource::getUrl('create'));

livewire(CreateOrder::class)
->fillForm([
'brand_id' => $brand->id,
])->assertFormSet(['supplier_id' => $suppliers->pluck('id')->toArray()]);
24 replies
FFilament
Created by ericmp #2 on 11/13/2023 in #❓┊help
Image previews not showing up
have you given or applied the directory permissions for storage and given access to www-data group for nginx or whatever the nginx group is?
7 replies
FFilament
Created by Geoff. on 10/27/2023 in #❓┊help
multitenacy combined with tenancyforlaravel and filament shield permission problem
Glad it could help, just mark it as solved if that was all you needed. 🍻
14 replies
FFilament
Created by Geoff. on 10/27/2023 in #❓┊help
multitenacy combined with tenancyforlaravel and filament shield permission problem
1. To disable cache in dev mode set the CACHE_DRIVER=array in .env file or set the cache store to array from permission config file. learn more https://spatie.be/docs/laravel-permission/v5/advanced-usage/cache 2. since you are using that package you need to add the following in TenancyServiceProvider
Events\TenancyBootstrapped::class => [
function (Events\TenancyBootstrapped $event) {
\Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache.tenant.' . $event->tenancy->tenant->id;
}
],

Events\TenancyEnded::class => [
function (Events\TenancyEnded $event) {
\Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache';
}
],
Events\TenancyBootstrapped::class => [
function (Events\TenancyBootstrapped $event) {
\Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache.tenant.' . $event->tenancy->tenant->id;
}
],

Events\TenancyEnded::class => [
function (Events\TenancyEnded $event) {
\Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache';
}
],
learn more https://tenancyforlaravel.com/docs/v3/integrations/spatie
14 replies
FFilament
Created by vahnmarty on 7/16/2023 in #❓┊help
How to close datepicker once the user clicks a date?
Forms\Components\DatePicker::make('until')
->placeholder('select start date')
->format('Y-m-d')
->maxDate(now()->addDay())
->closeOnDateSelection()
Forms\Components\DatePicker::make('until')
->placeholder('select start date')
->format('Y-m-d')
->maxDate(now()->addDay())
->closeOnDateSelection()
5 replies
FFilament
Created by vahnmarty on 7/16/2023 in #❓┊help
How to close datepicker once the user clicks a date?
use the closeOnDateSelection() method.
5 replies
FFilament
Created by ahloudev on 3/14/2023 in #❓┊help
How to add loading indicator at the top of the filamentphp app page
What he said 👆
21 replies
FFilament
Created by eazy on 3/10/2023 in #❓┊help
Dynamic text input value
here you go... just adjust how you wanna manipulate it. don't try... just move on to the next thing 🖖
Forms\Components\TextInput::make('year')
->label(__('Year'))
->numeric()
->reactive()
->afterStateUpdated(function (callable $set, callable $get, $state) {
if (filled($name = $get('name'))) {
$set('code', str($state)->append('_')->append($name));
} else {
$set('code', $state);
}
})
->required(),
Forms\Components\TextInput::make('name')
->label(__('Name'))
->reactive()
->afterStateUpdated(function (callable $set, callable $get, $state) {
if (filled($year = $get('year'))) {
$set('code', str($year)->append('_')->append($state));
} else {
$set('code', $state);
}
})
->required(),
Forms\Components\TextInput::make('code')
->disabled()
]);
Forms\Components\TextInput::make('year')
->label(__('Year'))
->numeric()
->reactive()
->afterStateUpdated(function (callable $set, callable $get, $state) {
if (filled($name = $get('name'))) {
$set('code', str($state)->append('_')->append($name));
} else {
$set('code', $state);
}
})
->required(),
Forms\Components\TextInput::make('name')
->label(__('Name'))
->reactive()
->afterStateUpdated(function (callable $set, callable $get, $state) {
if (filled($year = $get('year'))) {
$set('code', str($year)->append('_')->append($state));
} else {
$set('code', $state);
}
})
->required(),
Forms\Components\TextInput::make('code')
->disabled()
]);
7 replies
FFilament
Created by eazy on 3/10/2023 in #❓┊help
Dynamic text input value
dude your doing it in reverse.. it should be afterStateUpdate() but you need to change the state from year and/or name to trigger the state change. fields can't listen to other fields' state changes only there own but you can change a field's state from another field.
7 replies