mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Documents
This commit is contained in:
parent
8ed382a0b7
commit
049e9032cb
@ -7,10 +7,35 @@ use App\Http\Requests\Document\ShowDocumentRequest;
|
|||||||
use App\Http\Requests\Document\StoreDocumentRequest;
|
use App\Http\Requests\Document\StoreDocumentRequest;
|
||||||
use App\Http\Requests\Document\UpdateDocumentRequest;
|
use App\Http\Requests\Document\UpdateDocumentRequest;
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
|
use App\Repositories\DocumentRepository;
|
||||||
|
use App\Transformers\DocumentTransformer;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class DocumentController extends BaseController
|
class DocumentController extends BaseController
|
||||||
{
|
{
|
||||||
|
use MakesHash;
|
||||||
|
|
||||||
|
protected $entity_type = Document::class;
|
||||||
|
|
||||||
|
protected $entity_transformer = DocumentTransformer::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var DocumentRepository
|
||||||
|
*/
|
||||||
|
protected $document_repo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DocumentController constructor.
|
||||||
|
* @param DocumentRepository $document_repo
|
||||||
|
*/
|
||||||
|
public function __construct(DocumentRepository $document_repo)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->document_repo = $document_repo;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*
|
*
|
||||||
@ -49,12 +74,15 @@ class DocumentController extends BaseController
|
|||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function show(ShowDocumentRequest $request, Document $document)
|
public function show(ShowDocumentRequest $request, Document $document)
|
||||||
|
{
|
||||||
|
return $this->itemResponse($document);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function download(DownloadDocumentRequest $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());
|
||||||
}, basename($document->generateUrl()));
|
}, basename($document->generateUrl()));
|
||||||
|
|
||||||
//return response()->download($document->generateUrl());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,11 +116,35 @@ class DocumentController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function destroy(DestroyDocumentRequest $request, Document $document)
|
public function destroy(DestroyDocumentRequest $request, Document $document)
|
||||||
{
|
{
|
||||||
//
|
$this->document_repo->delete($document);
|
||||||
|
|
||||||
|
return response()->json(['message'=>'success']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function bulk()
|
public function bulk()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$action = request()->input('action');
|
||||||
|
|
||||||
|
$ids = request()->input('ids');
|
||||||
|
|
||||||
|
$documents = Document::withTrashed()->whereIn('id', $this->transformKeys($ids))->company()->get();
|
||||||
|
|
||||||
|
if (!$invoices) {
|
||||||
|
return response()->json(['message' => 'No Documents Found']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send the other actions to the switch
|
||||||
|
*/
|
||||||
|
$documents->each(function ($document, $key) use ($action) {
|
||||||
|
if (auth()->user()->can('edit', $document)) {
|
||||||
|
$this->{$action}($document);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/* Need to understand which permission are required for the given bulk action ie. view / edit */
|
||||||
|
|
||||||
|
return $this->listResponse(Document::withTrashed()->whereIn('id', $this->transformKeys($ids))->company());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,4 +119,9 @@ class Document extends BaseModel
|
|||||||
|
|
||||||
//return route('document.show', ['document' => $this->hashed_id]);
|
//return route('document.show', ['document' => $this->hashed_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteFile()
|
||||||
|
{
|
||||||
|
Storage::disk($this->disk)->delete($this->url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,9 @@ class PaymentTransformer extends EntityTransformer
|
|||||||
|
|
||||||
protected $serializer;
|
protected $serializer;
|
||||||
|
|
||||||
protected $defaultIncludes = ['invoices'];
|
protected $defaultIncludes = [
|
||||||
|
// 'invoices'
|
||||||
|
];
|
||||||
|
|
||||||
protected $availableIncludes = [
|
protected $availableIncludes = [
|
||||||
'client',
|
'client',
|
||||||
|
@ -265,29 +265,29 @@ class RandomDataSeeder extends Seeder
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
// if (config('ninja.testvars.stripe')) {
|
if (config('ninja.testvars.stripe')) {
|
||||||
// $cg = new CompanyGateway;
|
$cg = new CompanyGateway;
|
||||||
// $cg->company_id = $company->id;
|
$cg->company_id = $company->id;
|
||||||
// $cg->user_id = $user->id;
|
$cg->user_id = $user->id;
|
||||||
// $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
|
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
|
||||||
// $cg->require_cvv = true;
|
$cg->require_cvv = true;
|
||||||
// $cg->show_billing_address = true;
|
$cg->show_billing_address = true;
|
||||||
// $cg->show_shipping_address = true;
|
$cg->show_shipping_address = true;
|
||||||
// $cg->update_details = true;
|
$cg->update_details = true;
|
||||||
// $cg->config = encrypt(config('ninja.testvars.stripe'));
|
$cg->config = encrypt(config('ninja.testvars.stripe'));
|
||||||
// $cg->save();
|
$cg->save();
|
||||||
|
|
||||||
// $cg = new CompanyGateway;
|
$cg = new CompanyGateway;
|
||||||
// $cg->company_id = $company->id;
|
$cg->company_id = $company->id;
|
||||||
// $cg->user_id = $user->id;
|
$cg->user_id = $user->id;
|
||||||
// $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
|
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
|
||||||
// $cg->require_cvv = true;
|
$cg->require_cvv = true;
|
||||||
// $cg->show_billing_address = true;
|
$cg->show_billing_address = true;
|
||||||
// $cg->show_shipping_address = true;
|
$cg->show_shipping_address = true;
|
||||||
// $cg->update_details = true;
|
$cg->update_details = true;
|
||||||
// $cg->config = encrypt(config('ninja.testvars.stripe'));
|
$cg->config = encrypt(config('ninja.testvars.stripe'));
|
||||||
// $cg->save();
|
$cg->save();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (config('ninja.testvars.paypal')) {
|
// if (config('ninja.testvars.paypal')) {
|
||||||
// $cg = new CompanyGateway;
|
// $cg = new CompanyGateway;
|
||||||
@ -315,18 +315,18 @@ class RandomDataSeeder extends Seeder
|
|||||||
// $cg->save();
|
// $cg->save();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if(config('ninja.testvars.authorize')) {
|
// if(config('ninja.testvars.authorize')) {
|
||||||
$cg = new CompanyGateway;
|
// $cg = new CompanyGateway;
|
||||||
$cg->company_id = $company->id;
|
// $cg->company_id = $company->id;
|
||||||
$cg->user_id = $user->id;
|
// $cg->user_id = $user->id;
|
||||||
$cg->gateway_key = '3b6621f970ab18887c4f6dca78d3f8bb';
|
// $cg->gateway_key = '3b6621f970ab18887c4f6dca78d3f8bb';
|
||||||
$cg->require_cvv = true;
|
// $cg->require_cvv = true;
|
||||||
$cg->show_billing_address = true;
|
// $cg->show_billing_address = true;
|
||||||
$cg->show_shipping_address = true;
|
// $cg->show_shipping_address = true;
|
||||||
$cg->update_details = true;
|
// $cg->update_details = true;
|
||||||
$cg->config = encrypt(config('ninja.testvars.authorize'));
|
// $cg->config = encrypt(config('ninja.testvars.authorize'));
|
||||||
$cg->save();
|
// $cg->save();
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user