SirAlyon
SirAlyon
FFilament
Created by SirAlyon on 9/18/2024 in #❓┊help
How to Customize Filament Table Queries in Laravel: Help Needed!
I'm trying something like:
public static function getEloquentQuery(): Builder
{
$today = Carbon::now()->format('Y-m-d');
$yesterday = Carbon::now()->subDay()->format('Y-m-d');

// Crea sottoquery per il giorno attuale (2024-09-18)
$subqueryTab0 = GridJobImport::select('ijob')
->selectRaw('SUM(irighe) as irighe')
->where('cstato', 'A')
->where('tuts', '>=', $today)
->groupBy('ijob');

// Crea sottoquery per il giorno precedente (2024-09-17)
$subqueryTab1 = GridJobImport::select('ijob')
->selectRaw('SUM(irighe) as irighe')
->where('cstato', 'A')
->where('tuts', '>=', $yesterday)
->groupBy('ijob');

// Eloquent query con leftJoinSub
return GridJobImport::query()
->leftJoinSub($subqueryTab0, 'tab0', function ($join) {
$join->on('jobs_import_grid.ijob', '=', 'tab0.ijob');
})
->leftJoinSub($subqueryTab1, 'tab1', function ($join) {
$join->on('jobs_import_grid.ijob', '=', 'tab1.ijob');
})
->select('jobs_import_grid.ijob')
->selectRaw("CONCAT(COUNT(jobs_import_grid.ijob), ' (', COALESCE(SUM(tab0.irighe), 0), ')') AS '2024-09-18'")
->selectRaw("CONCAT(COUNT(jobs_import_grid.ijob), ' (', COALESCE(SUM(tab1.irighe), 0), ')') AS '2024-09-17'")
->groupBy('jobs_import_grid.ijob');
}
public static function getEloquentQuery(): Builder
{
$today = Carbon::now()->format('Y-m-d');
$yesterday = Carbon::now()->subDay()->format('Y-m-d');

// Crea sottoquery per il giorno attuale (2024-09-18)
$subqueryTab0 = GridJobImport::select('ijob')
->selectRaw('SUM(irighe) as irighe')
->where('cstato', 'A')
->where('tuts', '>=', $today)
->groupBy('ijob');

// Crea sottoquery per il giorno precedente (2024-09-17)
$subqueryTab1 = GridJobImport::select('ijob')
->selectRaw('SUM(irighe) as irighe')
->where('cstato', 'A')
->where('tuts', '>=', $yesterday)
->groupBy('ijob');

// Eloquent query con leftJoinSub
return GridJobImport::query()
->leftJoinSub($subqueryTab0, 'tab0', function ($join) {
$join->on('jobs_import_grid.ijob', '=', 'tab0.ijob');
})
->leftJoinSub($subqueryTab1, 'tab1', function ($join) {
$join->on('jobs_import_grid.ijob', '=', 'tab1.ijob');
})
->select('jobs_import_grid.ijob')
->selectRaw("CONCAT(COUNT(jobs_import_grid.ijob), ' (', COALESCE(SUM(tab0.irighe), 0), ')') AS '2024-09-18'")
->selectRaw("CONCAT(COUNT(jobs_import_grid.ijob), ' (', COALESCE(SUM(tab1.irighe), 0), ')') AS '2024-09-17'")
->groupBy('jobs_import_grid.ijob');
}
but it trigger: Filament\Resources\Pages\ListRecords::getTableRecordKey(): Return value must be of type string, null returned.
6 replies
FFilament
Created by SirAlyon on 9/18/2024 in #❓┊help
How to Customize Filament Table Queries in Laravel: Help Needed!
Here the query:
SELECT tab.ijob, CONCAT(COUNT(1), ' (', SUM(tab0.irighe),')') AS '2024-09-18', CONCAT(COUNT(1), ' (', SUM(tab1.irighe),')') AS '2024-09-17'
FROM jobs_import_grid AS tab

LEFT JOIN (SELECT
ijob,
irighe,
tuts
FROM
jobs_import_grid
WHERE
cstato = 'A'
AND tuts >= '2024-09-18'
GROUP BY ijob) AS tab0
ON tab.ijob = tab0.ijob AND tab.tuts = tab0.tuts

LEFT JOIN (SELECT
ijob,
irighe,
tuts
FROM
jobs_import_grid
WHERE
cstato = 'A'
AND tuts >= '2024-09-17'
GROUP BY ijob) AS tab1
ON tab.ijob = tab1.ijob AND tab.tuts = tab1.tuts

GROUP BY tab.ijob
SELECT tab.ijob, CONCAT(COUNT(1), ' (', SUM(tab0.irighe),')') AS '2024-09-18', CONCAT(COUNT(1), ' (', SUM(tab1.irighe),')') AS '2024-09-17'
FROM jobs_import_grid AS tab

LEFT JOIN (SELECT
ijob,
irighe,
tuts
FROM
jobs_import_grid
WHERE
cstato = 'A'
AND tuts >= '2024-09-18'
GROUP BY ijob) AS tab0
ON tab.ijob = tab0.ijob AND tab.tuts = tab0.tuts

LEFT JOIN (SELECT
ijob,
irighe,
tuts
FROM
jobs_import_grid
WHERE
cstato = 'A'
AND tuts >= '2024-09-17'
GROUP BY ijob) AS tab1
ON tab.ijob = tab1.ijob AND tab.tuts = tab1.tuts

