diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index c3c3dd10eda9..28d59825f337 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -50,7 +50,7 @@ class InvoiceController extends Controller if (request()->ajax()) { return DataTables::of($invoices)->addColumn('action', function ($invoice) { - return ''.ctrans('texts.view').''; + return ''.ctrans('texts.view').''; }) ->addColumn('checkbox', function ($invoice){ return ''; @@ -90,7 +90,7 @@ class InvoiceController extends Controller 'invoice' => $invoice ]; - return view('portal.default.invoices.show', $invoice); + return view('portal.default.invoices.show', $data); } /** diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 7e2d694779ff..e8bcf30c25fd 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -11,6 +11,7 @@ namespace App\Models; +use App\Events\Invoice\InvoiceWasUpdated; use App\Helpers\Invoice\InvoiceCalc; use App\Models\Currency; use App\Models\Filterable; @@ -246,6 +247,7 @@ class Invoice extends BaseModel * Returns the template for the invoice * * @return string Either the template view, OR the template HTML string + * @todo this needs attention, invoice->settings needs clarification */ public function design() :string { @@ -265,4 +267,17 @@ class Invoice extends BaseModel return $invoice_calc->build(); } + + public function pdf_url() + { + $public_path = 'storage/' . $this->client->client_hash . '/invoices/'. $this->invoice_number . '.pdf'; + + $storage_path = 'public/' . $this->client->client_hash . '/invoices/'. $this->invoice_number . '.pdf'; + + if(!Storage::exists($storage_path)) { + event(new InvoiceWasUpdated($this)); + } + + return $public_path; + } } \ No newline at end of file diff --git a/composer.json b/composer.json index 99ab34b082b9..6a93d6a9cbd0 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,7 @@ "laravel/framework": "5.8.*", "laravel/socialite": "^3.1", "laravel/tinker": "^1.0", + "laravelcollective/html": "5.8.*", "league/fractal": "^0.17.0", "league/omnipay": "^3", "nwidart/laravel-modules": "^4.0", @@ -42,8 +43,7 @@ "webpatser/laravel-countries": "dev-master#75992ad", "wildbit/postmark-php": "^2.6", "yajra/laravel-datatables-html": "^4.0", - "yajra/laravel-datatables-oracle": "~9.0", - "laravelcollective/html": "5.8.*" + "yajra/laravel-datatables-oracle": "~9.0" }, "require-dev": { "barryvdh/laravel-debugbar": "^3.2", diff --git a/resources/views/portal/default/invoices/show.blade.php b/resources/views/portal/default/invoices/show.blade.php index 897dc00b9e9b..0c16d11a84eb 100644 --- a/resources/views/portal/default/invoices/show.blade.php +++ b/resources/views/portal/default/invoices/show.blade.php @@ -3,9 +3,22 @@
- - diff --git a/routes/client.php b/routes/client.php index 4fbfe12fc07c..96c6b76b516a 100644 --- a/routes/client.php +++ b/routes/client.php @@ -18,8 +18,8 @@ Route::group(['middleware' => ['auth:contact'], 'prefix' => 'client', 'as' => 'c Route::get('invoices', 'ClientPortal\InvoiceController@index')->name('invoices.index'); Route::post('invoices/payment', 'ClientPortal\InvoiceController@bulk')->name('invoices.bulk'); - Route::get('invoice/{invoice}', 'ClientPortal\InvoiceController@show')->name('invoice.show'); - Route::get('invoice/{invoice_invitation}', 'ClientPortal\InvoiceController@show')->name('invoice.show_invitation'); + Route::get('invoices/{invoice}', 'ClientPortal\InvoiceController@show')->name('invoice.show'); + Route::get('invoices/{invoice_invitation}', 'ClientPortal\InvoiceController@show')->name('invoice.show_invitation'); Route::get('recurring_invoices', 'ClientPortal\RecurringInvoiceController@index')->name('recurring_invoices.index');