Skip to content

Commit ff53d40

Browse files
Initial commit
0 parents  commit ff53d40

File tree

92 files changed

+11947
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+11947
-0
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

.env.example

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
LOG_DEPRECATIONS_CHANNEL=null
9+
LOG_LEVEL=debug
10+
11+
DB_CONNECTION=mysql
12+
DB_HOST=127.0.0.1
13+
DB_PORT=3306
14+
DB_DATABASE=zatca_qr
15+
DB_USERNAME=root
16+
DB_PASSWORD=
17+
18+
BROADCAST_DRIVER=log
19+
CACHE_DRIVER=file
20+
FILESYSTEM_DRIVER=local
21+
QUEUE_CONNECTION=sync
22+
SESSION_DRIVER=file
23+
SESSION_LIFETIME=120
24+
25+
MEMCACHED_HOST=127.0.0.1
26+
27+
REDIS_HOST=127.0.0.1
28+
REDIS_PASSWORD=null
29+
REDIS_PORT=6379
30+
31+
MAIL_MAILER=smtp
32+
MAIL_HOST=mailhog
33+
MAIL_PORT=1025
34+
MAIL_USERNAME=null
35+
MAIL_PASSWORD=null
36+
MAIL_ENCRYPTION=null
37+
MAIL_FROM_ADDRESS=null
38+
MAIL_FROM_NAME="${APP_NAME}"
39+
40+
AWS_ACCESS_KEY_ID=
41+
AWS_SECRET_ACCESS_KEY=
42+
AWS_DEFAULT_REGION=us-east-1
43+
AWS_BUCKET=
44+
AWS_USE_PATH_STYLE_ENDPOINT=false
45+
46+
PUSHER_APP_ID=
47+
PUSHER_APP_KEY=
48+
PUSHER_APP_SECRET=
49+
PUSHER_APP_CLUSTER=mt1
50+
51+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
52+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored
4+
*.js linguist-vendored
5+
CHANGELOG.md export-ignore

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/node_modules
2+
/public/hot
3+
/public/storage
4+
/storage/*.key
5+
/vendor
6+
.env
7+
.env.backup
8+
.phpunit.result.cache
9+
docker-compose.override.yml
10+
Homestead.json
11+
Homestead.yaml
12+
npm-debug.log
13+
yarn-error.log
14+
/.idea
15+
/.vscode

.styleci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
php:
2+
preset: laravel
3+
version: 8
4+
disabled:
5+
- no_unused_imports
6+
finder:
7+
not-name:
8+
- index.php
9+
- server.php
10+
js:
11+
finder:
12+
not-name:
13+
- webpack.mix.js
14+
css: true

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<p align="center"><br><img src="./public/images/qr_scan_me.png" width="150"></p>
2+
3+
A Laravel application to generate QR Codes required for e-invoicing standard by [ZATCA](https://zatca.gov.sa/en/E-Invoicing/Pages/default.aspx) in Saudi Arabia.
4+
You can use it as a ready-made code template for your projects to support ZATCA QR codes.
5+
6+
This application is built using the following libraries:
7+
8+
- [Salla ZATCA](https://github.com/SallaApp/ZATCA) implementation.
9+
- [Chillerlan](https://github.com/chillerlan/php-qrcode) QR Code library
10+
- Barryvdh [DOMPDF Wrapper](https://github.com/barryvdh/laravel-dompdf) for Laravel.
11+
12+
## Features
13+
14+
- Download QR code image directly.
15+
- Save QR code image to server.
16+
- Generate PDF with QR code image.
17+
- Add an image in the center of the QR code image.
18+
19+
## Usage
20+
21+
To get started, this is all you need to do:
22+
23+
```bash
24+
$ git clone https://github.com/mostafaaminflakes/ZATCA-QR-Code-Implementation.git
25+
$ cd ZATCA-QR-Code-Implementation
26+
$ composer install
27+
$ cp .env.example .env
28+
$ php artisan key:generate
29+
$ php artisan serve
30+
```
31+
32+
## Contributions
33+
34+
For bug reports or feature requests, please share them with us [here](https://github.com/mostafaaminflakes/ZATCA-QR-Code-Implementation/issues).

app/Classes/LogoOptions.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace App\Classes;
4+
5+
use chillerlan\QRCode\QROptions;
6+
7+
/**
8+
* @property int $logoSpaceWidth
9+
* @property int $logoSpaceHeight
10+
*
11+
* @noinspection PhpIllegalPsrClassPathInspection
12+
*/
13+
class LogoOptions extends QROptions
14+
{
15+
// size in QR modules, multiply with QROptions::$scale for pixel size
16+
protected int $logoSpaceWidth;
17+
protected int $logoSpaceHeight;
18+
}

