wip
This commit is contained in:
1 parent
2be54cdb61
commit
b0d0f3608c
14 files changed
+120
-25
No files matched your search
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\BettypeUser;
|
||||
use App\Models\MultilineSetting;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class BettypUserGenerator
|
||||
{
|
||||
public static function run($record)
|
||||
{
|
||||
$user_id = $record->id;
|
||||
|
||||
$multilines = MultilineSetting::select('id', 'sport_id')->get();
|
||||
|
||||
foreach ($multilines as $multiline) {
|
||||
|
||||
BettypeUser::firstOrCreate(
|
||||
[
|
||||
'user_id' => $user_id,
|
||||
'sport_id' => $multiline->sport_id,
|
||||
'multiline_setting_id' => $multiline->id,
|
||||
'is_active' => in_array($multiline->id, [1, 8, 12, 15]) ? 1 : 0,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Bettypes for user generated successfully')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Filament\Resources\Events\Tables;
|
||||
|
||||
use App\Filament\Tables\Columns\Columns3way;
|
||||
use App\Filament\Tables\Columns\MatchIds;
|
||||
use App\Models\BettypeUser;
|
||||
use App\Models\Country;
|
||||
use App\Models\Event;
|
||||
use Carbon\Carbon;
|
||||
@@ -24,8 +25,17 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class EventsTable
|
||||
{
|
||||
public static $bettype_settings = [];
|
||||
|
||||
public static function load_bettype_settings()
|
||||
{
|
||||
self::$bettype_settings = BettypeUser::where('user_id', auth()->user()->id)->where('sport_id', auth()->user()->sport_id)->where('is_active', 1)->pluck('multiline_setting_id')->toArray();
|
||||
}
|
||||
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
self::load_bettype_settings();
|
||||
|
||||
return $table
|
||||
->striped()
|
||||
->columns([
|
||||
@@ -58,7 +68,7 @@ class EventsTable
|
||||
->alignRight(),
|
||||
TextColumn::make('away.name')
|
||||
->searchable(),
|
||||
Columns3way::make('odds3way')->label(fn () => view('filament.tables.columns.multiline.labels')),
|
||||
Columns3way::make('odds3way')->visible(fn () => in_array(1, self::$bettype_settings))->label(fn () => view('filament.tables.columns.multiline.labels')),
|
||||
])
|
||||
->poll('10s')
|
||||
->defaultSort('starttime', 'ASC')
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources\Users\Tables;
|
||||
|
||||
use App\Actions\BettypUserGenerator;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
@@ -31,6 +33,12 @@ class UsersTable
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
Action::make('bettype')
|
||||
->icon('phosphor-gear-fine')
|
||||
->tooltip('Generates basic bettype monitor configuration for this user')
|
||||
->action(function ($record) {
|
||||
BettypUserGenerator::run($record);
|
||||
}),
|
||||
EditAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BettypeUser extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'sport_id',
|
||||
'multiline_setting_id',
|
||||
'is_active',
|
||||
];
|
||||
}
|
||||
@@ -146,4 +146,14 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function client()
|
||||
{
|
||||
return $this->belongsTo(Client::class);
|
||||
}
|
||||
|
||||
public function bettype_user()
|
||||
{
|
||||
return $this->hasMany(BettypeUser::class)->where('sport_id', auth()->user()->sport_id);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Filament\Resources\Events\Pages\ListEvents;
|
||||
use App\Utilities\Settings;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Support\Colors\Color;
|
||||
use Filament\Support\Facades\FilamentColor;
|
||||
@@ -28,10 +27,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->app->singleton('systemSettings', function () {
|
||||
return Settings::get();
|
||||
});
|
||||
|
||||
FilamentView::registerRenderHook(
|
||||
TablesRenderHook::TOOLBAR_SEARCH_AFTER,
|
||||
fn (): string => Blade::render('@livewire(\'bettype-toggle\')'),
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
use App\Models\MultilineSetting;
|
||||
|
||||
class Settings
|
||||
{
|
||||
public static function get()
|
||||
{
|
||||
return MultilineSetting::select('id', 'name', 'short', 'table', 'has_3_columns')->get()->keyBy('id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('bettype_users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id');
|
||||
$table->integer('sport_id');
|
||||
$table->integer('multiline_setting_id');
|
||||
$table->boolean('is_active')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('bettype_users');
|
||||
}
|
||||
};
|
||||
Generated
+2
@@ -1990,6 +1990,7 @@
|
||||
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
@@ -2223,6 +2224,7 @@
|
||||
"integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"esbuild": "^0.27.0",
|
||||
"fdir": "^6.5.0",
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
<div {{ $getExtraAttributeBag() }} class="grid grid-cols-5 grid-rows-4 text-xs gap-0 justify-between">
|
||||
|
||||
{{-- @include('filament.tables.columns.multiline.labels') --}}
|
||||
|
||||
@foreach ($getMultilines() as $item)
|
||||
@include('filament.tables.columns.multiline.bkm', [
|
||||
'bookmaker_id' => $item->bookmaker_id,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@if ($hasodds())
|
||||
<div x-data="{ message: 'loading..' }" class="mx-3 my-auto">
|
||||
<template x-ref="template">
|
||||
<div class="grid grid-cols-5 grid-rows-5 gap-2 m-5">
|
||||
<div class="grid grid-cols-5 grid-rows-5 gap-1 m-5">
|
||||
|
||||
@foreach ($getFumetto() as $item)
|
||||
@include('filament.tables.columns.multiline.bkm', [
|
||||
|
||||
@@ -1 +1 @@
|
||||
<div class="text-center">{{ $label }}</div>
|
||||
<div class="size-14">{{ $label }}</div>
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="grid grid-cols-6 text-xs gap-0 justify-start text-xs">
|
||||
<div class="text-center"></div>
|
||||
<div class="text-center"></div>
|
||||
<div class="flex justify-start my-0 p-0 h-5">
|
||||
<div class="size-14 text-center"></div>
|
||||
<div class="size-14 text-center"></div>
|
||||
@switch(auth()->user()->multiline_setting_id)
|
||||
@case(1)
|
||||
@case(13)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
use App\Utilities\OddsFormatting;
|
||||
@endphp
|
||||
|
||||
<div class="text-right mb-0.5 ml-0.5 border">
|
||||
<div class="text-right mb-0.5 ml-0.5">
|
||||
|
||||
@if (isset($odd))
|
||||
{{ OddsFormatting::get($odd, $decimal) }}
|
||||
|
||||
Reference in new issue
Block a user