diff --git a/.idea/php.xml b/.idea/php.xml index bb5a856..3f70f6c 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -4,7 +4,6 @@ - @@ -26,8 +25,6 @@ - - @@ -62,8 +59,6 @@ - - @@ -120,6 +115,14 @@ + + + + + + + + diff --git a/.idea/skolehjem-webapp.iml b/.idea/skolehjem-webapp.iml index 7c6434f..1c12b7e 100644 --- a/.idea/skolehjem-webapp.iml +++ b/.idea/skolehjem-webapp.iml @@ -7,6 +7,7 @@ + @@ -14,6 +15,7 @@ + @@ -30,14 +32,11 @@ - - - @@ -54,7 +53,8 @@ - + + @@ -69,7 +69,6 @@ - @@ -77,6 +76,7 @@ + diff --git a/skolehjem/app/Http/Controllers/MenuPlanController.php b/skolehjem/app/Http/Controllers/MenuPlanController.php index db6bbac..bbe049b 100644 --- a/skolehjem/app/Http/Controllers/MenuPlanController.php +++ b/skolehjem/app/Http/Controllers/MenuPlanController.php @@ -2,10 +2,12 @@ namespace App\Http\Controllers; +use App; use App\ExternalLink; use App\MenuPlan; use App\News; use App\User; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Facades\DB; @@ -156,7 +158,7 @@ class MenuPlanController extends Controller * Remove the specified resource from storage. * Test delete return index function. * @param int $id - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function destroy($id) { @@ -165,5 +167,19 @@ class MenuPlanController extends Controller return redirect()->route("menu-plans.index"); } + /** + * Remove the specified resource from storage. + * Test delete return index function. + * @param $Id + * @return RedirectResponse + */ + public function genPDF($Id){ + $menuPlan = MenuPlan::query()->where("id", "=", $Id)->first(); + $pdf = \Illuminate\Support\Facades\App::make('dompdf.wrapper'); + $data = '
'. '

Uge '. $menuPlan->week. '

' .$menuPlan->menu. '
'; + $pdf->loadHTML($data); + return $pdf->stream(); + + } } diff --git a/skolehjem/composer.json b/skolehjem/composer.json index 15daac3..8cd540d 100644 --- a/skolehjem/composer.json +++ b/skolehjem/composer.json @@ -9,6 +9,7 @@ "license": "MIT", "require": { "php": "^7.2.5", + "barryvdh/laravel-dompdf": "^0.8.6", "fideloper/proxy": "^4.2", "fruitcake/laravel-cors": "^1.0", "guzzlehttp/guzzle": "^6.3", diff --git a/skolehjem/composer.lock b/skolehjem/composer.lock index 7b23866..7c857bf 100644 --- a/skolehjem/composer.lock +++ b/skolehjem/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8ba128c6252a57bde3eb22750ed51bef", + "content-hash": "8e62a745d683f5494f4d1efefc047dfd", "packages": [ { "name": "asm89/stack-cors", @@ -58,6 +58,62 @@ ], "time": "2019-12-24T22:41:47+00:00" }, + { + "name": "barryvdh/laravel-dompdf", + "version": "v0.8.6", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-dompdf.git", + "reference": "d7108f78cf5254a2d8c224542967f133e5a6d4e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-dompdf/zipball/d7108f78cf5254a2d8c224542967f133e5a6d4e8", + "reference": "d7108f78cf5254a2d8c224542967f133e5a6d4e8", + "shasum": "" + }, + "require": { + "dompdf/dompdf": "^0.8", + "illuminate/support": "^5.5|^6|^7", + "php": ">=7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.8-dev" + }, + "laravel": { + "providers": [ + "Barryvdh\\DomPDF\\ServiceProvider" + ], + "aliases": { + "PDF": "Barryvdh\\DomPDF\\Facade" + } + } + }, + "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" + ], + "time": "2020-02-25T20:44:34+00:00" + }, { "name": "brick/math", "version": "0.8.15", @@ -102,12 +158,6 @@ "brick", "math" ], - "funding": [ - { - "url": "https://tidelift.com/funding/github/packagist/brick/math", - "type": "tidelift" - } - ], "time": "2020-04-15T15:59:35+00:00" }, { @@ -218,20 +268,6 @@ "uppercase", "words" ], - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector", - "type": "tidelift" - } - ], "time": "2020-05-29T15:13:26+00:00" }, { @@ -294,21 +330,73 @@ "parser", "php" ], - "funding": [ + "time": "2020-05-25T17:44:05+00:00" + }, + { + "name": "dompdf/dompdf", + "version": "v0.8.5", + "source": { + "type": "git", + "url": "https://github.com/dompdf/dompdf.git", + "reference": "6782abfc090b132134cd6cea0ec6d76f0fce2c56" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/dompdf/zipball/6782abfc090b132134cd6cea0ec6d76f0fce2c56", + "reference": "6782abfc090b132134cd6cea0ec6d76f0fce2c56", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-mbstring": "*", + "phenx/php-font-lib": "^0.5.1", + "phenx/php-svg-lib": "^0.3.3", + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.5", + "squizlabs/php_codesniffer": "^3.5" + }, + "suggest": { + "ext-gd": "Needed to process images", + "ext-gmagick": "Improves image processing performance", + "ext-imagick": "Improves image processing performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "0.7-dev" + } + }, + "autoload": { + "psr-4": { + "Dompdf\\": "src/" + }, + "classmap": [ + "lib/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1" + ], + "authors": [ { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" + "name": "Fabien Ménager", + "email": "fabien.menager@gmail.com" }, { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" + "name": "Brian Sweeney", + "email": "eclecticgeek@gmail.com" }, { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer", - "type": "tidelift" + "name": "Gabriel Bull", + "email": "me@gabrielbull.com" } ], - "time": "2020-05-25T17:44:05+00:00" + "description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter", + "homepage": "https://github.com/dompdf/dompdf", + "time": "2020-02-20T03:52:51+00:00" }, { "name": "dragonmantank/cron-expression", @@ -542,12 +630,6 @@ "crossdomain", "laravel" ], - "funding": [ - { - "url": "https://github.com/barryvdh", - "type": "github" - } - ], "time": "2020-04-28T08:47:37+00:00" }, { @@ -1356,12 +1438,6 @@ "sftp", "storage" ], - "funding": [ - { - "url": "https://offset.earth/frankdejonge", - "type": "other" - } - ], "time": "2020-05-18T15:13:39+00:00" }, { @@ -1495,16 +1571,6 @@ "logging", "psr-3" ], - "funding": [ - { - "url": "https://github.com/Seldaek", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", - "type": "tidelift" - } - ], "time": "2020-05-22T08:12:19+00:00" }, { @@ -1709,6 +1775,83 @@ ], "time": "2020-06-07T11:41:29+00:00" }, + { + "name": "phenx/php-font-lib", + "version": "0.5.2", + "source": { + "type": "git", + "url": "https://github.com/PhenX/php-font-lib.git", + "reference": "ca6ad461f032145fff5971b5985e5af9e7fa88d8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PhenX/php-font-lib/zipball/ca6ad461f032145fff5971b5985e5af9e7fa88d8", + "reference": "ca6ad461f032145fff5971b5985e5af9e7fa88d8", + "shasum": "" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5 || ^6 || ^7" + }, + "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", + "time": "2020-03-08T15:31:32+00:00" + }, + { + "name": "phenx/php-svg-lib", + "version": "v0.3.3", + "source": { + "type": "git", + "url": "https://github.com/PhenX/php-svg-lib.git", + "reference": "5fa61b65e612ce1ae15f69b3d223cb14ecc60e32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PhenX/php-svg-lib/zipball/5fa61b65e612ce1ae15f69b3d223cb14ecc60e32", + "reference": "5fa61b65e612ce1ae15f69b3d223cb14ecc60e32", + "shasum": "" + }, + "require": { + "sabberworm/php-css-parser": "^8.3" + }, + "require-dev": { + "phpunit/phpunit": "^5.5|^6.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", + "time": "2019-09-11T20:02:13+00:00" + }, { "name": "phpoption/phpoption", "version": "1.7.4", @@ -1762,16 +1905,6 @@ "php", "type" ], - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", - "type": "tidelift" - } - ], "time": "2020-06-07T10:40:07+00:00" }, { @@ -2266,13 +2399,52 @@ "identifier", "uuid" ], - "funding": [ + "time": "2020-03-29T20:13:32+00:00" + }, + { + "name": "sabberworm/php-css-parser", + "version": "8.3.1", + "source": { + "type": "git", + "url": "https://github.com/sabberworm/PHP-CSS-Parser.git", + "reference": "d217848e1396ef962fb1997cf3e2421acba7f796" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabberworm/PHP-CSS-Parser/zipball/d217848e1396ef962fb1997cf3e2421acba7f796", + "reference": "d217848e1396ef962fb1997cf3e2421acba7f796", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "codacy/coverage": "^1.4", + "phpunit/phpunit": "~4.8" + }, + "type": "library", + "autoload": { + "psr-0": { + "Sabberworm\\CSS": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { - "url": "https://github.com/ramsey", - "type": "github" + "name": "Raphael Schweikert" } ], - "time": "2020-03-29T20:13:32+00:00" + "description": "Parser for CSS Files written in PHP", + "homepage": "http://www.sabberworm.com/blog/2010/6/10/php-css-parser", + "keywords": [ + "css", + "parser", + "stylesheet" + ], + "time": "2020-06-01T09:10:00+00:00" }, { "name": "spatie/laravel-permission", @@ -2340,12 +2512,6 @@ "security", "spatie" ], - "funding": [ - { - "url": "https://spatie.be/open-source/support-us", - "type": "custom" - } - ], "time": "2020-05-20T00:31:29+00:00" }, { @@ -2586,20 +2752,6 @@ ], "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-27T08:34:37+00:00" }, { @@ -2787,20 +2939,6 @@ "interoperability", "standards" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-20T17:43:50+00:00" }, { @@ -3507,20 +3645,6 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-12T16:47:27+00:00" }, { @@ -3845,20 +3969,6 @@ "interoperability", "standards" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-05-20T17:43:50+00:00" }, { @@ -4300,16 +4410,6 @@ "env", "environment" ], - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", - "type": "tidelift" - } - ], "time": "2020-06-07T18:25:35+00:00" }, { @@ -4416,20 +4516,6 @@ "constructor", "instantiate" ], - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", - "type": "tidelift" - } - ], "time": "2020-05-29T17:27:14+00:00" }, { @@ -4484,12 +4570,6 @@ "flare", "reporting" ], - "funding": [ - { - "url": "https://www.patreon.com/spatie", - "type": "patreon" - } - ], "time": "2020-03-02T15:52:04+00:00" }, { @@ -4950,20 +5030,6 @@ "php", "symfony" ], - "funding": [ - { - "url": "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L", - "type": "custom" - }, - { - "url": "https://github.com/nunomaduro", - "type": "github" - }, - { - "url": "https://www.patreon.com/nunomaduro", - "type": "patreon" - } - ], "time": "2020-04-04T19:56:08+00:00" }, { @@ -5681,12 +5747,6 @@ "highlight.php", "syntax" ], - "funding": [ - { - "url": "https://github.com/allejo", - "type": "github" - } - ], "time": "2020-03-02T05:59:21+00:00" }, { diff --git a/skolehjem/config/app.php b/skolehjem/config/app.php index 2c1b451..e1168d1 100644 --- a/skolehjem/config/app.php +++ b/skolehjem/config/app.php @@ -161,6 +161,7 @@ return [ Illuminate\Translation\TranslationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class, Illuminate\View\ViewServiceProvider::class, + Barryvdh\DomPDF\ServiceProvider::class, /* * Package Service Providers... diff --git a/skolehjem/resources/views/admin/menuplans/index.blade.php b/skolehjem/resources/views/admin/menuplans/index.blade.php index 212f5d7..a9ae2af 100644 --- a/skolehjem/resources/views/admin/menuplans/index.blade.php +++ b/skolehjem/resources/views/admin/menuplans/index.blade.php @@ -19,12 +19,14 @@ + @foreach($menuPlans as $menuplan) +
UgePrint Update Delete
{{$menuplan->week}} $menuplan ]) }}">Print $menuplan ]) }}">Update
$menuplan ]) }}" class="w-100 nostyle"> @csrf diff --git a/skolehjem/routes/web.php b/skolehjem/routes/web.php index 9fcb986..a81eb7b 100644 --- a/skolehjem/routes/web.php +++ b/skolehjem/routes/web.php @@ -49,6 +49,9 @@ Route::get("/risrosapi", "FeedbackController@search")->name("feedbacks.search"); Route::get("/languages", "UserController@setLanguages")->name("users.setLanguages"); Route::get("/darkmode", "UserController@setDarkMode")->name("users.setDarkMode"); +//Convert to PDF +Route::get("/pdf/{menuPlan}", "MenuPlanController@genPDF")->name("pdf.genPDF")->hasParameter("Id"); + Route::resource("contacts", "ContactController"); Route::resource("menu-plans", "MenuPlanController");