wip uni file manager

This commit is contained in:
salam committed 2026-10-28 10:06:55 +01:00
1 parent 51e2659a1e
commit 8eaead42e6
9 files changed
+605 -352

No files matched your search

+203 -208
View File
File diff suppressed because it is too large. Load diff
+4 -3
View File
@@ -13,6 +13,7 @@ use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Auth;
use Spatie\Permission\Traits\HasRoles; use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable implements FilamentUser, HasAppAuthentication, HasAppAuthenticationRecovery, HasEmailAuthentication, MustVerifyEmail 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() 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 // Accessor
@@ -195,11 +196,11 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
public function userBookmaker() 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() public static function getUser()
{ {
return User::with('bookmaker')->find(auth()->user()->id); return User::with('bookmaker')->find(Auth::user()->id);
} }
} }
+8
View File
@@ -3,6 +3,7 @@
namespace App\Providers; namespace App\Providers;
use App\Filament\Resources\Events\Pages\ListEvents; use App\Filament\Resources\Events\Pages\ListEvents;
use App\Models\User;
use BezhanSalleh\FilamentShield\Facades\FilamentShield; use BezhanSalleh\FilamentShield\Facades\FilamentShield;
use Carbon\Carbon; use Carbon\Carbon;
use Filament\Notifications\Livewire\Notifications; use Filament\Notifications\Livewire\Notifications;
@@ -17,7 +18,9 @@ use Filament\Support\Facades\FilamentTimezone;
use Filament\Support\Facades\FilamentView; use Filament\Support\Facades\FilamentView;
use Filament\Tables\View\TablesRenderHook; use Filament\Tables\View\TablesRenderHook;
use Filament\View\PanelsRenderHook; use Filament\View\PanelsRenderHook;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\HtmlString; use Illuminate\Support\HtmlString;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -36,6 +39,11 @@ class AppServiceProvider extends ServiceProvider
*/ */
public function boot(): void public function boot(): void
{ {
Gate::define('manageFileManager', function (User $user): bool {
return Auth::user()->hasRole('super_admin') ?? false;
});
FilamentShield::enforcePolicies(); FilamentShield::enforcePolicies();
FilamentTimezone::set('Europe/Vienna'); FilamentTimezone::set('Europe/Vienna');
@@ -38,6 +38,7 @@ use Joaopaulolndev\FilamentEditProfile\Pages\EditProfilePage;
use Maatwebsite\Excel\Facades\Excel; use Maatwebsite\Excel\Facades\Excel;
use Swis\Filament\Backgrounds\FilamentBackgroundsPlugin; use Swis\Filament\Backgrounds\FilamentBackgroundsPlugin;
use Swis\Filament\Backgrounds\ImageProviders\MyImages; use Swis\Filament\Backgrounds\ImageProviders\MyImages;
use UniFileManager\FilamentFileManager\FilamentFileManagerPlugin;
class AdminPanelProvider extends PanelProvider class AdminPanelProvider extends PanelProvider
{ {
@@ -51,6 +52,13 @@ class AdminPanelProvider extends PanelProvider
RecordUserActivity::class, RecordUserActivity::class,
]) ])
->userMenuItems([ ->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') ExportAction::make('download_betfair')
->columnMapping(false) ->columnMapping(false)
->exporter(BetfairExporter::class) ->exporter(BetfairExporter::class)
@@ -180,6 +188,12 @@ class AdminPanelProvider extends PanelProvider
->authMiddleware([ ->authMiddleware([
Authenticate::class, Authenticate::class,
])->plugins([ ])->plugins([
FilamentFileManagerPlugin::make()
->navigationLabel('Files')
// ->navigationGroup('Data')
->navigationSort(10)
->navigationIcon('heroicon-o-folder'),
// ->shouldRegisterNavigation(fn (): bool => Auth::user()->hasRole('super_admin') ?? false),
FilamentShieldPlugin::make() FilamentShieldPlugin::make()
->navigationGroup('User') ->navigationGroup('User')
->navigationSort(10) ->navigationSort(10)
+151 -134
View File
@@ -12,6 +12,9 @@ trait GrappingEvent
{ {
protected function get_event(string $day, array $tournament) protected function get_event(string $day, array $tournament)
{ {
$targetDate = Carbon::parse($day);
foreach ($this->day_tournaments as $day_tournament) { foreach ($this->day_tournaments as $day_tournament) {
if ($day_tournament->tournament_id == $tournament['sofa_score_tournament_id']) { if ($day_tournament->tournament_id == $tournament['sofa_score_tournament_id']) {
@@ -36,153 +39,167 @@ trait GrappingEvent
foreach ($data['events'] as $event) { 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']; $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 (! $res) {
if ($this->debug) {
Notice::note('DB - Allready grapped at '.$day.' - '.$event['homeTeam']['name'].' vs '.$event['awayTeam']['name'], 'b'); $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 { } else {
if ($this->debug) { 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 { } else {
// not same day!
if ($this->debug) { if ($this->debug) {
Notice::note('allready in db event grapped: '.$base_check_string, 'p'); Notice::note('NOT SAME DAY!');
} }
} }
} }
+4 -4
View File
@@ -139,13 +139,13 @@ trait GrappingSofascore
$this->speed = $this->ask_speed(); $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(); $daily_way = $this->select_daily_days();
if ($this->ask_settings_download() == 'yes') { // if ($this->ask_settings_download() == 'yes') {
$this->settings_to_local(); // $this->settings_to_local();
} // }
switch ($restart) { switch ($restart) {
case 'restart': case 'restart':
+5 -2
View File
@@ -27,7 +27,8 @@
"phpoffice/phpspreadsheet": "^5.9", "phpoffice/phpspreadsheet": "^5.9",
"spatie/simple-excel": "^3.9", "spatie/simple-excel": "^3.9",
"stevebauman/location": "*", "stevebauman/location": "*",
"swisnl/filament-backgrounds": "^2.0" "swisnl/filament-backgrounds": "^2.0",
"unifilemanager/filament-file-manager": "^0.8.3"
}, },
"require-dev": { "require-dev": {
"barryvdh/laravel-debugbar": "*", "barryvdh/laravel-debugbar": "*",
@@ -63,7 +64,9 @@
"@php artisan filament:upgrade" "@php artisan filament:upgrade"
], ],
"post-update-cmd": [ "post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force" "@php artisan vendor:publish --tag=laravel-assets --ansi --force",
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"@php artisan ide-helper:generate"
], ],
"post-root-package-install": [ "post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
Generated
+120 -1
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "94233135ac6f53ec89f00776ca67026d", "content-hash": "9752215d2039a55dc411f96b0ac6c484",
"packages": [ "packages": [
{ {
"name": "agencetwogether/hookshelper", "name": "agencetwogether/hookshelper",
@@ -10401,6 +10401,125 @@
], ],
"time": "2026-10-19T10:48:00+00:00" "time": "2026-10-19T10:48:00+00:00"
}, },
{
"name": "unifilemanager/core",
"version": "v0.1.5",
"source": {
"type": "git",
"url": "https://github.com/UniFileManager/core.git",
"reference": "57b95b981515e5bc243fd4229e8fd9268a6023e8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/UniFileManager/core/zipball/57b95b981515e5bc243fd4229e8fd9268a6023e8",
"reference": "57b95b981515e5bc243fd4229e8fd9268a6023e8",
"shasum": ""
},
"require": {
"illuminate/contracts": "^11.0|^12.0|^13.0",
"illuminate/filesystem": "^11.0|^12.0|^13.0",
"php": "^8.2",
"symfony/http-foundation": "^7.0|^8.0",
"symfony/http-kernel": "^7.0|^8.0",
"symfony/mime": "^7.0|^8.0"
},
"require-dev": {
"laravel/pint": "^1.24",
"orchestra/testbench": "^9.0|^10.0|^11.0",
"pestphp/pest": "^3.0|^4.0",
"pestphp/pest-plugin-laravel": "^3.0|^4.0"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"UniFileManager\\Core\\UniFileManagerServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"UniFileManager\\Core\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Sampath Arachchige",
"role": "Maintainer"
}
],
"description": "Shared file management services for UniFileManager adapters.",
"support": {
"issues": "https://github.com/UniFileManager/core/issues",
"source": "https://github.com/UniFileManager/core/tree/v0.1.5"
},
"time": "2026-09-27T21:11:14+00:00"
},
{
"name": "unifilemanager/filament-file-manager",
"version": "v0.8.3",
"source": {
"type": "git",
"url": "https://github.com/UniFileManager/filament-file-manager.git",
"reference": "0a472f1909a2ce7f36111cd199007aae7026b698"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/UniFileManager/filament-file-manager/zipball/0a472f1909a2ce7f36111cd199007aae7026b698",
"reference": "0a472f1909a2ce7f36111cd199007aae7026b698",
"shasum": ""
},
"require": {
"filament/filament": "^4.0|^5.0",
"illuminate/contracts": "^11.0|^12.0|^13.0",
"illuminate/filesystem": "^11.0|^12.0|^13.0",
"livewire/livewire": "^3.0|^4.0",
"php": "^8.2",
"unifilemanager/core": ">=0.1.5 <1.0.0"
},
"require-dev": {
"laravel/pint": "^1.24",
"orchestra/testbench": "^9.0|^10.0|^11.0",
"pestphp/pest": "^3.0|^4.0",
"pestphp/pest-plugin-laravel": "^3.0|^4.0"
},
"suggest": {
"spatie/laravel-medialibrary": "Required when using UniFilePicker::collection() to sync selections into Spatie media-library collections."
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"UniFileManager\\FilamentFileManager\\FilamentFileManagerServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"UniFileManager\\FilamentFileManager\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Sampath Arachchige",
"role": "Maintainer"
}
],
"description": "A secure, disk-scoped file manager and file picker for Laravel Filament.",
"support": {
"issues": "https://github.com/UniFileManager/filament-file-manager/issues",
"source": "https://github.com/UniFileManager/filament-file-manager/tree/v0.8.3"
},
"time": "2026-09-27T22:29:52+00:00"
},
{ {
"name": "vlucas/phpdotenv", "name": "vlucas/phpdotenv",
"version": "v5.7.0", "version": "v5.7.0",
+96
View File
@@ -0,0 +1,96 @@
<?php
declare(strict_types=1);
use UniFileManager\Core\Support\DefaultFileManagerAuthorizer;
use UniFileManager\Core\Support\ConfigStorageAreaResolver;
return [
/* @deprecated Use storage_areas.private.disk. */
'disk' => env('FILAMENT_FILE_MANAGER_DISK', 'local'),
/* @deprecated Use storage_areas.private.root. */
'root' => env('FILAMENT_FILE_MANAGER_ROOT', 'file-manager'),
/* @deprecated Use storage_areas.private.visibility. */
'visibility' => 'private',
/*
* Storage areas are defined on the server. The browser can select an area
* by key, but it can never provide a disk, root, or visibility value.
* Keep public media disabled until you have configured a public disk or CDN.
*/
'storage_areas' => [
'private' => [
'enabled' => true,
'label' => 'Private files',
'disk' => env('FILAMENT_FILE_MANAGER_DISK', 'local'),
'root' => env('FILAMENT_FILE_MANAGER_ROOT', 'file-manager'),
'visibility' => 'private',
],
'public' => [
'enabled' => false,
'label' => 'Public media',
'disk' => env('FILAMENT_FILE_MANAGER_PUBLIC_DISK', 'public'),
'root' => env('FILAMENT_FILE_MANAGER_PUBLIC_ROOT', 'file-manager-public'),
'visibility' => 'public',
],
],
/*
* Resolve storage areas from trusted, server-side request context. Leave the
* default resolver in place for standard single-tenant applications.
*/
'storage_area_resolver' => ConfigStorageAreaResolver::class,
/* Used by UniFilePicker when more than one area is enabled. Private is the safer default. */
'file_picker_default_area' => 'private',
'max_upload_size' => 10 * 1024, // KiB
'max_upload_files' => 10,
/* Enable the embedded File Picker library. Fields can override this with ->library(false). */
'file_picker_library' => true,
/* Legacy File Picker manager URL metadata. Set this only for integrations that need it. */
'file_picker_manager_url' => null,
'folders_per_page' => 10,
'files_per_page' => 10,
'items_per_page' => 20,
/* Maximum nested folder levels below the configured File Manager root. */
'max_directory_depth' => 7,
/* Show the optional "Folders first" layout choice. When disabled, all items stay together. */
'show_item_layout' => false,
'allowed_mimes' => [
'image/jpeg', 'image/png', 'image/webp', 'image/gif', 'application/pdf',
'text/plain', 'text/csv', 'application/msword',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
],
'allowed_extensions' => ['jpg', 'jpeg', 'png', 'webp', 'gif', 'pdf', 'txt', 'csv', 'doc', 'docx', 'xls', 'xlsx'],
'preview_mimes' => ['image/jpeg', 'image/png', 'image/webp', 'image/gif', 'application/pdf', 'text/plain'],
/* Maximum authorised preview and thumbnail requests per minute, per user or guest IP address. */
'preview_rate_limit' => 60,
'thumbnails' => [
'enabled' => true,
'directory' => '.thumbnails',
'max_dimension' => 360,
/* Skip synchronous thumbnail generation for larger source images. */
'max_source_pixels' => 8_000_000,
],
/* Replace this with an application-specific authorizer before exposing the page. */
'authorizer' => DefaultFileManagerAuthorizer::class,
];