Merge branch 'issue-28' of krzysiej/paper-pi into master

This commit was merged in pull request #56.
This commit is contained in:
2018-08-19 10:08:27 +02:00
committed by krzysiej
2 changed files with 18 additions and 1 deletions

View File

@@ -75,6 +75,20 @@ class Paper
} }
} }
public function saveToHistory($title, $text, $textSource, $image)
{
DB::table('history')
->insertGetId([
'topic' => $title,
'topic_slug' => str_slug($title, '_'),
'text' => $text,
'text_source' => $textSource,
'icon' => $image,
'created_at' => time(),
'updated_at' => time()
]);
}
public function sendPrint($title, $text = '', $image = false, $imageLocal = true) public function sendPrint($title, $text = '', $image = false, $imageLocal = true)
{ {
@@ -82,6 +96,9 @@ class Paper
$this->sendHeaderPrint($title); $this->sendHeaderPrint($title);
$htmlToPos = new HtmlToPos(); $htmlToPos = new HtmlToPos();
$convertedData = $htmlToPos->convert($text); $convertedData = $htmlToPos->convert($text);
//zapisuje do pamięci dane o drukowanej notatce, jesli obrazek nie jest ikoną to nie zapisuje go
$this->saveToHistory($title, $convertedData, $text, $imageLocal ? $image : '');
if (is_array($convertedData)) { if (is_array($convertedData)) {
$this->printer->text($convertedData['text']); $this->printer->text($convertedData['text']);
} else { } else {

View File

@@ -16,7 +16,7 @@ class Traficar
private $traficarJson; private $traficarJson;
//dystans w kilometrach w którym auta brane są pod uwagę //dystans w kilometrach w którym auta brane są pod uwagę
const CLOSEST_DISTANCE = 2; const CLOSEST_DISTANCE = 2.5;
/** /**
* @param $lat1 * @param $lat1