country wip

This commit is contained in:
salam committed 2025-08-14 16:05:36 +02:00
1 parent 7396b40114
commit 97fa1202f0
21 files changed
+757 -3

No files matched your search

@@ -0,0 +1,83 @@
<?php
namespace App\Filament\Resources\Countries;
use App\Filament\Resources\Countries\Pages\ManageCountries;
use App\Models\Country;
use BackedEnum;
use Filament\Actions\EditAction;
use Filament\Forms\Components\TextInput;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Enums\IconSize;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use UnitEnum;
class CountryResource extends Resource
{
protected static ?string $model = Country::class;
// protected static bool $shouldSkipAuthorization = true;
protected static string|BackedEnum|null $navigationIcon = 'lucide-flag';
protected static ?string $recordTitleAttribute = 'name';
protected static ?string $navigationLabel = 'Countries';
protected static ?string $pluralLabel = 'Countries';
protected static string|UnitEnum|null $navigationGroup = 'Administration';
public static function form(Schema $schema): Schema
{
return $schema
->components([
TextInput::make('name')
->required()
->maxLength(255),
TextInput::make('iso2')
->required()
->maxLength(2),
]);
}
public static function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->description('Flags made from iso2 column')
->columns([
IconColumn::make('iso2')->icon(function ($record): string {
return 'flag-country-'.$record->iso2;
})->label('Flags')->size(IconSize::TwoExtraLarge),
TextColumn::make('name')->searchable(),
// TextColumn::make('iso2'),
TextColumn::make('iso3'),
TextColumn::make('cc'),
TextColumn::make('numeric'),
TextColumn::make('txid'),
])
->filters([
//
])
->recordActions([
EditAction::make(),
]);
}
public static function getNavigationBadge(): ?string
{
return parent::getEloquentQuery()->count();
}
public static function getPages(): array
{
return [
'index' => ManageCountries::route('/'),
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Countries\Pages;
use App\Filament\Resources\Countries\CountryResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ManageRecords;
class ManageCountries extends ManageRecords
{
protected static string $resource = CountryResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
+19
View File
@@ -0,0 +1,19 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Country extends Model
{
protected $table = 'countries';
protected $primaryKey = 'cc';
public $incrementing = false;
public function ligas()
{
return $this->hasMany(Liga::class, 'cc', 'cc');
}
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Customer extends Model
{
//
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Country;
use Illuminate\Auth\Access\HandlesAuthorization;
class CountryPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_countries::country');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Country $country): bool
{
return $user->can('view_countries::country');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_countries::country');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Country $country): bool
{
return $user->can('update_countries::country');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Country $country): bool
{
return $user->can('delete_countries::country');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_countries::country');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Country $country): bool
{
return $user->can('force_delete_countries::country');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_countries::country');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Country $country): bool
{
return $user->can('restore_countries::country');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_countries::country');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Country $country): bool
{
return $user->can('replicate_countries::country');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_countries::country');
}
}
@@ -26,6 +26,7 @@ use Illuminate\View\Middleware\ShareErrorsFromSession;
use Joaopaulolndev\FilamentEditProfile\FilamentEditProfilePlugin; use Joaopaulolndev\FilamentEditProfile\FilamentEditProfilePlugin;
use Joaopaulolndev\FilamentEditProfile\Pages\EditProfilePage; use Joaopaulolndev\FilamentEditProfile\Pages\EditProfilePage;
use Swis\Filament\Backgrounds\FilamentBackgroundsPlugin; use Swis\Filament\Backgrounds\FilamentBackgroundsPlugin;
use Swis\Filament\Backgrounds\ImageProviders\MyImages;
class AdminPanelProvider extends PanelProvider class AdminPanelProvider extends PanelProvider
{ {
@@ -82,7 +83,8 @@ class AdminPanelProvider extends PanelProvider
])->plugins([ ])->plugins([
FilamentEditProfilePlugin::make()->shouldRegisterNavigation(false), FilamentEditProfilePlugin::make()->shouldRegisterNavigation(false),
LightSwitchPlugin::make()->position(Alignment::BottomCenter), LightSwitchPlugin::make()->position(Alignment::BottomCenter),
FilamentBackgroundsPlugin::make(), FilamentBackgroundsPlugin::make()
->imageProvider(MyImages::make()->directory('images/backgrounds')),
]); ]);
} }
} }
+118
View File
@@ -0,0 +1,118 @@
<?php
namespace App\Utilities;
class Curl
{
public static function load($url, $debug = 0)
{
BetsapiCounter::count($debug);
if ($debug) {
Notice::note($url, 'g');
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
$data = curl_exec($ch);
$curl_errorno = curl_errno($ch);
if ($curl_errorno) {
Notice::note('curl_errorno: '.self::curlerrorcode($curl_errorno));
}
curl_close($ch);
return json_decode($data, true);
}
public static function curlerrorcode($id)
{
$error_codes = [
1 => 'CURLE_UNSUPPORTED_PROTOCOL',
2 => 'CURLE_FAILED_INIT',
3 => 'CURLE_URL_MALFORMAT',
4 => 'CURLE_URL_MALFORMAT_USER',
5 => 'CURLE_COULDNT_RESOLVE_PROXY',
6 => 'CURLE_COULDNT_RESOLVE_HOST',
7 => 'CURLE_COULDNT_CONNECT',
8 => 'CURLE_FTP_WEIRD_SERVER_REPLY',
9 => 'CURLE_REMOTE_ACCESS_DENIED',
11 => 'CURLE_FTP_WEIRD_PASS_REPLY',
13 => 'CURLE_FTP_WEIRD_PASV_REPLY',
14 => 'CURLE_FTP_WEIRD_227_FORMAT',
15 => 'CURLE_FTP_CANT_GET_HOST',
17 => 'CURLE_FTP_COULDNT_SET_TYPE',
18 => 'CURLE_PARTIAL_FILE',
19 => 'CURLE_FTP_COULDNT_RETR_FILE',
21 => 'CURLE_QUOTE_ERROR',
22 => 'CURLE_HTTP_RETURNED_ERROR',
23 => 'CURLE_WRITE_ERROR',
25 => 'CURLE_UPLOAD_FAILED',
26 => 'CURLE_READ_ERROR',
27 => 'CURLE_OUT_OF_MEMORY',
28 => 'CURLE_OPERATION_TIMEDOUT',
30 => 'CURLE_FTP_PORT_FAILED',
31 => 'CURLE_FTP_COULDNT_USE_REST',
33 => 'CURLE_RANGE_ERROR',
34 => 'CURLE_HTTP_POST_ERROR',
35 => 'CURLE_SSL_CONNECT_ERROR',
36 => 'CURLE_BAD_DOWNLOAD_RESUME',
37 => 'CURLE_FILE_COULDNT_READ_FILE',
38 => 'CURLE_LDAP_CANNOT_BIND',
39 => 'CURLE_LDAP_SEARCH_FAILED',
41 => 'CURLE_FUNCTION_NOT_FOUND',
42 => 'CURLE_ABORTED_BY_CALLBACK',
43 => 'CURLE_BAD_FUNCTION_ARGUMENT',
45 => 'CURLE_INTERFACE_FAILED',
47 => 'CURLE_TOO_MANY_REDIRECTS',
48 => 'CURLE_UNKNOWN_TELNET_OPTION',
49 => 'CURLE_TELNET_OPTION_SYNTAX',
51 => 'CURLE_PEER_FAILED_VERIFICATION',
52 => 'CURLE_GOT_NOTHING',
53 => 'CURLE_SSL_ENGINE_NOTFOUND',
54 => 'CURLE_SSL_ENGINE_SETFAILED',
55 => 'CURLE_SEND_ERROR',
56 => 'CURLE_RECV_ERROR',
58 => 'CURLE_SSL_CERTPROBLEM',
59 => 'CURLE_SSL_CIPHER',
60 => 'CURLE_SSL_CACERT',
61 => 'CURLE_BAD_CONTENT_ENCODING',
62 => 'CURLE_LDAP_INVALID_URL',
63 => 'CURLE_FILESIZE_EXCEEDED',
64 => 'CURLE_USE_SSL_FAILED',
65 => 'CURLE_SEND_FAIL_REWIND',
66 => 'CURLE_SSL_ENGINE_INITFAILED',
67 => 'CURLE_LOGIN_DENIED',
68 => 'CURLE_TFTP_NOTFOUND',
69 => 'CURLE_TFTP_PERM',
70 => 'CURLE_REMOTE_DISK_FULL',
71 => 'CURLE_TFTP_ILLEGAL',
72 => 'CURLE_TFTP_UNKNOWNID',
73 => 'CURLE_REMOTE_FILE_EXISTS',
74 => 'CURLE_TFTP_NOSUCHUSER',
75 => 'CURLE_CONV_FAILED',
76 => 'CURLE_CONV_REQD',
77 => 'CURLE_SSL_CACERT_BADFILE',
78 => 'CURLE_REMOTE_FILE_NOT_FOUND',
79 => 'CURLE_SSH',
80 => 'CURLE_SSL_SHUTDOWN_FAILED',
81 => 'CURLE_AGAIN',
82 => 'CURLE_SSL_CRL_BADFILE',
83 => 'CURLE_SSL_ISSUER_ERROR',
84 => 'CURLE_FTP_PRET_FAILED',
84 => 'CURLE_FTP_PRET_FAILED',
85 => 'CURLE_RTSP_CSEQ_ERROR',
86 => 'CURLE_RTSP_SESSION_ERROR',
87 => 'CURLE_FTP_BAD_FILE_LIST',
88 => 'CURLE_CHUNK_FAILED',
89 => 'CURLE_NO_CONNECTION_AVAILABLE',
90 => 'CURLE_SSL_PINNEDPUBKEYNOTMATCH',
91 => 'CURLE_SSL_INVALIDCERTSTATUS',
92 => 'CURLE_HTTP2_STREAM',
];
return $error_codes[$id];
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace App\Utilities;
use Exception;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
class Guzzle
{
public static function load($url, $debug = 0)
{
BetsapiCounter::count($debug);
if ($debug) {
Notice::note($url, 'g');
}
$data = Http::retry(3, 2, function (Exception $exception, PendingRequest $request) {
return $exception instanceof ConnectionException;
})->get($url);
return json_decode($data, true);
}
}
+55
View File
@@ -0,0 +1,55 @@
<?php
namespace App\Utilities;
class Html
{
public static function table_header_90($_row)
{
$html = '<thead><tr text-rotate="90deg">';
$mm = 190 / \count($_row);
foreach ($_row as $value) {
$html .= '<td class="head right bl bt br bb" style="background-color:#d1d1d1; width: '.$mm.'mm;">'.$value.'</td>';
}
$html .= '</tr></thead>';
return $html;
}
public static function make_table($str)
{
$array = explode('<br />', $str);
$html = '<table class="table-striped bt bl">';
foreach ($array as $value) {
$tmp = explode('|', $value);
$html .= '<tr>';
$html .= self::td($tmp[0], 'br bb');
$html .= self::td($tmp[1], 'br bb');
$html .= '</tr>';
}
$html .= '</table>';
return $html;
}
public static function td($value = '', $classname = '', $colspan = 0)
{
$cls = $classname != '' ? ' class="'.$classname.'"' : '';
$spn = $colspan != '' ? ' colspan="'.$colspan.'"' : '';
return "<td $cls $spn>".$value.'</td>';
}
public static function tag($tag = 'div', $value = '', $class = '', $style = '')
{
$str1 = $class != '' ? ' class="'.$class.'"' : '';
$str2 = $style != '' ? ' style="'.$style.'"' : '';
return "<$tag $str1 $str2>".$value."</$tag>";
}
public static function end($value = 'div')
{
return "</$value>";
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Utilities;
use Illuminate\Support\Facades\Storage;
class Lastcall
{
public static function load($file)
{
$lastcall = (int) Storage::disk('local')->get($file);
if ($lastcall < time() - 30) {
$lastcall = time() - 30;
}
Storage::disk('local')->put($file, time());
return trim($lastcall);
}
}
+98
View File
@@ -0,0 +1,98 @@
<?php
namespace App\Utilities;
class Notice
{
// note
public static function note($message, $color = '', $exit = false)
{
switch ($color) {
case 'g':
// green
echo "\e[0;32m";
break;
case 'gb':
case 'bg':
// bold green
echo "\e[1;32m";
break;
case 'r':
// red
echo "\e[0;31m";
break;
case 'br':
case 'rb':
// bold red
echo "\e[1;31m";
break;
case 'b':
// blue
echo "\e[0;34m";
break;
case 'bb':
// bold blue
echo "\e[1;34m";
break;
case 'y':
// yellow
echo "\e[0;33m";
break;
case 'p':
// purple
echo "\e[0;35m";
break;
case 'c':
// cyan
echo "\e[0;36m";
break;
case 'bi':
// blue intence
echo "\e[38;5;33m\n";
break;
default:
echo "\e[0;39m";
break;
}
echo PHP_EOL.'-----------------------------------------------------------'.PHP_EOL;
if (is_array($message)) {
print_r($message);
} else {
echo $message.PHP_EOL;
}
echo '-----------------------------------------------------------'.PHP_EOL;
echo "\e[0;39m";
if ($exit) {
exit();
}
}
public static function html($message, $color = '', $exit = false)
{
switch ($color) {
case 'g':
echo '<div style="margin:10px; padding:3px; color:green; width=20rem; text-align:center; border:solid 1px green; background-color:lightgreen;">';
break;
case 'r':
echo '<div style="margin:10px; padding:3px; color:red; width=20rem; text-align:center; border:solid 1px red; background-color:#fdd;">';
break;
case 'b':
echo '<div style="margin:10px; padding:3px; color:blue; width=20rem; text-align:center; border:solid 1px blue; background-color:lightblue;">';
break;
default:
echo '<div style="margin:10px; padding:3px; color:black; width=20rem; text-align:center; border:solid 1px black; background-color:#eee;">';
break;
}
if (is_array($message)) {
print_r($message);
} else {
echo $message;
}
echo '</div>';
if ($exit) {
exit();
}
}
}
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace App\Utilities;
use App\Models\Comparatore;
use App\Models\EventCustomer;
class NuhHash
{
public static function md5($data)
{
if (is_array($data)) {
$data = serialize($data);
}
return hash('md5', $data, false);
}
public static function comparatore_all($options)
{
$res = Comparatore::select('event_id', 'hash', 'updated_at')->where('sport_id', $options['sport_id'])->where('customer_id', $options['customer_id'])->get();
$_hash = [];
foreach ($res as $value) {
$event_id = $value['event_id'];
$_hash[$event_id] = ['hash' => $value['hash'], 'timestamp' => strtotime($value['updated_at'])];
}
return $_hash;
}
public static function load_event($options)
{
$res = EventCustomer::select('calculation_hash')->where('event_id', $options['event_id'])->where('customer_id', $options['customer_id'])->first();
if ($res) {
return $res->calculation_hash;
}
return false;
}
}
+57
View File
@@ -0,0 +1,57 @@
<?php
namespace App\Utilities;
use App\Models\Supervisor;
class Supervisorctl
{
public static $starttime = 0;
public static $code = '';
public static $events = 0;
public static function start(&$options)
{
$debug = $options['d'] ?? 0;
// sleep 1 sec to avoid error in supervisor
sleep(1);
self::$starttime = microtime(true);
self::$code = $options['code'];
$supervisor = Supervisor::where('code', self::$code)->get()->first();
// if process can be called only from bash
if ($supervisor) {
$options['sport_id'] = $supervisor->sport_id;
$options['customer_id'] = $supervisor->customer_id;
$options['limit'] = $supervisor->limit;
if ($debug) {
Notice::note('supervisor start '.self::$code, 'g');
}
if ($supervisor->sleep > 0) {
if (! $debug) {
sleep($supervisor->sleep);
}
}
} else {
Notice::note('unknown supervisor: '.$options['code'], 'r', 1);
}
}
public static function end($options)
{
$processend = microtime(true);
$runtime = round(($processend - self::$starttime) / 60, 3);
Supervisor::where('code', self::$code)->update(['runtime' => $runtime, 'events' => self::$events]);
if ($options['d']) {
Notice::note('spervisor time: '.$runtime.' min', 'g');
}
}
}
+5 -1
View File
@@ -3,7 +3,10 @@
"name": "laravel/laravel", "name": "laravel/laravel",
"type": "project", "type": "project",
"description": "The skeleton application for the Laravel framework.", "description": "The skeleton application for the Laravel framework.",
"keywords": ["laravel", "framework"], "keywords": [
"laravel",
"framework"
],
"license": "MIT", "license": "MIT",
"require": { "require": {
"php": "^8.2", "php": "^8.2",
@@ -14,6 +17,7 @@
"joaopaulolndev/filament-edit-profile": "^2.0", "joaopaulolndev/filament-edit-profile": "^2.0",
"laravel/framework": "^12.0", "laravel/framework": "^12.0",
"laravel/tinker": "^2.10.1", "laravel/tinker": "^2.10.1",
"outhebox/blade-flags": "^1.5",
"swisnl/filament-backgrounds": "^2.0" "swisnl/filament-backgrounds": "^2.0"
}, },
"require-dev": { "require-dev": {
Generated
+69 -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": "f578fc908c365c7a948798b1f927c90c", "content-hash": "bf7c6af5121fc67fc2955b0a58026eae",
"packages": [ "packages": [
{ {
"name": "anourvalar/eloquent-serialize", "name": "anourvalar/eloquent-serialize",
@@ -4526,6 +4526,74 @@
], ],
"time": "2025-07-07T06:15:55+00:00" "time": "2025-07-07T06:15:55+00:00"
}, },
{
"name": "outhebox/blade-flags",
"version": "1.5.3",
"source": {
"type": "git",
"url": "https://github.com/MohmmedAshraf/blade-flags.git",
"reference": "84d37c6c44e5509412c894a90ecdad737b96488f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MohmmedAshraf/blade-flags/zipball/84d37c6c44e5509412c894a90ecdad737b96488f",
"reference": "84d37c6c44e5509412c894a90ecdad737b96488f",
"shasum": ""
},
"require": {
"blade-ui-kit/blade-icons": "^1.1",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0",
"php": "^7.4|^8.0|^8.1|^8.2"
},
"require-dev": {
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0|^10.0",
"phpunit/phpunit": "^9.0|^10.5|^11.5.3"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"OutheBox\\BladeFlags\\BladeFlagsServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"OutheBox\\BladeFlags\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mohamed Ashraf",
"email": "cupo.ashraf@gmail.com",
"homepage": "https://github.com/MohmmedAshraf"
}
],
"description": "A package to easily make use of country & language flags in your Laravel Blade views.",
"homepage": "https://github.com/MohmmedAshraf/blade-flags",
"keywords": [
"blade",
"country flags",
"flags",
"language flags",
"laravel"
],
"support": {
"issues": "https://github.com/MohmmedAshraf/blade-flags/issues",
"source": "https://github.com/MohmmedAshraf/blade-flags/tree/1.5.3"
},
"funding": [
{
"url": "https://github.com/MohmmedAshraf",
"type": "github"
}
],
"time": "2025-02-24T15:04:52+00:00"
},
{ {
"name": "paragonie/constant_time_encoding", "name": "paragonie/constant_time_encoding",
"version": "v3.0.0", "version": "v3.0.0",
@@ -0,0 +1,27 @@
<?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('customers', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('customers');
}
};
Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB