@nasilemak
@nasilemak
FFilament
Created by @nasilemak on 3/18/2024 in #❓┊help
How to modify the search results format in Filament's Select field?
That did the trick. Thanks!
8 replies
FFilament
Created by @nasilemak on 2/23/2024 in #❓┊help
How to override default inline styling?
this works nicely
7 replies
FFilament
Created by @nasilemak on 2/23/2024 in #❓┊help
How to override default inline styling?
Could you elaborate more on this? Here is my setup
@import '/vendor/filament/filament/resources/css/theme.css';

@config 'tailwind.config.js';

@layer components {
.fi-btn {
@apply bg-yellow-500;
}

.fi-header-heading {
@apply bg-red-500;
}

.fi-section-content {
@apply bg-green-500;
}
}
@import '/vendor/filament/filament/resources/css/theme.css';

@config 'tailwind.config.js';

@layer components {
.fi-btn {
@apply bg-yellow-500;
}

.fi-header-heading {
@apply bg-red-500;
}

.fi-section-content {
@apply bg-green-500;
}
}
in my panel provider
->viteTheme('resources/css/filament/seller/theme.css')
->viteTheme('resources/css/filament/seller/theme.css')
7 replies
FFilament
Created by @nasilemak on 2/22/2024 in #❓┊help
Method Filament\Panel::assets does not exist.
3 replies
FFilament
Created by @nasilemak on 2/17/2024 in #❓┊help
Customer-Facing Filament - Tailwind Classes Not Compiling
Indeed, I was missing these lines in my tailwind.config.js:
import preset from './vendor/filament/support/tailwind.config.preset'

module.exports = {
presets: [preset],
}
import preset from './vendor/filament/support/tailwind.config.preset'

module.exports = {
presets: [preset],
}
https://filamentphp.com/docs/3.x/actions/installation#installing-tailwind-css Thank you, Dan
6 replies
FFilament
Created by @nasilemak on 1/30/2024 in #❓┊help
How to replace default actions in the Create and Edit pages?
No description
12 replies
FFilament
Created by @nasilemak on 1/30/2024 in #❓┊help
How to replace default actions in the Create and Edit pages?
Yes that did the trick. Here's the updated code:
Actions\Action::make('publish')
->action(function ($record) {

$this->form->validate();
$record->update($this->form->getState());
$record->publish();
$record->save();

return redirect(PostResource::getUrl('index'));
})
Actions\Action::make('publish')
->action(function ($record) {

$this->form->validate();
$record->update($this->form->getState());
$record->publish();
$record->save();

return redirect(PostResource::getUrl('index'));
})
12 replies
FFilament
Created by @nasilemak on 1/30/2024 in #❓┊help
How to replace default actions in the Create and Edit pages?
This is what I have so far. It's kind of messy.
class EditPost extends EditRecord
{
protected static string $resource = PostResource::class;

protected function getHeaderActions(): array
{
return [
Actions\Action::make('publish')
->label('Publish')
->action(function ($record) {
$record->publish();
$record->save();

Notification::make()
->title('Article has been published')
->icon('heroicon-o-document-text')
->iconColor('success')
->send();

return redirect(PostResource::getUrl('index'));
})
->visible(fn ($record): bool => $record && !$record->isPublished()),
Actions\Action::make('unpublish')
->label('Unpublish')
->action(function ($record) {
$record->unpublish();
$record->save();

Notification::make()
->title('Article is now unpublished and hidden from readers')
->icon('heroicon-o-document-text')
->iconColor('success')
->send();

return redirect(PostResource::getUrl('index'));
})
->visible(fn ($record): bool => $record && $record->isPublished()),
Actions\DeleteAction::make(),
];
}
}
class EditPost extends EditRecord
{
protected static string $resource = PostResource::class;

protected function getHeaderActions(): array
{
return [
Actions\Action::make('publish')
->label('Publish')
->action(function ($record) {
$record->publish();
$record->save();

Notification::make()
->title('Article has been published')
->icon('heroicon-o-document-text')
->iconColor('success')
->send();

return redirect(PostResource::getUrl('index'));
})
->visible(fn ($record): bool => $record && !$record->isPublished()),
Actions\Action::make('unpublish')
->label('Unpublish')
->action(function ($record) {
$record->unpublish();
$record->save();

Notification::make()
->title('Article is now unpublished and hidden from readers')
->icon('heroicon-o-document-text')
->iconColor('success')
->send();

return redirect(PostResource::getUrl('index'));
})
->visible(fn ($record): bool => $record && $record->isPublished()),
Actions\DeleteAction::make(),
];
}
}
Also I want the 'Publish' action to validate and save the form data the same way 'Create' and 'Save Changes' would
12 replies
FFilament
Created by @nasilemak on 1/30/2024 in #❓┊help
How to replace default actions in the Create and Edit pages?
Isn't that for the list page/table? I'm referring to the Create and Edit pages
12 replies
FFilament
Created by @nasilemak on 1/24/2024 in #❓┊help
Can I pass in a filament resource's form into createOptionsForm()?
Yes, that did the trick! Nice and easy. Thank you. Here's the updated code:
Select::make('tags')
->multiple()
->relationship(titleAttribute: 'name')
->createOptionForm(fn(Form $form) => TagResource::form($form)),
Select::make('tags')
->multiple()
->relationship(titleAttribute: 'name')
->createOptionForm(fn(Form $form) => TagResource::form($form)),
7 replies
FFilament
Created by @nasilemak on 1/15/2024 in #❓┊help
How to display an enum's label rather than value in a TextColumn?
never mind, forgot to cast my enum in my Eloquent model. Sorted. Thanks
16 replies
FFilament
Created by @nasilemak on 1/15/2024 in #❓┊help
How to display an enum's label rather than value in a TextColumn?
Ok refactored my code to use an enum instead. Got it working in the Form. But what about in the Table in the TextColumn?
use App\Enums\Priority;

