Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
maj
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcaussades committed Apr 3, 2024
1 parent 6e28c0e commit a2a5175
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 5 deletions.
122 changes: 122 additions & 0 deletions app/Http/Controllers/EventIvaoController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Controllers\whazzupController;
use Illuminate\Support\Facades\Http;

class EventIvaoController extends Controller
{

protected $event;

public function __construct()
{
$sr_env = new whazzupController();
$event = $sr_env->event_ivao();
$this->event = $event;
return $this->event;
}

public function get_event_ivao_world(){
$eventIvaoWorld = [];
for ($i=0; $i < count($this->event) ; $i++) {
$eventIvaoWorld[$i]['startDate'] = date('Y-m-d H:i:s', strtotime($this->event[$i]['startDate']));
$eventIvaoWorld[$i]['endDate'] = date('Y-m-d H:i:s', strtotime($this->event[$i]['endDate']));
$eventIvaoWorld[$i]['title'] = $this->event[$i]['title'];
$eventIvaoWorld[$i]['imageUrl'] = $this->event[$i]['imageUrl'];
$eventIvaoWorld[$i]['description'] = $this->event[$i]['description'];
$eventIvaoWorld[$i]['infoUrl'] = $this->event[$i]['infoUrl'];
$eventIvaoWorld[$i]['divisions'] = $this->event[$i]['divisions'];
$eventIvaoWorld[$i]['airports'] = $this->event[$i]['airports'];

}

return $eventIvaoWorld;

}

public function get_event_ivao_RFE_RFO(){

$rfe = $this->get_event_ivao_world();
$regexpr = '/RFE|RFO/';
$rfe_rfo = [];
for ($i=0; $i < count($rfe) ; $i++) {
if(preg_match($regexpr, $rfe[$i]['title'])){
$rfe_rfo[$i]['startDate'] = $rfe[$i]['startDate'];
$rfe_rfo[$i]['endDate'] = $rfe[$i]['endDate'];
$rfe_rfo[$i]['title'] = $rfe[$i]['title'];
$rfe_rfo[$i]['imageUrl'] = $rfe[$i]['imageUrl'];
$rfe_rfo[$i]['description'] = $rfe[$i]['description'];
$rfe_rfo[$i]['infoUrl'] = $rfe[$i]['infoUrl'];
$rfe_rfo[$i]['divisions'] = $rfe[$i]['divisions'];
$rfe_rfo[$i]['airports'] = $rfe[$i]['airports'];
}
}
$newrfe_rfo = array_values($rfe_rfo);
return $newrfe_rfo;


}

public function get_event_ivao_FR_days(){

$date = date("c");
$mois = date('m');
$year = date('Y');
$date_day = date('d/m/Y');
$event_fr = [];
$envent_fr_search = Http::get("https://www.ivao.fr/fr/api/p/calendar/".$year."-".$mois.".json");
$event_fr = $envent_fr_search->json();
$event_day = [];
foreach ($event_fr[$date_day] as $key => $value) {
$envent_day["type"] = $value['type'];
$envent_day["name"] = $value['name'];
$envent_day["started_at"] = date('Y-m-d H:i:s', strtotime($value['started_at']));
$envent_day["description"] = $value['tooltip_fr'] ?? "Pas de description disponible";
array_push($event_day, $envent_day);
}
return $event_day;
}


public function get_event_ivao_FR_tomorrow(){

$date = date("c");
$mois = date('m');
$year = date('Y');
$date_day = date('d/m/Y');
$event_fr = [];
$envent_fr_search = Http::get("https://www.ivao.fr/fr/api/p/calendar/".$year."-".$mois.".json");
$event_fr = $envent_fr_search->json();
$event_tomorrow = [];
$tomorrow = date('d/m/Y', strtotime('+1 day'));
if(!isset($event_fr[$tomorrow])){
$tomorrow = date('d/m/Y', strtotime('+2 day'));
}
if(!isset($event_fr[$tomorrow])){
$tomorrow = date('d/m/Y', strtotime('+3 day'));
}
foreach ($event_fr[$tomorrow] as $key => $value) {
$envent_tomorrow["type"] = $value['type'];
$envent_tomorrow["name"] = $value['name'];
$envent_tomorrow["started_at"] = date('Y-m-d H:i:s', strtotime($value['started_at']));
$envent_tomorrow["description"] = $value['tooltip_fr'] ?? "Pas de description disponible";
array_push($event_tomorrow, $envent_tomorrow);
}
return $event_tomorrow;
}

public function get_event_ivao_FR(){
$eventIvaoFR = [];
$eventIvaoFR = [
'today' => $this->get_event_ivao_FR_days(),
'tomorrow' => $this->get_event_ivao_FR_tomorrow(),
];
return $eventIvaoFR;
}


}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/asset/img/exam/logo_exam.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/asset/img/online_day/onlineday.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/asset/img/training/traning.webp
Binary file not shown.
34 changes: 34 additions & 0 deletions resources/views/welcome.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,39 @@