GROUP BY tab.ijob
6 replies
FFilament
Created by SirAlyon on 5/24/2024 in #❓┊help
Help Needed with ToggleButtons in Filament Form
It is working perfectly fine 🙂 ❤️
24 replies
FFilament
Created by SirAlyon on 5/24/2024 in #❓┊help
Help Needed with ToggleButtons in Filament Form
@Tally You have saved me from days of futile attempts. I don't know how to thank you! Thank you so much.
24 replies
FFilament
Created by SirAlyon on 5/24/2024 in #❓┊help
Help Needed with ToggleButtons in Filament Form
I have some doubts this is the right method to accomplish what i need :/
24 replies
FFilament
Created by SirAlyon on 5/24/2024 in #❓┊help
Help Needed with ToggleButtons in Filament Form
(still not working)
24 replies
FFilament
Created by SirAlyon on 5/24/2024 in #❓┊help
Help Needed with ToggleButtons in Filament Form
Something like that:
ToggleButtons::make('allocazione')
->label('')
->multiple()
->required()
->markAsRequired(false)
->options([
'obbligazionaria' => 'Obbligazionaria',
'prudente' => 'Prudente',
'moderata' => 'Moderata',
'azionaria' => 'Azionaria',
'libera' => 'Libera',
])
//->disableOptionWhen(fn (string $value): bool => $value === 'libera')
->disableOptionWhen(function (string $value) {
switch ($value) {
case 'obbligazionaria':
return 'true';
break;
case 'prudente':
return 'true';
break;
case 'moderata':
return 'true';
break;
case 'azionaria':
return 'true';
break;
}
})
ToggleButtons::make('allocazione')
->label('')
->multiple()
->required()
->markAsRequired(false)
->options([
'obbligazionaria' => 'Obbligazionaria',
'prudente' => 'Prudente',
'moderata' => 'Moderata',
'azionaria' => 'Azionaria',
'libera' => 'Libera',
])
//->disableOptionWhen(fn (string $value): bool => $value === 'libera')
->disableOptionWhen(function (string $value) {
switch ($value) {
case 'obbligazionaria':
return 'true';
break;
case 'prudente':
return 'true';
break;
case 'moderata':
return 'true';
break;
case 'azionaria':
return 'true';
break;
}
})
24 replies
FFilament
Created by SirAlyon on 5/24/2024 in #❓┊help
Help Needed with ToggleButtons in Filament Form
Pump
24 replies
FFilament
Created by SirAlyon on 5/24/2024 in #❓┊help
Help Needed with ToggleButtons in Filament Form
as you can see "libera" is disabled by default
24 replies
FFilament
Created by SirAlyon on 5/24/2024 in #❓┊help
Help Needed with ToggleButtons in Filament Form
No description
24 replies
FFilament
Created by SirAlyon on 5/24/2024 in #❓┊help
Help Needed with ToggleButtons in Filament Form
and trying with something like
->disableOptionWhen(fn (string $value): bool => $value === 'libera')
->disableOptionWhen(fn (string $value): bool => $value === 'libera')
result in:
24 replies
FFilament
Created by SirAlyon on 5/24/2024 in #❓┊help
Help Needed with ToggleButtons in Filament Form
This code is disabling 'obbligazionaria', 'prudente','moderata', 'azionaria' by default..
24 replies
FFilament
Created by SirAlyon on 5/24/2024 in #❓┊help
Help Needed with ToggleButtons in Filament Form
Sorry but im not understanding how to use this function:
ToggleButtons::make('allocazione')
->label('')
->multiple()
->required()
->markAsRequired(false)
->options([
'obbligazionaria' => 'Obbligazionaria',
'prudente' => 'Prudente',
'moderata' => 'Moderata',
'azionaria' => 'Azionaria',
'libera' => 'Libera',
])
->disableOptionWhen(function (string $value) {
switch ($value) {
case 'obbligazionaria':
return 'libera';
break;
case 'prudente':
return 'libera';
break;
case 'moderata':
return 'libera';
break;
case 'azionaria':
return 'libera';
break;

}
})
->rules([new Allocazione])
->inline()
ToggleButtons::make('allocazione')
->label('')
->multiple()
->required()
->markAsRequired(false)
->options([
'obbligazionaria' => 'Obbligazionaria',
'prudente' => 'Prudente',
'moderata' => 'Moderata',
'azionaria' => 'Azionaria',
'libera' => 'Libera',
])
->disableOptionWhen(function (string $value) {
switch ($value) {
case 'obbligazionaria':
return 'libera';
break;
case 'prudente':
return 'libera';
break;
case 'moderata':
return 'libera';
break;
case 'azionaria':
return 'libera';
break;

}
})
->rules([new Allocazione])
->inline()
24 replies
FFilament
Created by SirAlyon on 5/24/2024 in #❓┊help
Help Needed with ToggleButtons in Filament Form
I'm trying, im gonna paste the code asap. Thanks for help
24 replies
FFilament
Created by SirAlyon on 5/24/2024 in #❓┊help
Help Needed with ToggleButtons in Filament Form
Ye i tried with this method but coudn't work as excepted 😦
24 replies
FFilament
Created by SirAlyon on 5/24/2024 in #❓┊help
Help Needed with ToggleButtons in Filament Form
Anyone? 😦
24 replies
FFilament
Created by Sourabh on 4/4/2024 in #❓┊help
Failed to import csv
Try to share ur resources code
27 replies
FFilament
Created by Sourabh on 4/4/2024 in #❓┊help
Failed to import csv
Then we are missing something 🙂
27 replies
FFilament
Created by Sourabh on 4/4/2024 in #❓┊help
Failed to import csv
Seems ok to me. The failed_import_rows is showing the wrong import attempts?
27 replies
FFilament
Created by Sourabh on 4/4/2024 in #❓┊help
Failed to import csv
Try to share more infos
27 replies