Weather stuffs
This commit is contained in:
47
app/Http/Controllers/WeatherController.php
Normal file
47
app/Http/Controllers/WeatherController.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Jinas\Moosun\MoosunMv;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class WeatherController extends Controller
|
||||
{
|
||||
protected $stations = [
|
||||
'Male',
|
||||
'Hanimadhoo',
|
||||
'Kahdhoo',
|
||||
'Kaadehdhoo',
|
||||
'Gan'];
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('weather.index', [
|
||||
'stations' => $this->getMoosun(),
|
||||
'labels' => [
|
||||
'Male' => "މާލެ",
|
||||
'Hanimadhoo' => "ހަނިމާދޫ",
|
||||
'Kahdhoo' => "ކައްދޫ",
|
||||
'Kaadehdhoo' => "ކާޑެއްދޫ",
|
||||
'Gan' => "ގަން"
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getMoosun()
|
||||
{
|
||||
|
||||
$data = Cache::remember('weather.maldives', 3600, function () {
|
||||
$data = [];
|
||||
foreach ($this->stations as $station) {
|
||||
$rp = new MoosunMv($station);
|
||||
$data[] = $rp;
|
||||
}
|
||||
|
||||
return $data;
|
||||
});
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user