Sidem
Sidem
FFilament
Created by Sidem on 6/10/2024 in #❓┊help
select didn't return id
No description
18 replies
FFilament
Created by Sidem on 5/17/2024 in #❓┊help
retrieve information from a View in the form
Hi, in my filament form, I display a view: View::make('forms.components.createProduct') In this view I have a <form> and <inputs> which each have a different name and I would like to know if you have an idea of ​​how to retrieve the information from these inputs in my model with the create() function i try :
public static function create($data){
$request = new Request;
$quantity = $request->input('products_quantity_1');
dd($quantity);

//dd($request) is empty
public static function create($data){
$request = new Request;
$quantity = $request->input('products_quantity_1');
dd($quantity);

//dd($request) is empty
thanks 🙂
2 replies
FFilament
Created by Sidem on 5/15/2024 in #❓┊help
Select does not record the data
Hi, I am currently creating a Wizard. My problem is that when I select a piece of data inside the select and I click on the next step of my Wizard, the select returns me an error telling me that no data has been selected. Do you have an idea ? Here is my code :
Select::make('type_projet')
->multiple()
->relationship('type_projet', 'name')
->searchable()
->preload()
->required()
->default([157])
->columnSpan(2),
Select::make('type_projet')
->multiple()
->relationship('type_projet', 'name')
->searchable()
->preload()
->required()
->default([157])
->columnSpan(2),
7 replies
FFilament
Created by Sidem on 5/15/2024 in #❓┊help
align input
No description
4 replies
FFilament
Created by Sidem on 5/15/2024 in #❓┊help
wizard with many steps
No description
6 replies
FFilament
Created by Sidem on 5/10/2024 in #❓┊help
update defaultItems repeater with an other fields
Hi everyone, I need that when changing the value of a field, I can create a logic to dynamically generate several Repeater items at once, to make it easier for the user
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('numbers_of_product')
->numeric()
->minValue(1)
->live(),
Repeater::make('products')
->schema([
TextInput::make('name')
->required()
->columnSpan(2),
])
->grid(2)
->addable(false)
->deletable(false)
->defaultItems(fn (Get $get) => $get('numbers_of_product')),
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('numbers_of_product')
->numeric()
->minValue(1)
->live(),
Repeater::make('products')
->schema([
TextInput::make('name')
->required()
->columnSpan(2),
])
->grid(2)
->addable(false)
->deletable(false)
->defaultItems(fn (Get $get) => $get('numbers_of_product')),
]);
}
the problem is that when i update the TextInput, the repeater defaultItems dosen't update too. Have you any idee ? Thanks !
3 replies
FFilament
Created by Sidem on 4/4/2024 in #❓┊help
diplay columnspan
Hi, I would like to put my filter in 1 line but i don't know how i have to do that :
Filter::make('created_at')
->form([
Forms\Components\DatePicker::make('created_from')->label('Créé depuis')->columnspan(1),
Forms\Components\DatePicker::make('created_until')->label('Créé jusqu\'à')->columnspan(1),
])
->query(function (Builder $query, array $data): Builder {
if (isset($data['created_from'])) {
$query->when(
$data['created_from'],
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '>=', $date),
);
}

if (isset($data['created_until'])) {
$query->when(
$data['created_until'],
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '<=', $date),
);
}

return $query;
})
->default()
->columnspan(1),
Filter::make('created_at')
->form([
Forms\Components\DatePicker::make('created_from')->label('Créé depuis')->columnspan(1),
Forms\Components\DatePicker::make('created_until')->label('Créé jusqu\'à')->columnspan(1),
])
->query(function (Builder $query, array $data): Builder {
if (isset($data['created_from'])) {
$query->when(
$data['created_from'],
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '>=', $date),
);
}

if (isset($data['created_until'])) {
$query->when(
$data['created_until'],
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '<=', $date),
);
}

