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

Event fr #148

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/exam.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/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/Examen IVAO ATC 1.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/training.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.
65 changes: 62 additions & 3 deletions resources/views/welcome.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
@extends("index-base")

@section('content')
<?php

use Illuminate\Support\Carbon;
?>

<div class="col-12">

Expand Down Expand Up @@ -92,23 +95,23 @@
<div class="col-4 mt-2">
<div class="card text-white bg-dark">
<div class="card-body">
<h4 class="card-title text-center text-info">Total</h4>
<h4 class="card-title text-center">TOTAL</h4>
<p class="card-text text-center text-info">{{ $whazzup["total"] }}</p>
</div>
</div>
</div>
<div class="col-4 mt-2">
<div class="card text-white bg-dark">
<div class="card-body">
<h4 class="card-title text-center text-info">ATC</h4>
<h4 class="card-title text-center">ATC</h4>
<p class="card-text text-center text-info">{{ $whazzup["atc"] }}</p>
</div>
</div>
</div>
<div class="col-4 mt-2">
<div class="card text-white bg-dark">
<div class="card-body">
<h4 class="card-title text-center text-info">Pilot</h4>
<h4 class="card-title text-center">PILOT</h4>
<p class="card-text text-center text-info">{{ $whazzup["pilot"] }}</p>
</div>
</div>
Expand Down Expand Up @@ -157,5 +160,61 @@

@endauth

<hr>
<div class="container mt-2">
<h5 class="fw-bold">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/training.png") }}" alt="">
@else
<img class="card-img-top" src="{{ asset("public/asset/img/training/training.png") }}" alt="">
@endif
@endif
@if ($events[0]["type"] == "exam")
@if (ENV('APP_ENV') == 'local')
<img class="card-img-top" src="{{ asset("asset/img/exam/exam.png") }}" alt="">
@else
<img class="card-img-top" src="{{ asset("public/asset/img/exam/exam.png") }}" alt="">
@endif
@endif
<p class="card-text text-center text-info mt-2">{{$events[0]["name"]}}</p>
<p class="card-text text-center ">{{$events[0]["description"]}}</p>
<p class="card-text text-center "><button class="btn btn-outline-success">{{Carbon::parse($events[0]["started_at"])->format('d-m H:i') }}Z</button> </p>
</div>
</div>
</div>
@endforeach
</div>
</div>

<hr>
<div class="container mt-2">
<h5 class="fw-bold">IVAO Event World</h5>
<div class="row">
@foreach($event_worl as $events)
<div class="col-6 mt-2">
<div class="card text-white bg-dark">
<div class="card-body">
<img src="{{$events['imageUrl']}}" style="width: 100%; height: 80%;" alt="" srcset="">
<h5 class="card-text text-center text-info mt-2">{{$events["title"]}} / {{$events["airports"][0]}} </h5>
<div class=" d-flex justify-content-center">
@for ($i = 0 ; $i < count($events["divisions"]) ; $i++ )
<span class="badge bg-secondary fs-6 ms-2"> {{$events["divisions"][$i]}}</span>
@endfor
</div>
<p class="card-text text-center ">{{$events["description"]}}</p>
<a href="{{$events["infoUrl"]}}" class="float-end"><button class="btn btn-outline-primary">More Information</button></a>
</div>
</div>
</div>
@endforeach
</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_RFE_RFO();
return $event_world;

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