mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Merge pull request #3836 from turbo124/v2
Documents loaded behind route
This commit is contained in:
commit
15dc8fb865
54
app/Events/Document/DocumentWasArchived.php
Normal file
54
app/Events/Document/DocumentWasArchived.php
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Events\Document;
|
||||||
|
|
||||||
|
use App\Models\Document;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DocumentWasArchived.
|
||||||
|
*/
|
||||||
|
class DocumentWasArchived
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Document
|
||||||
|
*/
|
||||||
|
public $document;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param Document $document
|
||||||
|
*/
|
||||||
|
public function __construct(Document $document)
|
||||||
|
{
|
||||||
|
$this->document = $document;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
38
app/Events/Document/DocumentWasCreated.php
Normal file
38
app/Events/Document/DocumentWasCreated.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Events\Document;
|
||||||
|
|
||||||
|
use App\Models\Document;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DocumentWasCreated.
|
||||||
|
*/
|
||||||
|
class DocumentWasCreated
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Document
|
||||||
|
*/
|
||||||
|
public $document;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param Document $document
|
||||||
|
*/
|
||||||
|
public function __construct(Document $document)
|
||||||
|
{
|
||||||
|
$this->document = $document;
|
||||||
|
}
|
||||||
|
}
|
38
app/Events/Document/DocumentWasDeleted.php
Normal file
38
app/Events/Document/DocumentWasDeleted.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Events\Document;
|
||||||
|
|
||||||
|
use App\Models\Document;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DocumentWasDeleted.
|
||||||
|
*/
|
||||||
|
class DocumentWasDeleted
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Document
|
||||||
|
*/
|
||||||
|
public $document;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param Document $document
|
||||||
|
*/
|
||||||
|
public function __construct(Document $document)
|
||||||
|
{
|
||||||
|
$this->document = $document;
|
||||||
|
}
|
||||||
|
}
|
38
app/Events/Document/DocumentWasRestored.php
Normal file
38
app/Events/Document/DocumentWasRestored.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Events\Document;
|
||||||
|
|
||||||
|
use App\Models\Document;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DocumentWasRestored.
|
||||||
|
*/
|
||||||
|
class DocumentWasRestored
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Document
|
||||||
|
*/
|
||||||
|
public $document;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param Document $document
|
||||||
|
*/
|
||||||
|
public function __construct(Document $document)
|
||||||
|
{
|
||||||
|
$this->document = $document;
|
||||||
|
}
|
||||||
|
}
|
38
app/Events/Document/DocumentWasUpdated.php
Normal file
38
app/Events/Document/DocumentWasUpdated.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Events\Document;
|
||||||
|
|
||||||
|
use App\Models\Document;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DocumentWasUpdated.
|
||||||
|
*/
|
||||||
|
class DocumentWasUpdated
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Document
|
||||||
|
*/
|
||||||
|
public $document;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param Document $document
|
||||||
|
*/
|
||||||
|
public function __construct(Document $document)
|
||||||
|
{
|
||||||
|
$this->document = $document;
|
||||||
|
}
|
||||||
|
}
|
@ -78,7 +78,7 @@ class DocumentController extends BaseController
|
|||||||
return $this->itemResponse($document);
|
return $this->itemResponse($document);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function download(DownloadDocumentRequest $request, Document $document)
|
public function download(ShowDocumentRequest $request, Document $document)
|
||||||
{
|
{
|
||||||
return response()->streamDownload(function () use($document) {
|
return response()->streamDownload(function () use($document) {
|
||||||
echo file_get_contents($document->generateUrl());
|
echo file_get_contents($document->generateUrl());
|
||||||
@ -93,7 +93,7 @@ class DocumentController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function edit(EditDocumentRegquest $request, Document $document)
|
public function edit(EditDocumentRegquest $request, Document $document)
|
||||||
{
|
{
|
||||||
//
|
return $this->itemResponse($document);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,7 +105,7 @@ class DocumentController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function update(UpdateDocumentRequest $request, Document $document)
|
public function update(UpdateDocumentRequest $request, Document $document)
|
||||||
{
|
{
|
||||||
//
|
return $this->itemResponse($document);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,9 +115,7 @@ class Document extends BaseModel
|
|||||||
|
|
||||||
public function generateRoute($absolute = false)
|
public function generateRoute($absolute = false)
|
||||||
{
|
{
|
||||||
return route('api.documents.show', ['document' => $this->hashed_id]);
|
return route('api.documents.show', ['document' => $this->hashed_id]) . '/download';
|
||||||
|
|
||||||
//return route('document.show', ['document' => $this->hashed_id]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteFile()
|
public function deleteFile()
|
||||||
|
@ -111,6 +111,17 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
],
|
],
|
||||||
ClientWasRestored::class =>[
|
ClientWasRestored::class =>[
|
||||||
],
|
],
|
||||||
|
// Documents
|
||||||
|
DocumentWasCreated::class =>[
|
||||||
|
],
|
||||||
|
DocumentWasArchived::class =>[
|
||||||
|
],
|
||||||
|
DocumentWasUpdated::class =>[
|
||||||
|
],
|
||||||
|
DocumentWasDeleted::class =>[
|
||||||
|
],
|
||||||
|
DocumentWasRestored::class =>[
|
||||||
|
],
|
||||||
CreditWasMarkedSent::class => [
|
CreditWasMarkedSent::class => [
|
||||||
],
|
],
|
||||||
//Designs
|
//Designs
|
||||||
|
50
app/Repositories/DocumentRepository.php
Normal file
50
app/Repositories/DocumentRepository.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Repositories;
|
||||||
|
|
||||||
|
use App\Models\Document;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for document repository.
|
||||||
|
*/
|
||||||
|
class DocumentRepository extends BaseRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the class name.
|
||||||
|
*
|
||||||
|
* @return string The class name.
|
||||||
|
*/
|
||||||
|
public function getClassName()
|
||||||
|
{
|
||||||
|
return Document::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($document)
|
||||||
|
{
|
||||||
|
$document->deleteFile();
|
||||||
|
$document->forceDelete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function restore($document)
|
||||||
|
{
|
||||||
|
if (! $document->trashed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$document->restore();
|
||||||
|
|
||||||
|
if (class_exists($className)) {
|
||||||
|
event(new $className($document));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,6 @@
|
|||||||
<title>Invoice Ninja</title>
|
<title>Invoice Ninja</title>
|
||||||
<meta name="report_errors" content="{{ $report_errors }}">
|
<meta name="report_errors" content="{{ $report_errors }}">
|
||||||
<meta name="google-signin-client_id" content="{{ config('services.google.client_id') }}">
|
<meta name="google-signin-client_id" content="{{ config('services.google.client_id') }}">
|
||||||
<meta name="minimum_client_version" content="{{ config('ninja.minimum_client_version') }}">
|
|
||||||
<link rel="manifest" href="manifest.json">
|
<link rel="manifest" href="manifest.json">
|
||||||
</head>
|
</head>
|
||||||
<body style="background-color:#888888;">
|
<body style="background-color:#888888;">
|
||||||
|
@ -70,7 +70,7 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
|
|||||||
Route::post('vendors/bulk', 'VendorController@bulk')->name('vendors.bulk');
|
Route::post('vendors/bulk', 'VendorController@bulk')->name('vendors.bulk');
|
||||||
|
|
||||||
Route::resource('documents', 'DocumentController');// name = (documents. index / create / show / update / destroy / edit
|
Route::resource('documents', 'DocumentController');// name = (documents. index / create / show / update / destroy / edit
|
||||||
|
Route::get('documents/{document}/download', 'DocumentController@download')->name('documents.download');
|
||||||
Route::post('documents/bulk', 'DocumentController@bulk')->name('documents.bulk');
|
Route::post('documents/bulk', 'DocumentController@bulk')->name('documents.bulk');
|
||||||
|
|
||||||
Route::resource('client_statement', 'ClientStatementController@statement');// name = (client_statement. index / create / show / update / destroy / edit
|
Route::resource('client_statement', 'ClientStatementController@statement');// name = (client_statement. index / create / show / update / destroy / edit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user