app/Classes/QRImageWithLogo.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
/**
4+
* Class QRImageWithLogo
5+
*
6+
* @filesource QRImageWithLogo.php
7+
* @created 18.11.2020
8+
* @package chillerlan\QRCodeExamples
9+
* @author smiley <smiley@chillerlan.net>
10+
* @copyright 2020 smiley
11+
* @license MIT
12+
*
13+
* @noinspection PhpComposerExtensionStubsInspection
14+
*/
15+
16+
// namespace chillerlan\QRCodeExamples;
17+
namespace App\Classes;
18+
19+
use chillerlan\QRCode\Output\{QRCodeOutputException, QRImage};
20+
21+
use function imagecopyresampled, imagecreatefrompng, imagesx, imagesy, is_file, is_readable;
22+
23+
/**
24+
* @property \chillerlan\QRCodeExamples\LogoOptions $options
25+
*/
26+
class QRImageWithLogo extends QRImage
27+
{
28+
29+
/**
30+
* @param string|null $file
31+
* @param string|null $logo
32+
*
33+
* @return string
34+
* @throws \chillerlan\QRCode\Output\QRCodeOutputException
35+
*/
36+
public function dump(string $file = null, string $logo = null): string
37+
{
38+
// set returnResource to true to skip further processing for now
39+
$this->options->returnResource = true;
40+
41+
// of course you could accept other formats too (such as resource or Imagick)
42+
// i'm not checking for the file type either for simplicity reasons (assuming PNG)
43+
if (!is_file($logo) || !is_readable($logo)) {
44+
throw new QRCodeOutputException('invalid logo');
45+
}
46+
47+
$this->matrix->setLogoSpace(
48+
$this->options->logoSpaceWidth,
49+
$this->options->logoSpaceHeight
50+
// not utilizing the position here
51+
);
52+
53+
// there's no need to save the result of dump() into $this->image here
54+
parent::dump($file);
55+
56+
$im = imagecreatefrompng($logo);
57+
58+
// get logo image size
59+
$w = imagesx($im);
60+
$h = imagesy($im);
61+
62+
// set new logo size, leave a border of 1 module (no proportional resize/centering)
63+
$lw = ($this->options->logoSpaceWidth - 2) * $this->options->scale;
64+
$lh = ($this->options->logoSpaceHeight - 2) * $this->options->scale;
65+
66+
// get the qrcode size
67+
$ql = $this->matrix->size() * $this->options->scale;
68+
69+
// scale the logo and copy it over. done!
70+
imagecopyresampled($this->image, $im, ($ql - $lw) / 2, ($ql - $lh) / 2, 0, 0, $lw, $lh, $w, $h);
71+
72+
$imageData = $this->dumpImage();
73+
74+
if ($file !== null) {
75+
$this->saveToFile($imageData, $file);
76+
}
77+
78+
if ($this->options->imageBase64) {
79+
$imageData = 'data:image/' . $this->options->outputType . ';base64,' . base64_encode($imageData);
80+
}
81+
82+
return $imageData;
83+
}
84+
}

app/Console/Kernel.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* Define the application's command schedule.
12+
*
13+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
14+
* @return void
15+
*/
16+
protected function schedule(Schedule $schedule)
17+
{
18+
// $schedule->command('inspire')->hourly();
19+
}
20+
21+
/**
22+
* Register the commands for the application.
23+
*
24+
* @return void
25+
*/
26+
protected function commands()
27+
{
28+
$this->load(__DIR__.'/Commands');
29+
30+
require base_path('routes/console.php');
31+
}
32+
}

app/Exceptions/Handler.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6+
use Throwable;
7+
8+
class Handler extends ExceptionHandler
9+
{
10+
/**
11+
* A list of the exception types that are not reported.
12+
*
13+
* @var array<int, class-string<Throwable>>
14+
*/
15+
protected $dontReport = [
16+
//
17+
];
18+
19+
/**
20+
* A list of the inputs that are never flashed for validation exceptions.
21+
*
22+
* @var array<int, string>
23+
*/
24+
protected $dontFlash = [
25+
'current_password',
26+
'password',
27+
'password_confirmation',
28+
];
29+
30+
/**
31+
* Register the exception handling callbacks for the application.
32+
*
33+
* @return void
34+
*/
35+
public function register()
36+
{
37+
$this->reportable(function (Throwable $e) {
38+
//
39+
});
40+
}
41+
}

0 commit comments

Comments
 (0)