Skip to content

Commit

Permalink
Add QR Code Feature (#66)
Browse files Browse the repository at this point in the history
* Add QR Code feature

Closes #53

* Add strings for QR Code Feature
  • Loading branch information
michaellindahl authored and optiroot committed Oct 8, 2019
1 parent 68c7c42 commit da0d017
Show file tree
Hide file tree
Showing 39 changed files with 326 additions and 8 deletions.
58 changes: 58 additions & 0 deletions app/Http/Controllers/QRCodeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/*
* UrlHum (https://urlhum.com)
*
* @link https://github.com/urlhum/UrlHum
* @license https://github.com/urlhum/UrlHum/blob/master/LICENSE.md (MIT License)
*/

namespace App\Http\Controllers;

use App\Url;
use Illuminate\Support\Facades\Storage;
use SimpleSoftwareIO\QrCode\Facades\QrCode;

/**
* Controller handling creating/fetching the QR code associated with the short URL.
*
* Class ViewUrlController
* @author Michael Lindahl <[email protected]>
*/
class QRCodeController
{
/**
* Retreives the QR Code in svg format for the short URL.
*
* @param $url
* @return \Illuminate\Http\RedirectResponse
*/
public function svg(Url $url)
{
return $this->qrCode($url, 'svg', 'image/svg+xml');
}

/**
* Retreives the QR Code in png format for the short URL.
*
* @param $url
* @return \Illuminate\Http\RedirectResponse
*/
public function png(Url $url)
{
return $this->qrCode($url, 'png', 'image/png');
}

private function qrCode(Url $url, $format, $contentType)
{
$path = 'qrcodes/'.$url->short_url.'.'.$format;
if (Storage::exists($path)) {
$qrCode = Storage::get($path);
} else {
$qrCode = QrCode::format($format)->size(300)->generate(route('view', $url));
Storage::put($path, $qrCode);
}

return response($qrCode)->header('Content-Type', $contentType);
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"laravel/framework": "5.8.*",
"laravel/passport": "^7.2",
"laravel/tinker": "^1.0",
"simplesoftwareio/simple-qrcode": "^2.0",
"spatie/laravel-honeypot": "^1.3",
"yajra/laravel-datatables-oracle": "~9.0"
},
Expand Down
113 changes: 110 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions resources/lang/af_ZA/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/ar_SA/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/ca_ES/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/cs_CZ/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/da_DK/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/de_DE/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/el_GR/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/en_US/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/es_ES/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Últimas URLs',
'all' => 'Ver todo',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/fa_IR/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/fi_FI/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/fr_FR/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/he_IL/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/hu_HU/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/it_IT/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Ultimi URL',
'all' => 'Mostra tutti',
'urls' => 'URL',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/ja_JP/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/ko_KR/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/nl_NL/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/no_NO/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/pl_PL/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/pt_BR/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/pt_PT/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
3 changes: 3 additions & 0 deletions resources/lang/ro_RO/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
'latest' => 'Latest URLs',
'all' => 'See all',
'urls' => 'URLs',
'qrcode' => 'QR Code',
'qrcode_modal' => 'QR Code',
'qrcode_download' => 'Download',
];
Loading

0 comments on commit da0d017

Please sign in to comment.