fix policies

This commit is contained in:
salam committed 2026-07-12 12:35:52 +02:00
1 parent 109907d1f3
commit f8e6f8183b
10 files changed
+317 -276

No files matched your search

@@ -8,16 +8,29 @@ use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays;
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper;
use App\Console\Commands\Nuh;
use App\Models\SofaScoreDayTournament;
use App\Models\SofaScoreEventGrapped;
use App\Models\SofaScoreTaskTournament;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\File;
class Grapper
{
public static function load()
{
/**
* yesterday
*
* nuh --d --f 67 --fun=6 --task=1
*
* 1783710000
* 10 July 2026 09:00:00 PM CEST
*/
$debug = Nuh::$options['d'] ?? 0;
$force = Nuh::$options['f'] ?? 0;
$task_id = Nuh::$options['task'] ?? 0;
$days = LoadDays::load();
@@ -49,7 +62,7 @@ class Grapper
$data = CurlSofa::load($url);
dd($data);
// dd($data);
Nuh::$options['s'] = 0;
@@ -59,9 +72,14 @@ class Grapper
foreach ($data['events'] as $event) {
dd($event);
$now = Carbon::now()->subHours(4);
$starttime = Carbon::createFromTimestamp($event->startTimestamp);
// "hasEventPlayerStatistics" => true
if ($now->greaterThan($starttime)) {
$event_grapped = SofaScoreEventGrapped::where('id', $event['id'])->first();
$event_grapped['name'] = $event->homeTeam['name'] . ' vs ' . $event->awayTeam['name'];
$event_grapped['url'] = $url;
$folder = Sofascore::$grapper_path . $day . '/' . $event['tournament']['slug'] . '/' . $event['slug'];
@@ -79,7 +97,7 @@ class Grapper
$event_id = $event['id'];
if (!File::exists($folder . '/statistics.json')) {
if ($force || !$event_grapped['got_statistics'] && $event->hasEventPlayerStatistics) {
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/statistics";
@@ -90,13 +108,15 @@ class Grapper
$data['id'] = $event_id;
File::put($folder . '/statistics.json', json_encode($data));
$event_grapped['got_statistics'] = 1;
}
/*********************************
* EVENT lineups
*********************************/
if (!File::exists($folder . '/lineups.json')) {
if ($force || !$event_grapped['got_lineups']) {
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/lineups";
@@ -107,13 +127,15 @@ class Grapper
$data['id'] = $event_id;
File::put($folder . '/lineups.json', json_encode($data));
$event_grapped['got_lineups'] = 1;
}
/*********************************
* EVENT odds
*********************************/
if (!File::exists($folder . '/odds.json')) {
if ($force || !$event_grapped['got_odds']) {
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/odds/1/all";
@@ -124,13 +146,15 @@ class Grapper
$data['id'] = $event_id;
File::put($folder . '/odds.json', json_encode($data));
$event_grapped['got_odds'] = 1;
}
/*********************************
* EVENT incidents
*********************************/
if (!File::exists($folder . '/incidents.json')) {
if ($force || !$event_grapped['got_incidents']) {
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/incidents";
@@ -141,6 +165,9 @@ class Grapper
$data['id'] = $event_id;
File::put($folder . '/incidents.json', json_encode($data));
$event_grapped['got_incidents'] = 1;
}
}
}
}
+6 -1
View File
@@ -7,8 +7,13 @@ use Illuminate\Database\Eloquent\Model;
class SofaScoreEventGrapped extends Model
{
protected $fillable = [
'event_id',
'id',
'name',
'url',
'starttime',
'got_statistics',
'got_lineups',
'got_odds',
'got_incidents',
];
}
+38 -38
View File
@@ -2,65 +2,65 @@
namespace App\Policies;
use App\Models\SofaScoreTask;
use App\Models\User;
use Illuminate\Auth\Access\Response;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Foundation\Auth\User as AuthUser;
class SofaScoreTaskPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
use HandlesAuthorization;
public function viewAny(AuthUser $authUser): bool
{
return false;
return $authUser->can('ViewAny:SofaScoreTask');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, SofaScoreTask $sofaScoreTask): bool
public function view(AuthUser $authUser): bool
{
return false;
return $authUser->can('View:SofaScoreTask');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
public function create(AuthUser $authUser): bool
{
return false;
return $authUser->can('Create:SofaScoreTask');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, SofaScoreTask $sofaScoreTask): bool
public function update(AuthUser $authUser): bool
{
return false;
return $authUser->can('Update:SofaScoreTask');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, SofaScoreTask $sofaScoreTask): bool
public function delete(AuthUser $authUser): bool
{
return false;
return $authUser->can('Delete:SofaScoreTask');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, SofaScoreTask $sofaScoreTask): bool
public function restore(AuthUser $authUser): bool
{
return false;
return $authUser->can('Restore:SofaScoreTask');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, SofaScoreTask $sofaScoreTask): bool
public function forceDelete(AuthUser $authUser): bool
{
return false;
return $authUser->can('ForceDelete:SofaScoreTask');
}
public function forceDeleteAny(AuthUser $authUser): bool
{
return $authUser->can('ForceDeleteAny:SofaScoreTask');
}
public function restoreAny(AuthUser $authUser): bool
{
return $authUser->can('RestoreAny:SofaScoreTask');
}
public function replicate(AuthUser $authUser): bool
{
return $authUser->can('Replicate:SofaScoreTask');
}
public function reorder(AuthUser $authUser): bool
{
return $authUser->can('Reorder:SofaScoreTask');
}
}
+38 -38
View File
@@ -2,65 +2,65 @@
namespace App\Policies;
use App\Models\SofaScoreTournament;
use App\Models\User;
use Illuminate\Auth\Access\Response;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Foundation\Auth\User as AuthUser;
class SofaScoreTournamentPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
use HandlesAuthorization;
public function viewAny(AuthUser $authUser): bool
{
return false;
return $authUser->can('ViewAny:SofaScoreTournament');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, SofaScoreTournament $sofaScoreTournament): bool
public function view(AuthUser $authUser): bool
{
return false;
return $authUser->can('View:SofaScoreTournament');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
public function create(AuthUser $authUser): bool
{
return false;
return $authUser->can('Create:SofaScoreTournament');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, SofaScoreTournament $sofaScoreTournament): bool
public function update(AuthUser $authUser): bool
{
return false;
return $authUser->can('Update:SofaScoreTournament');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, SofaScoreTournament $sofaScoreTournament): bool
public function delete(AuthUser $authUser): bool
{
return false;
return $authUser->can('Delete:SofaScoreTournament');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, SofaScoreTournament $sofaScoreTournament): bool
public function restore(AuthUser $authUser): bool
{
return false;
return $authUser->can('Restore:SofaScoreTournament');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, SofaScoreTournament $sofaScoreTournament): bool
public function forceDelete(AuthUser $authUser): bool
{
return false;
return $authUser->can('ForceDelete:SofaScoreTournament');
}
public function forceDeleteAny(AuthUser $authUser): bool
{
return $authUser->can('ForceDeleteAny:SofaScoreTournament');
}
public function restoreAny(AuthUser $authUser): bool
{
return $authUser->can('RestoreAny:SofaScoreTournament');
}
public function replicate(AuthUser $authUser): bool
{
return $authUser->can('Replicate:SofaScoreTournament');
}
public function reorder(AuthUser $authUser): bool
{
return $authUser->can('Reorder:SofaScoreTournament');
}
}
+39 -38
View File
@@ -2,65 +2,66 @@
namespace App\Policies;
use App\Models\StatisticFixtures;
use App\Models\User;
use Illuminate\Auth\Access\Response;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Foundation\Auth\User as AuthUser;
class StatisticFixturesPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
use HandlesAuthorization;
public function viewAny(AuthUser $authUser): bool
{
return false;
return $authUser->can('ViewAny:StatisticFixtures');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, StatisticFixtures $statisticFixtures): bool
public function view(AuthUser $authUser): bool
{
return false;
return $authUser->can('View:StatisticFixtures');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
public function create(AuthUser $authUser): bool
{
return false;
return $authUser->can('Create:StatisticFixtures');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, StatisticFixtures $statisticFixtures): bool
public function update(AuthUser $authUser): bool
{
return false;
return $authUser->can('Update:StatisticFixtures');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, StatisticFixtures $statisticFixtures): bool
public function delete(AuthUser $authUser): bool
{
return false;
return $authUser->can('Delete:StatisticFixtures');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, StatisticFixtures $statisticFixtures): bool
public function restore(AuthUser $authUser): bool
{
return false;
return $authUser->can('Restore:StatisticFixtures');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, StatisticFixtures $statisticFixtures): bool
public function forceDelete(AuthUser $authUser): bool
{
return false;
return $authUser->can('ForceDelete:StatisticFixtures');
}
public function forceDeleteAny(AuthUser $authUser): bool
{
return $authUser->can('ForceDeleteAny:StatisticFixtures');
}
public function restoreAny(AuthUser $authUser): bool
{
return $authUser->can('RestoreAny:StatisticFixtures');
}
public function replicate(AuthUser $authUser): bool
{
return $authUser->can('Replicate:StatisticFixtures');
}
public function reorder(AuthUser $authUser): bool
{
return $authUser->can('Reorder:StatisticFixtures');
}
}
+39 -38
View File
@@ -2,65 +2,66 @@
namespace App\Policies;
use App\Models\StatistikoDetail;
use App\Models\User;
use Illuminate\Auth\Access\Response;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Foundation\Auth\User as AuthUser;
class StatistikoDetailPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
use HandlesAuthorization;
public function viewAny(AuthUser $authUser): bool
{
return false;
return $authUser->can('ViewAny:StatistikoDetail');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, StatistikoDetail $statistikoDetail): bool
public function view(AuthUser $authUser): bool
{
return false;
return $authUser->can('View:StatistikoDetail');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
public function create(AuthUser $authUser): bool
{
return false;
return $authUser->can('Create:StatistikoDetail');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, StatistikoDetail $statistikoDetail): bool
public function update(AuthUser $authUser): bool
{
return false;
return $authUser->can('Update:StatistikoDetail');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, StatistikoDetail $statistikoDetail): bool
public function delete(AuthUser $authUser): bool
{
return false;
return $authUser->can('Delete:StatistikoDetail');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, StatistikoDetail $statistikoDetail): bool
public function restore(AuthUser $authUser): bool
{
return false;
return $authUser->can('Restore:StatistikoDetail');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, StatistikoDetail $statistikoDetail): bool
public function forceDelete(AuthUser $authUser): bool
{
return false;
return $authUser->can('ForceDelete:StatistikoDetail');
}
public function forceDeleteAny(AuthUser $authUser): bool
{
return $authUser->can('ForceDeleteAny:StatistikoDetail');
}
public function restoreAny(AuthUser $authUser): bool
{
return $authUser->can('RestoreAny:StatistikoDetail');
}
public function replicate(AuthUser $authUser): bool
{
return $authUser->can('Replicate:StatistikoDetail');
}
public function reorder(AuthUser $authUser): bool
{
return $authUser->can('Reorder:StatistikoDetail');
}
}
+39 -38
View File
@@ -2,65 +2,66 @@
namespace App\Policies;
use App\Models\StatistikoEvent;
use App\Models\User;
use Illuminate\Auth\Access\Response;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Foundation\Auth\User as AuthUser;
class StatistikoEventPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
use HandlesAuthorization;
public function viewAny(AuthUser $authUser): bool
{
return false;
return $authUser->can('ViewAny:StatistikoEvent');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, StatistikoEvent $statistikoEvent): bool
public function view(AuthUser $authUser): bool
{
return false;
return $authUser->can('View:StatistikoEvent');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
public function create(AuthUser $authUser): bool
{
return false;
return $authUser->can('Create:StatistikoEvent');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, StatistikoEvent $statistikoEvent): bool
public function update(AuthUser $authUser): bool
{
return false;
return $authUser->can('Update:StatistikoEvent');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, StatistikoEvent $statistikoEvent): bool
public function delete(AuthUser $authUser): bool
{
return false;
return $authUser->can('Delete:StatistikoEvent');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, StatistikoEvent $statistikoEvent): bool
public function restore(AuthUser $authUser): bool
{
return false;
return $authUser->can('Restore:StatistikoEvent');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, StatistikoEvent $statistikoEvent): bool
public function forceDelete(AuthUser $authUser): bool
{
return false;
return $authUser->can('ForceDelete:StatistikoEvent');
}
public function forceDeleteAny(AuthUser $authUser): bool
{
return $authUser->can('ForceDeleteAny:StatistikoEvent');
}
public function restoreAny(AuthUser $authUser): bool
{
return $authUser->can('RestoreAny:StatistikoEvent');
}
public function replicate(AuthUser $authUser): bool
{
return $authUser->can('Replicate:StatistikoEvent');
}
public function reorder(AuthUser $authUser): bool
{
return $authUser->can('Reorder:StatistikoEvent');
}
}
+39 -38
View File
@@ -2,65 +2,66 @@
namespace App\Policies;
use App\Models\StatistikoImport;
use App\Models\User;
use Illuminate\Auth\Access\Response;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Foundation\Auth\User as AuthUser;
class StatistikoImportPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
use HandlesAuthorization;
public function viewAny(AuthUser $authUser): bool
{
return false;
return $authUser->can('ViewAny:StatistikoImport');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, StatistikoImport $statistikoImport): bool
public function view(AuthUser $authUser): bool
{
return false;
return $authUser->can('View:StatistikoImport');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
public function create(AuthUser $authUser): bool
{
return false;
return $authUser->can('Create:StatistikoImport');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, StatistikoImport $statistikoImport): bool
public function update(AuthUser $authUser): bool
{
return false;
return $authUser->can('Update:StatistikoImport');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, StatistikoImport $statistikoImport): bool
public function delete(AuthUser $authUser): bool
{
return false;
return $authUser->can('Delete:StatistikoImport');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, StatistikoImport $statistikoImport): bool
public function restore(AuthUser $authUser): bool
{
return false;
return $authUser->can('Restore:StatistikoImport');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, StatistikoImport $statistikoImport): bool
public function forceDelete(AuthUser $authUser): bool
{
return false;
return $authUser->can('ForceDelete:StatistikoImport');
}
public function forceDeleteAny(AuthUser $authUser): bool
{
return $authUser->can('ForceDeleteAny:StatistikoImport');
}
public function restoreAny(AuthUser $authUser): bool
{
return $authUser->can('RestoreAny:StatistikoImport');
}
public function replicate(AuthUser $authUser): bool
{
return $authUser->can('Replicate:StatistikoImport');
}
public function reorder(AuthUser $authUser): bool
{
return $authUser->can('Reorder:StatistikoImport');
}
}
+39 -38
View File
@@ -2,65 +2,66 @@
namespace App\Policies;
use App\Models\StatistikoPlayer;
use App\Models\User;
use Illuminate\Auth\Access\Response;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Foundation\Auth\User as AuthUser;
class StatistikoPlayerPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
use HandlesAuthorization;
public function viewAny(AuthUser $authUser): bool
{
return false;
return $authUser->can('ViewAny:StatistikoPlayer');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, StatistikoPlayer $statistikoPlayer): bool
public function view(AuthUser $authUser): bool
{
return false;
return $authUser->can('View:StatistikoPlayer');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
public function create(AuthUser $authUser): bool
{
return false;
return $authUser->can('Create:StatistikoPlayer');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, StatistikoPlayer $statistikoPlayer): bool
public function update(AuthUser $authUser): bool
{
return false;
return $authUser->can('Update:StatistikoPlayer');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, StatistikoPlayer $statistikoPlayer): bool
public function delete(AuthUser $authUser): bool
{
return false;
return $authUser->can('Delete:StatistikoPlayer');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, StatistikoPlayer $statistikoPlayer): bool
public function restore(AuthUser $authUser): bool
{
return false;
return $authUser->can('Restore:StatistikoPlayer');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, StatistikoPlayer $statistikoPlayer): bool
public function forceDelete(AuthUser $authUser): bool
{
return false;
return $authUser->can('ForceDelete:StatistikoPlayer');
}
public function forceDeleteAny(AuthUser $authUser): bool
{
return $authUser->can('ForceDeleteAny:StatistikoPlayer');
}
public function restoreAny(AuthUser $authUser): bool
{
return $authUser->can('RestoreAny:StatistikoPlayer');
}
public function replicate(AuthUser $authUser): bool
{
return $authUser->can('Replicate:StatistikoPlayer');
}
public function reorder(AuthUser $authUser): bool
{
return $authUser->can('Reorder:StatistikoPlayer');
}
}
@@ -13,9 +13,13 @@ return new class extends Migration
{
Schema::create('sofa_score_event_grappeds', function (Blueprint $table) {
$table->id();
$table->integer('event_id');
$table->string('name');
$table->string('name')->nullable();
$table->string('url')->nullable();
$table->dateTime('starttime')->nullable();
$table->boolean('got_statistics')->default(false);
$table->boolean('got_lineups')->default(false);
$table->boolean('got_odds')->default(false);
$table->boolean('got_incidents')->default(false);
$table->timestamps();
});
}