return $query;
})
->default()
->columnspan(1),
4 replies
FFilament
Created by Sidem on 3/20/2024 in #❓┊help
print function value
HI, the solution is probably very stupid but I haven't found it, but I would like to display the result of a function of a model in a column. The function is in my User model and returns a number that the column should display (so each row will have a different number in the column because it launches the function for a different user each time)
6 replies
FFilament
Created by Sidem on 3/20/2024 in #❓┊help
Load page with filter
Hi I would like to know if there is a method to load a filament page with a filter defined according to the link where you click: On a page that lists missions, I need to redirect the user to a list of requests related to the mission they clicked on. If you have an idea, I won't say no, thank you
25 replies
FFilament
Created by Sidem on 12/13/2023 in #❓┊help
change background color
Hi I would like change the background color of each line of my table. That's my code : App\Enums\DemandeStatutEnums.php :
...
public static function getColorStatut(int $chiffre_statut = null) {
$classes = [
self::CREE => 'bg-red-100 dark:bg-red-800', // Rouge
self::A_TRAITER => 'bg-green-100 dark:bg-green-800', // Vert
self::VALIDE => 'bg-blue-100 dark:bg-blue-800', // Bleu
self::REJECTED => 'bg-yellow-100 dark:bg-yellow-800', // Or
self::PENDING => 'bg-purple-100 dark:bg-purple-800', // Violet
self::EN_COURS => 'bg-orange-100 dark:bg-orange-800', // Orange
self::PROGRAMME => 'bg-darkgreen-100 dark:bg-darkgreen-800', // Vert foncé
self::QUALIFIE => 'bg-yellow-200 dark:bg-yellow-700', // Jaune
self::RECEPTIONNE => 'bg-cyan-100 dark:bg-cyan-800', // Cyan
self::ARBITRE_ANNULE => 'bg-brown-100 dark:bg-brown-800', // Marron
self::LIQUIDE => 'bg-indigo-100 dark:bg-indigo-800', // Indigo
self::REPORTE => 'bg-gray-100 dark:bg-gray-800', // Gris
];

if ($chiffre_statut == null) return 'bg-black-100 dark:bg-black-600';
return $classes[$chiffre_statut] ?? 'bg-black-100 dark:bg-black-600';
}
...
...
public static function getColorStatut(int $chiffre_statut = null) {
$classes = [
self::CREE => 'bg-red-100 dark:bg-red-800', // Rouge
self::A_TRAITER => 'bg-green-100 dark:bg-green-800', // Vert
self::VALIDE => 'bg-blue-100 dark:bg-blue-800', // Bleu
self::REJECTED => 'bg-yellow-100 dark:bg-yellow-800', // Or
self::PENDING => 'bg-purple-100 dark:bg-purple-800', // Violet
self::EN_COURS => 'bg-orange-100 dark:bg-orange-800', // Orange
self::PROGRAMME => 'bg-darkgreen-100 dark:bg-darkgreen-800', // Vert foncé
self::QUALIFIE => 'bg-yellow-200 dark:bg-yellow-700', // Jaune
self::RECEPTIONNE => 'bg-cyan-100 dark:bg-cyan-800', // Cyan
self::ARBITRE_ANNULE => 'bg-brown-100 dark:bg-brown-800', // Marron
self::LIQUIDE => 'bg-indigo-100 dark:bg-indigo-800', // Indigo
self::REPORTE => 'bg-gray-100 dark:bg-gray-800', // Gris
];

if ($chiffre_statut == null) return 'bg-black-100 dark:bg-black-600';
return $classes[$chiffre_statut] ?? 'bg-black-100 dark:bg-black-600';
}
...
DemandeResource.php :
public static function table(Table $table): Table
{
return $table
->modifyQueryUsing(fn (Builder $query) => $query->where('retard', 1))
->recordClasses(function (Demande $record) {
return DemandeStatutEnum::getColorStatut($record->statut);
})
->columns([
...
public static function table(Table $table): Table
{
return $table
->modifyQueryUsing(fn (Builder $query) => $query->where('retard', 1))
->recordClasses(function (Demande $record) {
return DemandeStatutEnum::getColorStatut($record->statut);
})
->columns([
...
The problem is that its dosen't works when i use this color : 'bg-brown-100 dark:bg-brown-800' or 'bg-darkgreen-100 dark:bg-darkgreen-800' I use npm run build before look if it's works but i have the same result 😢
3 replies
FFilament
Created by Sidem on 11/30/2023 in #❓┊help
problem mount
i use this in my Ressource page but but when I log in with account "D" on the OldRequest page, nothing happens, the user can navigate the page (even though he shouldn't)
class OldRequest extends Resource {

public function mount(): void{
abort_unless(auth()->user()->roles()->whereIn('name', ['D'])->exists(), 403); // auth()->user()->roles()->whereIn('name', ['D']->exists() : return true or false
$this->fillForm();
}

......
}
class OldRequest extends Resource {

public function mount(): void{
abort_unless(auth()->user()->roles()->whereIn('name', ['D'])->exists(), 403); // auth()->user()->roles()->whereIn('name', ['D']->exists() : return true or false
$this->fillForm();
}

......
}
if you have any ideas I'm interested
4 replies
FFilament
Created by Sidem on 11/29/2023 in #❓┊help
table count status
I want to create a table that counts the number of lines by status of the 'Demande' database. so I do this:
public function table(Table $table): Table
{
return $table
->query(DemandeResource::getEloquentQuery())
->modifyQueryUsing(fn (Builder $query) =>
$query
->where('demandeur_id', auth()->user()->id))
->columns([
TextColumn::make('statut')
->summarize(Sum::make('statut')),
))
->defaultGroup('statut')
->groupsOnly();
}
}
public function table(Table $table): Table
{
return $table
->query(DemandeResource::getEloquentQuery())
->modifyQueryUsing(fn (Builder $query) =>
$query
->where('demandeur_id', auth()->user()->id))
->columns([
TextColumn::make('statut')
->summarize(Sum::make('statut')),
))
->defaultGroup('statut')
->groupsOnly();
}
}
i you have any idees it will be nice 🙂 Thanks you !
42 replies
FFilament
Created by Sidem on 11/28/2023 in #❓┊help
relation : How can i show the name and not the ID
No description
6 replies
FFilament
Created by Sidem on 11/27/2023 in #❓┊help
Remove years
Hi ! I would like to remove years of my inpute Date :
DatePicker::make('firstDate')
->label('1ere Date vérification')
->time(false)
->format('m/d/y')
->columnSpan(2),
DatePicker::make('firstDate')
->label('1ere Date vérification')
->time(false)
->format('m/d/y')
->columnSpan(2),
You know how to do it ?
6 replies
FFilament
Created by Sidem on 11/27/2023 in #❓┊help
get back the categorie in my Ressource Page
Hi ! I would like to know if it's possible to get back the 'categorie' in my front : ChartRessource/Pages/ListChart.php :
public function getTabs(): array {
return [
'2022' => Tab::make()
->modifyQueryUsing(fn (Builder $query) =>
$query->with('demande')
->whereHas('demande', function($query) {
$query->where('etablissement_id', auth()->user()->etablissement_id );
})
),
];
}
public function getTabs(): array {
return [
'2022' => Tab::make()
->modifyQueryUsing(fn (Builder $query) =>
$query->with('demande')
->whereHas('demande', function($query) {
$query->where('etablissement_id', auth()->user()->etablissement_id );
})
),
];
}
And there is where i want to get back "2022" :
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('nom')->label('Etablissement')->searchable()->sortable(),
BudgetPrevChart::make('')->label('Budget Prev'),
CountEtablissementChart::make('id')->label('Nombre de demande par établissement'),
])
....
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('nom')->label('Etablissement')->searchable()->sortable(),
BudgetPrevChart::make('')->label('Budget Prev'),
CountEtablissementChart::make('id')->label('Nombre de demande par établissement'),
])
....
2 replies
FFilament
Created by Sidem on 11/17/2023 in #❓┊help
default select on relationship
No description
8 replies
FFilament
Created by Sidem on 11/8/2023 in #❓┊help
Export didn't work
Hi, i can't make the user to dowload the file but the link is good and when i put it on an other tab of my google, it work : there is my code in app\Services\ExportService.php :
public static function export($datas, $type)
{

//... my code

$writer->save($excelFile);
$filename = $name . now()->format('Y-m-d_H-i-s') . '.xlsx';
$filePath = 'public/' . $filename;
Storage::disk('local')->put($filePath, file_get_contents($excelFile));
unlink($excelFile);
return response()->download(storage_path('app/' . $filePath), $filename);
}
public static function export($datas, $type)
{

//... my code

$writer->save($excelFile);
$filename = $name . now()->format('Y-m-d_H-i-s') . '.xlsx';
$filePath = 'public/' . $filename;
Storage::disk('local')->put($filePath, file_get_contents($excelFile));
unlink($excelFile);
return response()->download(storage_path('app/' . $filePath), $filename);
}
if i do
dd(return response()->download(storage_path('app/' . $filePath), $filename));
dd(return response()->download(storage_path('app/' . $filePath), $filename));
it will send me a link that will download the file if I put it on another Google tab
3 replies