Falk Maria Zeitsprung
Falk Maria Zeitsprung
FFilament
Created by Falk Maria Zeitsprung on 12/3/2023 in #❓┊help
where configure the redirect url when user logs out admin panel?
where configure the redirect url when user logs out admin panel?
8 replies
FFilament
Created by Falk Maria Zeitsprung on 10/24/2023 in #❓┊help
unique email with deleted_at
How can i exclude records, which are marked as deleted from the email validation unique? I also need this function:
TextInput::make('email')
->email()
->required()
->unique(ignoreRecord: true)
->label(__('Email'))
->email(),
TextInput::make('email')
->email()
->required()
->unique(ignoreRecord: true)
->label(__('Email'))
->email(),
and i want to inlcude additional something like this:
->unique(modifyRuleUsing: function (Unique $rule) {
return $rule->whereNot('is_deleted', NULL);
->unique(modifyRuleUsing: function (Unique $rule) {
return $rule->whereNot('is_deleted', NULL);
how would look all together please?
9 replies
FFilament
Created by Falk Maria Zeitsprung on 10/24/2023 in #❓┊help
can i group headeractions in getHeaderActions?
can i group headeractions in getHeaderActions?
5 replies
FFilament
Created by Falk Maria Zeitsprung on 9/28/2023 in #❓┊help
Repeater shows up collapsed - why?
No description
7 replies
FFilament
Created by Falk Maria Zeitsprung on 8/1/2023 in #❓┊help
update actions on filter change
How can i update an action, when a filter is changed? I have an action, which is showing in a table column. The action shows labels with links, depending on the selection in the form of the filter. My problem is, that if i change the filter, the actions are not updated. I have to make a cmd-r reload of the page, to force a new calculation of the action label. How can i resolve this please?
11 replies
FFilament
Created by Falk Maria Zeitsprung on 7/17/2023 in #❓┊help
selectfilter from json data
I have a database filed where i have saved something like this:
[{"language":"german","language_level":"Native language"},{"language":"english","language_level":"Fluent \/ Fluent business"},{"language":"spanish","language_level":"Fluent \/ Fluent business"}]
[{"language":"german","language_level":"Native language"},{"language":"english","language_level":"Fluent \/ Fluent business"},{"language":"spanish","language_level":"Fluent \/ Fluent business"}]
Cane be one o n lines. Now i need a SelectFilter where i can choose a language. And language_level (or language_level) withou selection. I try:
SelectFilter::make('languages')
->options(['english' => 'Englisch', 'spanish' => 'Spanisch', 'french' => 'Französisch'])
->query(fn(Builder $query, $value): Builder => $query->whereJsonContains('languages')),
SelectFilter::make('languages')
->options(['english' => 'Englisch', 'spanish' => 'Spanisch', 'french' => 'Französisch'])
->query(fn(Builder $query, $value): Builder => $query->whereJsonContains('languages')),
` but get error: Unable to resolve dependency [Parameter #1 [ <required> $value ]] in class App\Filament\Resources\ApplicantResource
33 replies
FFilament
Created by Falk Maria Zeitsprung on 7/13/2023 in #❓┊help
menu item background color changing
18 replies
FFilament
Created by Falk Maria Zeitsprung on 7/4/2023 in #❓┊help
Displaying filters above or below the table content
I cant get to work this. In my CenterResource.php i add the methos:
protected function getTableFiltersLayout(): ?string
{
return Layout::BelowContent;
}
protected function getTableFiltersLayout(): ?string
{
return Layout::BelowContent;
}
i also added:
use Filament\Tables\Filters\Layout;
use Filament\Tables\Filters\Layout;
` But the method is not being called. It shows in PHPStorm as unused element. From where do i have to call the method please?
5 replies
FFilament
Created by Falk Maria Zeitsprung on 7/3/2023 in #❓┊help
How to show table underneath select form fields.
5 replies
FFilament
Created by Falk Maria Zeitsprung on 7/2/2023 in #❓┊help
Relation Manager: Create with Modal. How to define default values for form fields?
How and where to put my predefined values?
$this->form->fill([
'start_date' => now()->format('Y-m-d'),
'frequency' => 'WEEKLY',
'weekdays' => ['WE', 'FR'],
'start_time' => '10:00',
'count' => 100,
'slots_available' => 1,
'duration_unit' => 'M',
'duration_value' => 90,
]);
$this->form->fill([
'start_date' => now()->format('Y-m-d'),
'frequency' => 'WEEKLY',
'weekdays' => ['WE', 'FR'],
'start_time' => '10:00',
'count' => 100,
'slots_available' => 1,
'duration_unit' => 'M',
'duration_value' => 90,
]);
I tried
CreateAction::make()
->beforeFormFilled(function () {
// Runs before the form fields are populated with their default values.
})
CreateAction::make()
->beforeFormFilled(function () {
// Runs before the form fields are populated with their default values.
})
But cant get it to work. In EditAction it works perfectly with:
EditAction::make()
//Antes de llenar el formulario, adaptar/mutar los datos.
->mutateRecordDataUsing(function (array $data): array {
return FormMutatorHelper::mutateBeforeAvailabilityFormData($data);
})
//Antes de guardar, adaptar/mutar los datos.
->mutateFormDataUsing(function (array $data): array {
return FormMutatorHelper::mutateAvailabilityFormData($data);
}),
EditAction::make()
//Antes de llenar el formulario, adaptar/mutar los datos.
->mutateRecordDataUsing(function (array $data): array {
return FormMutatorHelper::mutateBeforeAvailabilityFormData($data);
})
//Antes de guardar, adaptar/mutar los datos.
->mutateFormDataUsing(function (array $data): array {
return FormMutatorHelper::mutateAvailabilityFormData($data);
}),
`
3 replies
FFilament
Created by Falk Maria Zeitsprung on 6/23/2023 in #❓┊help
can i create a form in app/Filament/Pages/CreateModelname.php?
A form which i use only to create a record? i tried:
<?php

namespace App\Filament\Resources\AvailabilityResource\Pages;

use App\Filament\Resources\AvailabilityResource;
use Filament\Resources\Pages\CreateRecord;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\DateTimePicker;
use App\Models\ReservableItem;

class CreateAvailability extends CreateRecord
{
public static $resource = AvailabilityResource::class;

public function form()
{
return parent::form()->schema([
Select::make('reservable_item_id')
->label('Reservable Item')
->options(
ReservableItem::all()->pluck('id', 'name')->toArray()
)
->placeholder('Select an Item'),
DateTimePicker::make('start_time')
->label('Start Time')
->withTimezone()
->required(),
// add other fields as necessary
]);
}
}
<?php

namespace App\Filament\Resources\AvailabilityResource\Pages;

use App\Filament\Resources\AvailabilityResource;
use Filament\Resources\Pages\CreateRecord;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\DateTimePicker;
use App\Models\ReservableItem;

class CreateAvailability extends CreateRecord
{
public static $resource = AvailabilityResource::class;

public function form()
{
return parent::form()->schema([
Select::make('reservable_item_id')
->label('Reservable Item')
->options(
ReservableItem::all()->pluck('id', 'name')->toArray()
)
->placeholder('Select an Item'),
DateTimePicker::make('start_time')
->label('Start Time')
->withTimezone()
->required(),
// add other fields as necessary
]);
}
}
but does not work.
3 replies
FFilament
Created by Falk Maria Zeitsprung on 6/20/2023 in #❓┊help
RichEditor align text right, center?
Is it possible to set a button for text paragraph align center or right in the rich text editor? Or how to align a paragraph text centered or right please?
3 replies
FFilament
Created by Falk Maria Zeitsprung on 6/12/2023 in #❓┊help
show filter only if role is "Admin"
I am using Spatie permissioni package. How to resolve this please?
4 replies
FFilament
Created by Falk Maria Zeitsprung on 6/12/2023 in #❓┊help
How to add a form field only in CREATE and NOT in EDIT?
f.e. for a user.
2 replies
FFilament
Created by Falk Maria Zeitsprung on 6/5/2023 in #❓┊help
menu item depending on user role or permission
How can i set a menu item only, if the user has a specific role? I tried https://filamentphp.com/tricks/conditions-on-user-menu-items-based-on-roles But cant get it running. I installed in config/filament.php
'auth' => [
Authenticate::class,
UserMenuItemMiddleware::class,
'auth' => [
Authenticate::class,
UserMenuItemMiddleware::class,
` I created
php artisan make:middleware UserMenuItemMiddleware
php artisan make:middleware UserMenuItemMiddleware
public function handle(Request $request, Closure $next): Response
{
if (Auth::user()->hasRole('Root')) {

Filament::serving(function () {

Filament::registerUserMenuItems([
'GitLog' => UserMenuItem::make()
->label('Git Log')
->url(route('filament.pages.settings'))
->icon('heroicon-s-cog'),

]);
});
}
public function handle(Request $request, Closure $next): Response
{
if (Auth::user()->hasRole('Root')) {

Filament::serving(function () {

Filament::registerUserMenuItems([
'GitLog' => UserMenuItem::make()
->label('Git Log')
->url(route('filament.pages.settings'))
->icon('heroicon-s-cog'),

]);
});
}
I have a Page in app/Filament/Pages/GitLog.php with
class GitLog extends Page
{
protected static ?string $title = 'Git Log';
protected static ?string $navigationLabel = 'Git Log';
protected static ?string $navigationIcon = 'heroicon-o-document-text';
//protected static ?string $navigationGroup = 'Settings';
//protected static ?string $navigationIcon = 'heroicon-o-beaker';
protected static string $view = 'filament.pages.git-log';
protected static ?int $navigationSort = 4;

public $content;

public function mount(): void
{
//abort_unless(auth()->user()->hasRole(['Root', 'Admin']), 403);
abort_unless(auth()->user()->hasRole(['Root']), 403);
$this->content = file_get_contents(base_path('git-log.txt'));

}

}
class GitLog extends Page
{
protected static ?string $title = 'Git Log';
protected static ?string $navigationLabel = 'Git Log';
protected static ?string $navigationIcon = 'heroicon-o-document-text';
//protected static ?string $navigationGroup = 'Settings';
//protected static ?string $navigationIcon = 'heroicon-o-beaker';
protected static string $view = 'filament.pages.git-log';
protected static ?int $navigationSort = 4;

public $content;

public function mount(): void
{
//abort_unless(auth()->user()->hasRole(['Root', 'Admin']), 403);
abort_unless(auth()->user()->hasRole(['Root']), 403);
$this->content = file_get_contents(base_path('git-log.txt'));

}

}
What to i have to put in app/Http/Middleware/UserMenuItemMiddleware.php please? I want to show the page GitLog.php only when the user has role "Root".
13 replies
FFilament
Created by Falk Maria Zeitsprung on 6/5/2023 in #❓┊help
in which file to put Filament::pushMeta
i want to insert
Filament::pushMeta([new HtmlString('<meta name="robots" content="noindex, nofollow">'),]);
Filament::pushMeta([new HtmlString('<meta name="robots" content="noindex, nofollow">'),]);
` In which file please is best?
4 replies
FFilament
Created by Falk Maria Zeitsprung on 6/2/2023 in #❓┊help
How to asign to a hidden form field a role?
i tried:
Hidden::make('roles')
->relationship('roles', 'name')
->saveRelationshipsWhenHidden()
->default('User'),
Hidden::make('roles')
->relationship('roles', 'name')
->saveRelationshipsWhenHidden()
->default('User'),
` but doesnt work.
5 replies
FFilament
Created by Falk Maria Zeitsprung on 6/2/2023 in #❓┊help
how to show roles in user table
i use the spatie permission package.
3 replies
FFilament
Created by Falk Maria Zeitsprung on 5/30/2023 in #❓┊help
How to get several actions in the table in a dropdown? (Using the Admin Panel)
How to get several actions in the table in a dropdown? I have:
->actions([
Tables\Actions\Action::make('pdf1')
->label('Candidato')
->tooltip('PDF contiene nombre, apellidos y email.')
//->url('/pdf/60/0'),
//->color('success')
->url(function (Applicant $record) {
return '/'.App::getLocale().'/pdf/' . $record->id . '/1/0';
})
->icon('heroicon-o-document'),

Tables\Actions\Action::make('pdf2')
->label('SCG cliente')
->tooltip('PDF no contiene datos privados.')
//->url('/pdf/60/0'),
//->color('success')
->url(function (Applicant $record) {
return '/'.App::getLocale().'/pdf/' . $record->id . '/2/0';
})
->icon('heroicon-o-document'),

]);
->actions([
Tables\Actions\Action::make('pdf1')
->label('Candidato')
->tooltip('PDF contiene nombre, apellidos y email.')
//->url('/pdf/60/0'),
//->color('success')
->url(function (Applicant $record) {
return '/'.App::getLocale().'/pdf/' . $record->id . '/1/0';
})
->icon('heroicon-o-document'),

Tables\Actions\Action::make('pdf2')
->label('SCG cliente')
->tooltip('PDF no contiene datos privados.')
//->url('/pdf/60/0'),
//->color('success')
->url(function (Applicant $record) {
return '/'.App::getLocale().'/pdf/' . $record->id . '/2/0';
})
->icon('heroicon-o-document'),

]);
` How can i get this in a dropdown in each table row please?
3 replies
FFilament
Created by Falk Maria Zeitsprung on 5/26/2023 in #❓┊help
how to hide a form field conditionally?
I have two Radio Buttons. And want to hide the Select field candidato if no a special radio option is clicked.
Select::make('puesto')
->searchable()
->label( __('Oferta'))
->options(JobOffer::all()
->where('job_offer_open', true)
->sortBy('title')
->pluck('title', 'id'))
->required(),

Radio::make('comparison_type')
->label( __('Tipo de comparación'))
->options([
'1with1' => __('1 Oferta con 1 Candidato'),
'1withAll' => __('1 Oferta con todos los Candidatos'),
])
->default('1withAll')
->required()
->inline(),

Components\ConditionalSelect::make('candidato')
->searchable()
->label( __('Candidato (solamente activos)'))
->options(Applicant::all()
->where('is_active', true)
->sortBy('full_name')
->pluck('full_name', 'id'))
->dependsOn('comparison_type', '1with1')
->required(),
Select::make('puesto')
->searchable()
->label( __('Oferta'))
->options(JobOffer::all()
->where('job_offer_open', true)
->sortBy('title')
->pluck('title', 'id'))
->required(),

Radio::make('comparison_type')
->label( __('Tipo de comparación'))
->options([
'1with1' => __('1 Oferta con 1 Candidato'),
'1withAll' => __('1 Oferta con todos los Candidatos'),
])
->default('1withAll')
->required()
->inline(),

Components\ConditionalSelect::make('candidato')
->searchable()
->label( __('Candidato (solamente activos)'))
->options(Applicant::all()
->where('is_active', true)
->sortBy('full_name')
->pluck('full_name', 'id'))
->dependsOn('comparison_type', '1with1')
->required(),
3 replies