fix animation
This commit is contained in:
1 parent
f0bbcbc72f
commit
657f356590
10 files changed
+16046
-99
No files matched your search
+3
-2
@@ -27,6 +27,7 @@ class SofaScoreRosasTable
|
||||
TextColumn::make('tournament_rosa.tournament.name')->label('Tournament')
|
||||
->sortable(),
|
||||
TextColumn::make('ss_team_name')->label('Name')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('updated_at')->dateTime('Y-m-d H:i:s')
|
||||
->sortable()
|
||||
@@ -46,9 +47,9 @@ class SofaScoreRosasTable
|
||||
})
|
||||
->live(),
|
||||
Select::make('ss_tournament_id')
|
||||
->default(23)
|
||||
// ->default(23)
|
||||
->label('Tournament')
|
||||
->selectablePlaceholder(false)
|
||||
->selectablePlaceholder(true)
|
||||
->options(function (Get $get) {
|
||||
$res = SofaScoreTournament::with('sofascore_category')->where('enabled', 1)->where('sport_id', $get('sport_id'))->get();
|
||||
$return = [];
|
||||
|
||||
@@ -9,9 +9,10 @@ use App\Utilities\Round;
|
||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||
use Filament\Widgets\StatsOverviewWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Livewire\Attributes\Reactive;
|
||||
use Illuminate\Support\Carbon;
|
||||
// use Illuminate\Support\Facades\Log;
|
||||
|
||||
class StatsMedianAverage extends StatsOverviewWidget
|
||||
{
|
||||
@@ -158,54 +159,58 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
|
||||
$boxes = [];
|
||||
|
||||
// Log::info(__Line__ . ' ' . $expectations_home . ' - ' . $expectations_away);
|
||||
|
||||
|
||||
// BOX 1
|
||||
$boxes[] = Stat::make($statistic_type, self::template_2sp('expectations_home', 'expectations_away', 'Home', 'Away', $expectations_home, $expectations_away))
|
||||
$boxes[] = Stat::make($statistic_type, self::template_box1($expectations_home, $expectations_away))
|
||||
->description('Expected Values')
|
||||
->extraAttributes([
|
||||
'x-init' => "console.log('expectations_home, expectations_away'); animate('expectations_home', $expectations_home); animate('expectations_away', $expectations_away)",
|
||||
'class' => 'box-yellow',
|
||||
]);
|
||||
|
||||
if ($team_id) {
|
||||
// BOX 2
|
||||
|
||||
$boxes[] = Stat::make('Total', self::template_1sp('number-of-events', $total_home, 'Events'))
|
||||
// BOX 2
|
||||
$boxes[] = Stat::make('Total', self::template_box2($total_home))
|
||||
->description(fn() => new HtmlString($date_events))
|
||||
->extraAttributes([
|
||||
'x-init' => "console.log('number-of-events'); animate('number-of-events', $total_home);",
|
||||
'class' => 'box-info',
|
||||
]);
|
||||
|
||||
// BOX 3
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_2sp('avhome', 'avaway', $home_team, $away_team, $value_home, $value_away))
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_box3($home_team, $away_team, $value_home, $value_away))
|
||||
->description('Team ' . $team_position)
|
||||
->extraAttributes([
|
||||
'x-init' => "animate('average_home', $value_home); animate('average_away', $value_away)",
|
||||
'class' => 'box-success',
|
||||
]);
|
||||
// ->extraAttributes(['x-init' => "animate('avhome', $value_home); animate('avaway', $value_away)"]);
|
||||
|
||||
// BOX 4
|
||||
// Log::debug([$average_team_home, $average_team_away]);
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_2sp('av_team_home', 'av_team_away', $home_team, $away_team, $average_team_home, $average_team_away))
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_box4($home_team, $away_team, $average_team_home, $average_team_away))
|
||||
->description('Team Season')
|
||||
->extraAttributes([
|
||||
'x-init' => "animate('av_team_home', $average_team_home); animate('av_team_away', $average_team_away)",
|
||||
'class' => 'box-success',
|
||||
]);
|
||||
// ->extraAttributes(['x-init' => "animate('av_team_home', $average_team_home); animate('av_team_away', $average_team_away)"]);
|
||||
|
||||
// BOX 5
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_2sp('av_league_home', 'av_league_away', 'Home', 'Away', $average_league_home, $average_league_away))
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_box5('Home', 'Away', $average_league_home, $average_league_away))
|
||||
->description('League Season')
|
||||
->extraAttributes([
|
||||
'x-init' => "animate('av_league_home', $average_league_home); animate('av_league_away', $average_league_away)",
|
||||
'class' => 'box-success',
|
||||
]);
|
||||
// ->extraAttributes(['x-init' => "animate('av_league_home', $average_league_home); animate('av_league_away', $average_league_away)"]);
|
||||
|
||||
// BOX 6
|
||||
$boxes[] = Stat::make('Odds', self::templateOdds($data, $win, $draw, $lost))
|
||||
->description($team_position)
|
||||
->extraAttributes([
|
||||
'x-init' => "animate('win', $win); animate('draw', $draw); animate('lost', $lost)",
|
||||
'class' => 'box-purple',
|
||||
]);
|
||||
// ->extraAttributes(['x-init' => "animate('mehome', $median_home); animate('meaway', $median_away, 0)"]);
|
||||
}
|
||||
|
||||
$this->columns = [
|
||||
@@ -218,6 +223,60 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
return $boxes;
|
||||
}
|
||||
|
||||
// TEAMPLATE BOX 1
|
||||
protected function template_box1(float $expectations_home, float $expectations_away): HtmlString
|
||||
{
|
||||
return new HtmlString('<div class="grid grid-cols-2 justify-center font-bold text-2xl">
|
||||
<span class="text-center" id="expectations_home">' . $expectations_home . '</span>
|
||||
<span class="text-center" id="expectations_away">' . $expectations_away . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">Home</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">Away</span>
|
||||
</div>');
|
||||
}
|
||||
|
||||
// TEAMPLATE BOX 2
|
||||
protected function template_box2(float $total_home): HtmlString
|
||||
{
|
||||
return new HtmlString('<div class="grid grid-cols-1 justify-center font-bold text-2xl">
|
||||
<span class="text-center" id="number-of-events">' . $total_home . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">Events</span>
|
||||
</div>');
|
||||
}
|
||||
|
||||
// TEAMPLATE BOX 3
|
||||
protected function template_box3(string $home_team, string $away_team, float $value_home, float $value_away): HtmlString
|
||||
{
|
||||
return new HtmlString('<div class="grid grid-cols-2 justify-center font-bold text-2xl">
|
||||
<span class="text-center" id="average_home">' . $value_home . '</span>
|
||||
<span class="text-center" id="average_away">' . $value_away . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $home_team . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $away_team . '</span>
|
||||
</div>');
|
||||
}
|
||||
|
||||
// TEAMPLATE BOX 4
|
||||
protected function template_box4(string $home_team, string $away_team, float $value_home, float $value_away): HtmlString
|
||||
{
|
||||
return new HtmlString('<div class="grid grid-cols-2 justify-center font-bold text-2xl">
|
||||
<span class="text-center" id="av_team_home">' . $value_home . '</span>
|
||||
<span class="text-center" id="av_team_away">' . $value_away . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $home_team . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $away_team . '</span>
|
||||
</div>');
|
||||
}
|
||||
|
||||
// TEAMPLATE BOX 5
|
||||
protected function template_box5(string $home_team, string $away_team, float $value_home, float $value_away): HtmlString
|
||||
{
|
||||
return new HtmlString('<div class="grid grid-cols-2 justify-center font-bold text-2xl">
|
||||
<span class="text-center" id="av_league_home">' . $value_home . '</span>
|
||||
<span class="text-center" id="av_league_away">' . $value_away . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $home_team . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $away_team . '</span>
|
||||
</div>');
|
||||
}
|
||||
|
||||
// TEAMPLATE BOX 6 odds
|
||||
protected function templateOdds(array &$data, float $win, float $draw, float $lost): HtmlString
|
||||
{
|
||||
if ($data['similar_past_matches'] != 'none') {
|
||||
@@ -231,32 +290,15 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
}
|
||||
|
||||
return new HtmlString('<div class="grid grid-cols-3 justify-center">
|
||||
<span class="text-center font-bold text-xl">' . number_format($win, 2) . '</span>
|
||||
<span class="text-center font-bold text-xl">' . number_format($draw, 2) . '</span>
|
||||
<span class="text-center font-bold text-xl">' . number_format($lost, 2) . '</span>
|
||||
<span class="text-center font-bold text-xl" id="win">' . number_format($win, 2) . '</span>
|
||||
<span class="text-center font-bold text-xl" id="draw">' . number_format($draw, 2) . '</span>
|
||||
<span class="text-center font-bold text-xl" id="lost">' . number_format($lost, 2) . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $name_win . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $name_draw . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $name_lost . '</span>
|
||||
</div>');
|
||||
}
|
||||
|
||||
protected function template_1sp(string $value_id, string $value, $text = 0): HtmlString
|
||||
{
|
||||
return new HtmlString('<div class="grid grid-cols-1 justify-center font-bold text-2xl">
|
||||
<span class="text-center" id="' . $value_id . '">' . $value . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $text . '</span>
|
||||
</div>');
|
||||
}
|
||||
|
||||
protected function template_2sp(string $home_id, string $away_id, string $home_name, string $away_name, $val_home = 0, $val_away = 0): HtmlString
|
||||
{
|
||||
return new HtmlString('<div class="grid grid-cols-2 justify-center font-bold text-2xl">
|
||||
<span class="text-center" id="' . $home_id . '">' . $val_home . '</span>
|
||||
<span class="text-center" id="' . $away_id . '">' . $val_away . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $home_name . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $away_name . '</span>
|
||||
</div>');
|
||||
}
|
||||
|
||||
protected function getMedian(array $arr)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user