class CustomerResource extends Resource
{
public static function form(Form $form): Form
{
return $form
->schema([
Select::make('priority')
->options(Priority::class),
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('priority')
->badge(),
]);
}
}
use App\Enums\Priority;

class CustomerResource extends Resource
{
public static function form(Form $form): Form
{
return $form
->schema([
Select::make('priority')
->options(Priority::class),
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('priority')
->badge(),
]);
}
}
16 replies
FFilament
Created by @nasilemak on 1/15/2024 in #❓┊help
How to display an enum's label rather than value in a TextColumn?
Thanks again mate
16 replies
FFilament
Created by @nasilemak on 1/15/2024 in #❓┊help
How to display an enum's label rather than value in a TextColumn?
RTFM will be my epitaph 🪦 lol
16 replies
FFilament
Created by @nasilemak on 1/15/2024 in #❓┊help
How to display an enum's label rather than value in a TextColumn?
I hadn't realized Filament ships with a HasLabel interface! Been using my own HasLabel trait this whole time. Got to refactor a dozen projects now lol
16 replies
FFilament
Created by @nasilemak on 1/15/2024 in #❓┊help
How to display an enum's label rather than value in a TextColumn?
I'm starting to use Enums less and less lately. I haven't found a straight forward way of fetching labels or a random item when working with Enums without defining Traits.
<?php

namespace App\Enums;

enum Priority: integer
{
case LOW = 1;
case MEDIUM = 2;
case HIGH = 3;
}
<?php

namespace App\Enums;

enum Priority: integer
{
case LOW = 1;
case MEDIUM = 2;
case HIGH = 3;
}
16 replies
FFilament
Created by @nasilemak on 1/15/2024 in #❓┊help
How to display an enum's label rather than value in a TextColumn?
Found the solution. ->formatStateUsing()
16 replies
FFilament
Created by @nasilemak on 1/10/2024 in #❓┊help
How to enable/disable field when another field is null/filled
That did the trick! Cheers!
5 replies
FFilament
Created by @nasilemak on 1/10/2024 in #❓┊help
How to properly set up Filament when building a customer-facing app using TALL Stack preset
Issue solved. I had to include ./vendor/filament/**/*.blade.php in the content array.
module.exports = {
content: [
'./vendor/filament/**/*.blade.php',
],
}
module.exports = {
content: [
'./vendor/filament/**/*.blade.php',
],
}
4 replies
FFilament
Created by @nasilemak on 12/26/2023 in #❓┊help
Upload multiple images to a model
Thanks Tim. I refactored my code to simply add an images json column to my projects table. That did the trick. 👌
5 replies