This commit is contained in:
EwelinaLasowy 2022-02-04 08:42:18 +01:00
parent 067b343f24
commit fccf5e97f1
6 changed files with 403 additions and 2 deletions

View File

@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace Toby\Infrastructure\Http\Controllers;
use Barryvdh\DomPDF\Facade\Pdf;
use Illuminate\Http\Response;
class GeneratePdfController extends Controller
{
public function generatePDF(): Response
{
$data = ["data"];
$pdf = PDF::loadView('vacation-request-pdf', $data);
return $pdf->stream();
}
}

View File

@ -8,6 +8,7 @@
"php": "^8.1", "php": "^8.1",
"ext-pdo": "*", "ext-pdo": "*",
"azuyalabs/yasumi": "^2.4", "azuyalabs/yasumi": "^2.4",
"barryvdh/laravel-dompdf": "^1.0",
"fruitcake/laravel-cors": "^2.0", "fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1", "guzzlehttp/guzzle": "^7.0.1",
"inertiajs/inertia-laravel": "^0.5.1", "inertiajs/inertia-laravel": "^0.5.1",

289
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "bf5f7d8f40ecadea64ae8564a3df3110", "content-hash": "c2f475e65f84bdff45169e4443d9ef4f",
"packages": [ "packages": [
{ {
"name": "asm89/stack-cors", "name": "asm89/stack-cors",
@ -135,6 +135,82 @@
], ],
"time": "2022-01-30T07:43:17+00:00" "time": "2022-01-30T07:43:17+00:00"
}, },
{
"name": "barryvdh/laravel-dompdf",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/laravel-dompdf.git",
"reference": "e3f429e97087b2ef19b83e5ed313f080f2477685"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-dompdf/zipball/e3f429e97087b2ef19b83e5ed313f080f2477685",
"reference": "e3f429e97087b2ef19b83e5ed313f080f2477685",
"shasum": ""
},
"require": {
"dompdf/dompdf": "^1",
"illuminate/support": "^6|^7|^8|^9",
"php": "^7.2 || ^8.0"
},
"require-dev": {
"nunomaduro/larastan": "^1|^2",
"orchestra/testbench": "^4|^5|^6|^7",
"phpro/grumphp": "^1",
"squizlabs/php_codesniffer": "^3.5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"laravel": {
"providers": [
"Barryvdh\\DomPDF\\ServiceProvider"
],
"aliases": {
"PDF": "Barryvdh\\DomPDF\\Facade\\Pdf"
}
}
},
"autoload": {
"psr-4": {
"Barryvdh\\DomPDF\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "A DOMPDF Wrapper for Laravel",
"keywords": [
"dompdf",
"laravel",
"pdf"
],
"support": {
"issues": "https://github.com/barryvdh/laravel-dompdf/issues",
"source": "https://github.com/barryvdh/laravel-dompdf/tree/v1.0.0"
},
"funding": [
{
"url": "https://fruitcake.nl",
"type": "custom"
},
{
"url": "https://github.com/barryvdh",
"type": "github"
}
],
"time": "2022-01-29T08:02:59+00:00"
},
{ {
"name": "brick/math", "name": "brick/math",
"version": "0.9.3", "version": "0.9.3",
@ -437,6 +513,73 @@
], ],
"time": "2022-01-12T08:27:12+00:00" "time": "2022-01-12T08:27:12+00:00"
}, },
{
"name": "dompdf/dompdf",
"version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/dompdf/dompdf.git",
"reference": "de4aad040737a89fae2129cdeb0f79c45513128d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dompdf/dompdf/zipball/de4aad040737a89fae2129cdeb0f79c45513128d",
"reference": "de4aad040737a89fae2129cdeb0f79c45513128d",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-mbstring": "*",
"phenx/php-font-lib": "^0.5.2",
"phenx/php-svg-lib": "^0.3.3",
"php": "^7.1 || ^8.0"
},
"require-dev": {
"mockery/mockery": "^1.3",
"phpunit/phpunit": "^7.5 || ^8 || ^9",
"squizlabs/php_codesniffer": "^3.5"
},
"suggest": {
"ext-gd": "Needed to process images",
"ext-gmagick": "Improves image processing performance",
"ext-imagick": "Improves image processing performance",
"ext-zlib": "Needed for pdf stream compression"
},
"type": "library",
"autoload": {
"psr-4": {
"Dompdf\\": "src/"
},
"classmap": [
"lib/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1"
],
"authors": [
{
"name": "Fabien Ménager",
"email": "fabien.menager@gmail.com"
},
{
"name": "Brian Sweeney",
"email": "eclecticgeek@gmail.com"
},
{
"name": "Gabriel Bull",
"email": "me@gabrielbull.com"
}
],
"description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter",
"homepage": "https://github.com/dompdf/dompdf",
"support": {
"issues": "https://github.com/dompdf/dompdf/issues",
"source": "https://github.com/dompdf/dompdf/tree/v1.1.1"
},
"time": "2021-11-24T00:45:04+00:00"
},
{ {
"name": "dragonmantank/cron-expression", "name": "dragonmantank/cron-expression",
"version": "v3.3.1", "version": "v3.3.1",
@ -2846,6 +2989,95 @@
], ],
"time": "2021-07-19T03:43:32+00:00" "time": "2021-07-19T03:43:32+00:00"
}, },
{
"name": "phenx/php-font-lib",
"version": "0.5.4",
"source": {
"type": "git",
"url": "https://github.com/dompdf/php-font-lib.git",
"reference": "dd448ad1ce34c63d09baccd05415e361300c35b4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/dd448ad1ce34c63d09baccd05415e361300c35b4",
"reference": "dd448ad1ce34c63d09baccd05415e361300c35b4",
"shasum": ""
},
"require": {
"ext-mbstring": "*"
},
"require-dev": {
"symfony/phpunit-bridge": "^3 || ^4 || ^5"
},
"type": "library",
"autoload": {
"psr-4": {
"FontLib\\": "src/FontLib"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"authors": [
{
"name": "Fabien Ménager",
"email": "fabien.menager@gmail.com"
}
],
"description": "A library to read, parse, export and make subsets of different types of font files.",
"homepage": "https://github.com/PhenX/php-font-lib",
"support": {
"issues": "https://github.com/dompdf/php-font-lib/issues",
"source": "https://github.com/dompdf/php-font-lib/tree/0.5.4"
},
"time": "2021-12-17T19:44:54+00:00"
},
{
"name": "phenx/php-svg-lib",
"version": "0.3.4",
"source": {
"type": "git",
"url": "https://github.com/PhenX/php-svg-lib.git",
"reference": "f627771eb854aa7f45f80add0f23c6c4d67ea0f2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PhenX/php-svg-lib/zipball/f627771eb854aa7f45f80add0f23c6c4d67ea0f2",
"reference": "f627771eb854aa7f45f80add0f23c6c4d67ea0f2",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
"sabberworm/php-css-parser": "^8.3"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Svg\\": "src/Svg"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"authors": [
{
"name": "Fabien Ménager",
"email": "fabien.menager@gmail.com"
}
],
"description": "A library to read, parse and export to PDF SVG files.",
"homepage": "https://github.com/PhenX/php-svg-lib",
"support": {
"issues": "https://github.com/PhenX/php-svg-lib/issues",
"source": "https://github.com/PhenX/php-svg-lib/tree/0.3.4"
},
"time": "2021-10-18T02:13:32+00:00"
},
{ {
"name": "phpoption/phpoption", "name": "phpoption/phpoption",
"version": "1.8.1", "version": "1.8.1",
@ -3572,6 +3804,59 @@
], ],
"time": "2021-09-25T23:10:38+00:00" "time": "2021-09-25T23:10:38+00:00"
}, },
{
"name": "sabberworm/php-css-parser",
"version": "8.4.0",
"source": {
"type": "git",
"url": "https://github.com/sabberworm/PHP-CSS-Parser.git",
"reference": "e41d2140031d533348b2192a83f02d8dd8a71d30"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sabberworm/PHP-CSS-Parser/zipball/e41d2140031d533348b2192a83f02d8dd8a71d30",
"reference": "e41d2140031d533348b2192a83f02d8dd8a71d30",
"shasum": ""
},
"require": {
"ext-iconv": "*",
"php": ">=5.6.20"
},
"require-dev": {
"codacy/coverage": "^1.4",
"phpunit/phpunit": "^4.8.36"
},
"suggest": {
"ext-mbstring": "for parsing UTF-8 CSS"
},
"type": "library",
"autoload": {
"psr-4": {
"Sabberworm\\CSS\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Raphael Schweikert"
}
],
"description": "Parser for CSS Files written in PHP",
"homepage": "https://www.sabberworm.com/blog/2010/6/10/php-css-parser",
"keywords": [
"css",
"parser",
"stylesheet"
],
"support": {
"issues": "https://github.com/sabberworm/PHP-CSS-Parser/issues",
"source": "https://github.com/sabberworm/PHP-CSS-Parser/tree/8.4.0"
},
"time": "2021-12-11T13:40:54+00:00"
},
{ {
"name": "swiftmailer/swiftmailer", "name": "swiftmailer/swiftmailer",
"version": "v6.3.0", "version": "v6.3.0",
@ -10027,5 +10312,5 @@
"ext-pdo": "*" "ext-pdo": "*"
}, },
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.1.0" "plugin-api-version": "2.2.0"
} }