@endauth

<hr>
<div class="container mt-2">
<h5>IVAO Event FR</h5>

<div class="row">
@foreach($event_fr as $events)

<div class="col-6 mt-2">
<div class="card text-white bg-dark">
<div class="card-body">
@if ($events[0]["type"] == "training")
@if (ENV('APP_ENV') == 'local')
<img class="card-img-top" src="{{ asset("asset/img/training/traning.webp") }}" alt="">
@else
<img class="card-img-top" src="{{ asset("public/asset/img/training/traning.webp") }}" alt="">
@endif
@endif
@if ($events[0]["type"] == "exam")
@if (ENV('APP_ENV') == 'local')
<img class="card-img-top" style="width: 18vw; center" src="{{ asset("asset/img/exam/logo_exam.jpeg") }}" alt="">
@else
<img class="card-img-top" style="width: 18vw; center" src="{{ asset("public/asset/img/exam/logo_exam.jpeg") }}" alt="">
@endif
@endif
<p class="card-text text-center text-info">{{$events[0]["name"]}}</p>
<p class="card-text text-center ">{{$events[0]["description"]}}</p>
<p class="card-text text-center "> {{$events[0]["started_at"]}} </p>
</div>
</div>
</div>
@endforeach
</div>
</div>


@endsection
22 changes: 17 additions & 5 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\Sleep;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\airac_info;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Http;
Expand All @@ -31,20 +32,20 @@
use App\Http\Controllers\whazzupController;
use App\Http\Controllers\AutAdminController;
use App\Http\Controllers\AuthIVAOController;
use App\Http\Controllers\CarteSIAController;
use App\Http\Controllers\changelogController;
use App\Http\Controllers\EventIvaoController;
use App\Http\Controllers\PilotIvaoController;
use App\Http\Controllers\whitelistController;
use App\Http\Controllers\ApiGestionController;
use App\Http\Controllers\chartIvaoFRcontroller;
use App\Http\Controllers\frendly_userController;
use App\Http\Controllers\MailRegisterController;
use App\Http\Controllers\my_fav_plateController;
use App\Http\Requests\registerValidationRequest;
use App\Http\Controllers\myOnlineServeurController;
use App\Http\Controllers\CreatAuhUniqueUsersController;
use Symfony\Component\HttpKernel\Controller\ErrorController;
use App\Http\Controllers\my_fav_plateController;
use App\Http\Controllers\airac_info;
use App\Http\Controllers\CarteSIAController;

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -72,6 +73,10 @@
$whazzup = $whazzup->connexion();
$w = new changelogController();
$u = $w->info_update();
$event_world = new EventIvaoController();
$event_world = $event_world->get_event_ivao_RFE_RFO();
$event_fr = new EventIvaoController();
$event_fr = $event_fr->get_event_ivao_FR();
if (Session::get("ivao_tokens") != null) {
$date = new DateTime();
$date->setTimezone(new DateTimeZone('UTC'));
Expand All @@ -85,13 +90,13 @@
$users_me = $whaz->user_me();
//dd($online->json(), $users_me);
$online = json_decode($online, true);
return response()->view('welcome', ["whazzup" => $whazzup, "online" => $online, "update" => $u]);
return response()->view('welcome', ["whazzup" => $whazzup, "online" => $online, "update" => $u, "event_worl" => $event_world, "event_fr" => $event_fr]);
}
if (env("maintenance_mode") == true) {
return view('maintenance');
}
$online = null;
return response()->view('welcome', ["whazzup" => $whazzup, "online" => $online, "update" => $u]);
return response()->view('welcome', ["whazzup" => $whazzup, "online" => $online, "update" => $u, "event_worl" => $event_world, "event_fr" => $event_fr]);
})->where('client', '[0-9]+')->name("home");

Route::get('/logout', function (Request $request) {
Expand Down Expand Up @@ -658,4 +663,11 @@
return response($req->body(), 200)->header('Content-Type', 'application/pdf');
//return $airac;
})->name("vac.icao");

Route::get("event", function (Request $request) {
$event_world = new EventIvaoController();
$event_world = $event_world->get_event_ivao();
return $event_world;

})->name("event.index");
});

0 comments on commit a2a5175

Please sign in to comment.