wip uni file manager
This commit is contained in:
1 parent
51e2659a1e
commit
8eaead42e6
9 files changed
+605
-352
No files matched your search
+4
-3
@@ -13,6 +13,7 @@ use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable implements FilamentUser, HasAppAuthentication, HasAppAuthenticationRecovery, HasEmailAuthentication, MustVerifyEmail
|
||||
@@ -184,7 +185,7 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
|
||||
|
||||
public function bettype_user()
|
||||
{
|
||||
return $this->hasMany(BettypeUser::class)->where('sport_id', auth()->user()->sport_id);
|
||||
return $this->hasMany(BettypeUser::class)->where('sport_id', Auth::user()->sport_id);
|
||||
}
|
||||
|
||||
// Accessor
|
||||
@@ -195,11 +196,11 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
|
||||
|
||||
public function userBookmaker()
|
||||
{
|
||||
return Bookmaker::where('id', auth()->user()->bookmaker_id)->select('id', 'name', 'icon', 'svg')->first();
|
||||
return Bookmaker::where('id', Auth::user()->bookmaker_id)->select('id', 'name', 'icon', 'svg')->first();
|
||||
}
|
||||
|
||||
public static function getUser()
|
||||
{
|
||||
return User::with('bookmaker')->find(auth()->user()->id);
|
||||
return User::with('bookmaker')->find(Auth::user()->id);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Filament\Resources\Events\Pages\ListEvents;
|
||||
use App\Models\User;
|
||||
use BezhanSalleh\FilamentShield\Facades\FilamentShield;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Notifications\Livewire\Notifications;
|
||||
@@ -17,7 +18,9 @@ use Filament\Support\Facades\FilamentTimezone;
|
||||
use Filament\Support\Facades\FilamentView;
|
||||
use Filament\Tables\View\TablesRenderHook;
|
||||
use Filament\View\PanelsRenderHook;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
@@ -36,6 +39,11 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
|
||||
Gate::define('manageFileManager', function (User $user): bool {
|
||||
return Auth::user()->hasRole('super_admin') ?? false;
|
||||
});
|
||||
|
||||
FilamentShield::enforcePolicies();
|
||||
|
||||
FilamentTimezone::set('Europe/Vienna');
|
||||
|
||||
@@ -38,6 +38,7 @@ use Joaopaulolndev\FilamentEditProfile\Pages\EditProfilePage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Swis\Filament\Backgrounds\FilamentBackgroundsPlugin;
|
||||
use Swis\Filament\Backgrounds\ImageProviders\MyImages;
|
||||
use UniFileManager\FilamentFileManager\FilamentFileManagerPlugin;
|
||||
|
||||
class AdminPanelProvider extends PanelProvider
|
||||
{
|
||||
@@ -51,6 +52,13 @@ class AdminPanelProvider extends PanelProvider
|
||||
RecordUserActivity::class,
|
||||
])
|
||||
->userMenuItems([
|
||||
Action::make('file-exchange') // Give your action a unique name/ID
|
||||
->label('File Exchange')
|
||||
->color('warning')
|
||||
->visible(fn (): bool => Auth::user()->hasRole('super_admin'))
|
||||
->url('https://file.statistiko.at/', shouldOpenInNewTab: true)
|
||||
->icon('heroicon-o-arrow-top-right-on-square')
|
||||
->visible(true),
|
||||
ExportAction::make('download_betfair')
|
||||
->columnMapping(false)
|
||||
->exporter(BetfairExporter::class)
|
||||
@@ -180,6 +188,12 @@ class AdminPanelProvider extends PanelProvider
|
||||
->authMiddleware([
|
||||
Authenticate::class,
|
||||
])->plugins([
|
||||
FilamentFileManagerPlugin::make()
|
||||
->navigationLabel('Files')
|
||||
// ->navigationGroup('Data')
|
||||
->navigationSort(10)
|
||||
->navigationIcon('heroicon-o-folder'),
|
||||
// ->shouldRegisterNavigation(fn (): bool => Auth::user()->hasRole('super_admin') ?? false),
|
||||
FilamentShieldPlugin::make()
|
||||
->navigationGroup('User')
|
||||
->navigationSort(10)
|
||||
|
||||
@@ -12,6 +12,9 @@ trait GrappingEvent
|
||||
{
|
||||
protected function get_event(string $day, array $tournament)
|
||||
{
|
||||
|
||||
$targetDate = Carbon::parse($day);
|
||||
|
||||
foreach ($this->day_tournaments as $day_tournament) {
|
||||
|
||||
if ($day_tournament->tournament_id == $tournament['sofa_score_tournament_id']) {
|
||||
@@ -36,153 +39,167 @@ trait GrappingEvent
|
||||
|
||||
foreach ($data['events'] as $event) {
|
||||
|
||||
$base_check_string = $day.'-'.$event['tournament']['category']['slug'].'-'.$event['tournament']['slug'].'/'.$event['slug'];
|
||||
$starttime = $event['startTimestamp'];
|
||||
|
||||
$res = SofaScoreEventGrapped::where('id', (int) $event['id'])->where('grapper_id', $this->task_id)->first();
|
||||
$timestamp = Carbon::createFromTimestamp($event['startTimestamp']);
|
||||
|
||||
if (! $res) {
|
||||
// Check if it matches today's calendar date
|
||||
if ($timestamp->isSameDay($targetDate)) {
|
||||
// Timestamp is within today's 24-hour block
|
||||
|
||||
$base_check_string = $day.'-'.$event['tournament']['category']['slug'].'-'.$event['tournament']['slug'].'/'.$event['slug'];
|
||||
|
||||
// chinese-super-league
|
||||
$res = SofaScoreEventGrapped::where('id', (int) $event['id'])->where('grapper_id', $this->task_id)->first();
|
||||
|
||||
if (! $this->restart && SofaScoreEventGrapped::where('grapper_id', $this->task_id)->where('id', (int) $event['id'])->exists()) {
|
||||
if ($this->debug) {
|
||||
Notice::note('DB - Allready grapped at '.$day.' - '.$event['homeTeam']['name'].' vs '.$event['awayTeam']['name'], 'b');
|
||||
if (! $res) {
|
||||
|
||||
$base_check_string = $day.'-'.$event['tournament']['category']['slug'].'-'.$event['tournament']['slug'].'/'.$event['slug'];
|
||||
|
||||
// chinese-super-league
|
||||
|
||||
if (! $this->restart && SofaScoreEventGrapped::where('grapper_id', $this->task_id)->where('id', (int) $event['id'])->exists()) {
|
||||
if ($this->debug) {
|
||||
Notice::note('DB - Allready grapped at '.$day.' - '.$event['homeTeam']['name'].' vs '.$event['awayTeam']['name'], 'b');
|
||||
}
|
||||
} else {
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note("$day - ".$event['homeTeam']['name'].' vs '.$event['awayTeam']['name'], 'g');
|
||||
}
|
||||
|
||||
$folder = strtolower("$this->data_dir/$day/$day-".$event['tournament']['category']['slug'].'-'.$event['tournament']['slug'].'/'.$event['slug']);
|
||||
|
||||
File::makeDirectory($folder, 0775, true, true);
|
||||
|
||||
/*********************************
|
||||
* EVENT event
|
||||
*********************************/
|
||||
|
||||
File::put("$folder/event.json", json_encode($event));
|
||||
|
||||
/*********************************
|
||||
* EVENT statistics
|
||||
*********************************/
|
||||
|
||||
$event_id = $event['id'];
|
||||
|
||||
if (! $this->grapped($base_check_string.'/statistics.json')) {
|
||||
|
||||
$url = $this->base_url."api/v1/event/$event_id/statistics";
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note($url, 'b');
|
||||
}
|
||||
|
||||
$this->grapper_sleep();
|
||||
|
||||
$data = $cloudflareService->getJsonFromUrl($url);
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put("$folder/statistics.json", json_encode($data));
|
||||
} else {
|
||||
if ($this->debug) {
|
||||
Notice::note('already grapped statistics.json', 'y');
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************
|
||||
* EVENT lineups
|
||||
*********************************/
|
||||
|
||||
if (! $this->grapped($base_check_string.'/lineups.json')) {
|
||||
|
||||
$url = $this->base_url."api/v1/event/$event_id/lineups";
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note($url, 'b');
|
||||
}
|
||||
|
||||
$this->grapper_sleep();
|
||||
|
||||
$data = $cloudflareService->getJsonFromUrl($url);
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put("$folder/lineups.json", json_encode($data));
|
||||
} else {
|
||||
if ($this->debug) {
|
||||
Notice::note('already grapped lineups.json', 'y');
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************
|
||||
* EVENT odds
|
||||
*********************************/
|
||||
|
||||
if (! $this->grapped($base_check_string.'/odds.json')) {
|
||||
|
||||
$url = $this->base_url."api/v1/event/$event_id/odds/1/all";
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note($url, 'b');
|
||||
}
|
||||
|
||||
$this->grapper_sleep();
|
||||
|
||||
$data = $cloudflareService->getJsonFromUrl($url);
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put("$folder/odds.json", json_encode($data));
|
||||
} else {
|
||||
if ($this->debug) {
|
||||
Notice::note('already grapped odds.json', 'y');
|
||||
}
|
||||
}
|
||||
/*********************************
|
||||
* EVENT incidents
|
||||
*********************************/
|
||||
|
||||
if (! $this->grapped($base_check_string.'/incidents.json')) {
|
||||
|
||||
$url = $this->base_url."api/v1/event/$event_id/incidents";
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note($url, 'b');
|
||||
}
|
||||
|
||||
$this->grapper_sleep();
|
||||
|
||||
$data = $cloudflareService->getJsonFromUrl($url);
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put("$folder/incidents.json", json_encode($data));
|
||||
} else {
|
||||
if ($this->debug) {
|
||||
Notice::note('already grapped incidents.json', 'y');
|
||||
}
|
||||
}
|
||||
|
||||
$starttime = Carbon::createFromTimestamp($event['startTimestamp']);
|
||||
|
||||
SofaScoreEventGrapped::updateOrCreate([
|
||||
'id' => (int) $event['id'],
|
||||
], [
|
||||
'grapper_id' => $this->task_id,
|
||||
'day' => $day,
|
||||
'liga' => $event['tournament']['name'],
|
||||
'name' => $event['homeTeam']['name'].' vs '.$event['awayTeam']['name'],
|
||||
'url' => $url,
|
||||
'starttime' => $starttime->toDateTimeString(),
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note("$day - ".$event['homeTeam']['name'].' vs '.$event['awayTeam']['name'], 'g');
|
||||
Notice::note('allready in db event grapped: '.$base_check_string, 'p');
|
||||
}
|
||||
|
||||
$folder = strtolower("$this->data_dir/$day/$day-".$event['tournament']['category']['slug'].'-'.$event['tournament']['slug'].'/'.$event['slug']);
|
||||
|
||||
File::makeDirectory($folder, 0775, true, true);
|
||||
|
||||
/*********************************
|
||||
* EVENT event
|
||||
*********************************/
|
||||
|
||||
File::put("$folder/event.json", json_encode($event));
|
||||
|
||||
/*********************************
|
||||
* EVENT statistics
|
||||
*********************************/
|
||||
|
||||
$event_id = $event['id'];
|
||||
|
||||
if (! $this->grapped($base_check_string.'/statistics.json')) {
|
||||
|
||||
$url = $this->base_url."api/v1/event/$event_id/statistics";
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note($url, 'b');
|
||||
}
|
||||
|
||||
$this->grapper_sleep();
|
||||
|
||||
$data = $cloudflareService->getJsonFromUrl($url);
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put("$folder/statistics.json", json_encode($data));
|
||||
} else {
|
||||
if ($this->debug) {
|
||||
Notice::note('already grapped statistics.json', 'y');
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************
|
||||
* EVENT lineups
|
||||
*********************************/
|
||||
|
||||
if (! $this->grapped($base_check_string.'/lineups.json')) {
|
||||
|
||||
$url = $this->base_url."api/v1/event/$event_id/lineups";
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note($url, 'b');
|
||||
}
|
||||
|
||||
$this->grapper_sleep();
|
||||
|
||||
$data = $cloudflareService->getJsonFromUrl($url);
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put("$folder/lineups.json", json_encode($data));
|
||||
} else {
|
||||
if ($this->debug) {
|
||||
Notice::note('already grapped lineups.json', 'y');
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************
|
||||
* EVENT odds
|
||||
*********************************/
|
||||
|
||||
if (! $this->grapped($base_check_string.'/odds.json')) {
|
||||
|
||||
$url = $this->base_url."api/v1/event/$event_id/odds/1/all";
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note($url, 'b');
|
||||
}
|
||||
|
||||
$this->grapper_sleep();
|
||||
|
||||
$data = $cloudflareService->getJsonFromUrl($url);
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put("$folder/odds.json", json_encode($data));
|
||||
} else {
|
||||
if ($this->debug) {
|
||||
Notice::note('already grapped odds.json', 'y');
|
||||
}
|
||||
}
|
||||
/*********************************
|
||||
* EVENT incidents
|
||||
*********************************/
|
||||
|
||||
if (! $this->grapped($base_check_string.'/incidents.json')) {
|
||||
|
||||
$url = $this->base_url."api/v1/event/$event_id/incidents";
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note($url, 'b');
|
||||
}
|
||||
|
||||
$this->grapper_sleep();
|
||||
|
||||
$data = $cloudflareService->getJsonFromUrl($url);
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put("$folder/incidents.json", json_encode($data));
|
||||
} else {
|
||||
if ($this->debug) {
|
||||
Notice::note('already grapped incidents.json', 'y');
|
||||
}
|
||||
}
|
||||
|
||||
$starttime = Carbon::createFromTimestamp($event['startTimestamp']);
|
||||
|
||||
SofaScoreEventGrapped::updateOrCreate([
|
||||
'id' => (int) $event['id'],
|
||||
], [
|
||||
'grapper_id' => $this->task_id,
|
||||
'day' => $day,
|
||||
'liga' => $event['tournament']['name'],
|
||||
'name' => $event['homeTeam']['name'].' vs '.$event['awayTeam']['name'],
|
||||
'url' => $url,
|
||||
'starttime' => $starttime->toDateTimeString(),
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
// not same day!
|
||||
if ($this->debug) {
|
||||
Notice::note('allready in db event grapped: '.$base_check_string, 'p');
|
||||
Notice::note('NOT SAME DAY!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,13 +139,13 @@ trait GrappingSofascore
|
||||
|
||||
$this->speed = $this->ask_speed();
|
||||
|
||||
$this->debug = $this->ask_debug() == 'yes' ? 1 : 0;
|
||||
// $this->debug = $this->ask_debug() == 'yes' ? 1 : 0;
|
||||
|
||||
$daily_way = $this->select_daily_days();
|
||||
|
||||
if ($this->ask_settings_download() == 'yes') {
|
||||
$this->settings_to_local();
|
||||
}
|
||||
// if ($this->ask_settings_download() == 'yes') {
|
||||
// $this->settings_to_local();
|
||||
// }
|
||||
|
||||
switch ($restart) {
|
||||
case 'restart':
|
||||
|
||||
Reference in new issue
Block a user