This repository has been archived on 2019-03-01. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
paper-pi/app/Http/Controllers/AirlyController.php

93 lines
3.1 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: k
* Date: 10.02.2017
* Time: 20:10
*/
namespace App\Http\Controllers;
set_time_limit(-1);
use App\Paper\Airly;
use App\Paper\Paper;
use Illuminate\Http\Request;
class AirlyController extends Controller
{
private $paper = null;
public function __construct()
{
$this->paper = new Paper();
}
/**
* get:/airly_all
* @return \Illuminate\Http\RedirectResponse
*/
public function airly_all()
{
$airly = new Airly();
$this->paper->sendImagePrint($airly->icon);
$this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y'));
$airly->setStations(config('paper.airly.stations'));
foreach ($airly->getStations() as $stationId) {
$stationInfo = $airly->getStationInfo($stationId);
$this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']);
$dataText = $airly->getInformationText($stationId);
$this->paper->sendPrint('', $dataText);
}
return back();
}
public function airly_rzeczypospolitej()
{
$airly = new Airly();
$this->paper->sendImagePrint($airly->icon);
$this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y'));
$airly->setStations([config('paper.airly.rzeczypospolitej')]);
foreach ($airly->getStations() as $stationId) {
$stationInfo = $airly->getStationInfo($stationId);
$this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']);
$dataText = $airly->getInformationText($stationId);
$this->paper->sendPrint('', $dataText);
}
return back();
}
public function airly_grunwaldzka()
{
$airly = new Airly();
$this->paper->sendImagePrint($airly->icon);
$this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y'));
$airly->setStations([config('paper.airly.grunwaldzka')]);
foreach ($airly->getStations() as $stationId) {
$stationInfo = $airly->getStationInfo($stationId);
$this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']);
$dataText = $airly->getInformationText($stationId);
$this->paper->sendPrint('', $dataText);
}
return back();
}
public function airly_sowinskiego()
{
$airly = new Airly();
$this->paper->sendImagePrint($airly->icon);
$this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y'));
$airly->setStations([config('paper.airly.sowinskiego')]);
foreach ($airly->getStations() as $stationId) {
$stationInfo = $airly->getStationInfo($stationId);
$this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']);
$dataText = $airly->getInformationText($stationId);
$this->paper->sendPrint('', $dataText);
}
return back();
}
}