Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ConsoleTVs committed Apr 17, 2018
1 parent b248716 commit ad2140b
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 13 deletions.
16 changes: 8 additions & 8 deletions Classes/Invoice.php
Expand Up @@ -305,9 +305,9 @@ public function taxPriceFormatted()
*
* @return self
*/
private function generate($template = 'vendor.invoices.default')
private function generate()
{
$this->pdf = PDF::generate($this, $template);
$this->pdf = PDF::generate($this);

return $this;
}
Expand All @@ -321,9 +321,9 @@ private function generate($template = 'vendor.invoices.default')
*
* @return response
*/
public function download($name = 'invoice', $template = 'vendor.invoices.default')
public function download($name = 'invoice')
{
$this->generate($template);
$this->generate();

return $this->pdf->stream($name);
}
Expand All @@ -336,9 +336,9 @@ public function download($name = 'invoice', $template = 'vendor.invoices.default
* @param string $name
*
*/
public function save($name = 'invoice.pdf', $template = 'vendor.invoices.default')
public function save($name = 'invoice.pdf')
{
$invoice = $this->generate($template);
$invoice = $this->generate();

Storage::put($name, $invoice->pdf->output());
}
Expand All @@ -352,9 +352,9 @@ public function save($name = 'invoice.pdf', $template = 'vendor.invoices.default
*
* @return response
*/
public function show($name = 'invoice', $template = 'vendor.invoices.default')
public function show($name = 'invoice')
{
$this->generate($template);
$this->generate();

return $this->pdf->stream($name, ['Attachment' => false]);
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/PDF.php
Expand Up @@ -31,7 +31,7 @@ class PDF
*
* @return Dompdf\Dompdf
*/
public static function generate(Invoice $invoice, $template = 'invoices::default')
public static function generate(Invoice $invoice, $template = 'default')
{
$template = strtolower($template);

Expand All @@ -51,7 +51,7 @@ public static function generate(Invoice $invoice, $template = 'invoices::default

$pdf->setHttpContext($context);

$pdf->loadHtml(View::make($template, ['invoice' => $invoice]));
$pdf->loadHtml(View::make('invoices::'.$template, ['invoice' => $invoice]));
$pdf->render();

return $pdf;
Expand Down
48 changes: 48 additions & 0 deletions InvoicesServiceProvider.php
@@ -0,0 +1,48 @@
<?php
/**
* This file is part of consoletvs/invoices.
*
* (c) Erik Campobadal <soc@erik.cat>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace ConsoleTVs\Invoices;

use Illuminate\Support\ServiceProvider;

/**
* This is the InvoicesServiceProvider class.
*
* @author Erik Campobadal <soc@erik.cat>
*/
class InvoicesServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->loadViewsFrom(__DIR__.'/Templates', 'invoices');

$this->publishes([
__DIR__.'/Templates' => resource_path('views/vendor/invoices'),
__DIR__.'/Config/invoices.php' => config_path('invoices.php'),
], 'invoices');
}

/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(
__DIR__.'/Config/invoices.php', 'invoices'
);
}
}
67 changes: 65 additions & 2 deletions README.md
@@ -1,4 +1,4 @@
<p align="center"><a href="https://erik.cat/projects/invoices"><img src="https://image.prntscr.com/image/jeO1UBSVSHi5NQ_lFH9rLA.png"></a></p>
<p align="center"><a href="https://erik.cat/projects/Invoices"><img height="250" src="http://i.imgur.com/t9G3rFM.png"></a></p>

<p align="center">
<a href="https://styleci.io/repos/92863426"><img src="https://styleci.io/repos/92863426/shield?branch=master&style=flat" alt="StyleCI Status"></a>
Expand All @@ -13,4 +13,67 @@
Invoices is a Laravel library that generates a PDF invoice for your customers. The PDF can be either downloaded or
streamed in the browser. It's highly customizable and you can modify the whole output view as well.

<p align="center"><a href="https://erik.cat/projects/invoices"><img height="250" src="https://i.imgur.com/F0PDyYE.png"></a></p>
## Sample Invoice

This is a sample invoice generated using this library:

![Sample Invoice](https://i.gyazo.com/768f5b59791162e432f9cdfa15f017bc.png)

```php
$invoice = ConsoleTVs\Invoices\Classes\Invoice::make()
->addItem('Test Item', 10.25, 2, 1412)
->addItem('Test Item 2', 5, 2, 923)
->addItem('Test Item 3', 15.55, 5, 42)
->addItem('Test Item 4', 1.25, 1, 923)
->addItem('Test Item 5', 3.12, 1, 3142)
->addItem('Test Item 6', 6.41, 3, 452)
->addItem('Test Item 7', 2.86, 1, 1526)
->number(4021)
->tax(21)
->notes('Lrem ipsum dolor sit amet, consectetur adipiscing elit.')
->customer([
'name' => 'Èrik Campobadal Forés',
'id' => '12345678A',
'phone' => '+34 123 456 789',
'location' => 'C / Unknown Street 1st',
'zip' => '08241',
'city' => 'Manresa',
'country' => 'Spain',
])
->download('demo');
//or save it somewhere
->save('public/myinvoicename.pdf');
```

## Documentation

<p align="center">
<a href="https://erik.cat/projects/Invoices/docs"><img src="http://i.imgur.com/47WnADd.png"></a>
</p>

## License

```
MIT License
Copyright (c) 2017 Erik Campobadal
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
9 changes: 8 additions & 1 deletion composer.json
@@ -1,5 +1,5 @@
{
"name": "newridetech/invoices",
"name": "consoletvs/invoices",
"description": "Generate PDF invoices for your customers in laravel",
"type": "library",
"keywords": [
Expand All @@ -25,5 +25,12 @@
"ConsoleTVs\\Invoices\\": "."
}
},
"extra": {
"laravel": {
"providers": [
"ConsoleTVs\\Invoices\\InvoicesServiceProvider"
]
}
},
"minimum-stability": "dev"
}

0 comments on commit ad2140b

Please sign in to comment.