View File

@ -43,5 +43,6 @@ return [
Toby\Architecture\Providers\RouteServiceProvider::class, Toby\Architecture\Providers\RouteServiceProvider::class,
Toby\Architecture\Providers\TelescopeServiceProvider::class, Toby\Architecture\Providers\TelescopeServiceProvider::class,
Toby\Architecture\Providers\ObserverServiceProvider::class, Toby\Architecture\Providers\ObserverServiceProvider::class,
Barryvdh\DomPDF\ServiceProvider::class,
], ],
]; ];

View File

@ -0,0 +1,93 @@
<!DOCTYPE html>
<html lang="pl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Wniosek urlopowy</title>
<style>
body {
font-family: DejaVu Sans, sans-serif;
}
h2 {
text-align: center;
}
p {
margin: 0;
text-align: center;
}
.container {
margin: 60px 20px;
}
.helper-text {
font-size: 12px;
font-weight: bold;
padding-bottom: 12px;
}
.content {
margin-top: 60px;
line-height: 24px;
text-align: left;
}
.main {
margin-top: 60px;
}
table {
width: 100%;
text-align: center;
}
.signatureTable {
margin-top: 100px;
}
</style>
</head>
<body>
<div class="container">
<div>
<table>
<tbody>
<tr>
<td>Jan Kowalski</td>
<td>Legnica, 02.02.2022</td>
</tr>
<tr>
<td class="helper-text">imię i nazwisko</td>
</tr>
<tr>
<td>tester oprogramowania</td>
</tr>
<tr>
<td class="helper-text">stanowisko</td>
</tr>
</tbody>
</table>
</div>
<div class="main">
<h2>Wniosek o urlop</h2>
<p class="content">Proszę o udzielenie urlopu wypoczynkowego w okresie od dnia 03.02.2022 do dnia 10.02.2022
włącznie tj. 5 dni roboczych za rok 2022. </p>
</div>
<table class="signatureTable">
<tbody>
<tr>
<td>Super Przełożony</td>
<td>Jan Kowalski</td>
</tr>
<tr>
<td class="helper-text">podpis przełożonego</td>
<td class="helper-text">podpis pracownika</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

View File

@ -3,6 +3,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use Toby\Infrastructure\Http\Controllers\GeneratePdfController;
use Toby\Infrastructure\Http\Controllers\GoogleController; use Toby\Infrastructure\Http\Controllers\GoogleController;
use Toby\Infrastructure\Http\Controllers\HolidayController; use Toby\Infrastructure\Http\Controllers\HolidayController;
use Toby\Infrastructure\Http\Controllers\LogoutController; use Toby\Infrastructure\Http\Controllers\LogoutController;
@ -44,6 +45,8 @@ Route::middleware("auth")->group(function (): void {
Route::post("year-periods/{yearPeriod}/select", SelectYearPeriodController::class) Route::post("year-periods/{yearPeriod}/select", SelectYearPeriodController::class)
->name("year-periods.select"); ->name("year-periods.select");
Route::get("/generate-pdf", [GeneratePdfController::class, "generatePDF"]);
}); });
Route::middleware("guest")->group(function (): void { Route::middleware("guest")->group(function (): void {