mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -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\UpdateDocumentRequest;
|
||||
use App\Models\Document;
|
||||
use App\Repositories\DocumentRepository;
|
||||
use App\Transformers\DocumentTransformer;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
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.
|
||||
*
|
||||
@ -50,11 +75,14 @@ class DocumentController extends BaseController
|
||||
*/
|
||||
public function show(ShowDocumentRequest $request, Document $document)
|
||||
{
|
||||
return response()->streamDownload(function () use($document) {
|
||||
echo file_get_contents($document->generateUrl());
|
||||
}, basename($document->generateUrl()));
|
||||
return $this->itemResponse($document);
|
||||
}
|
||||
|
||||
//return response()->download($document->generateUrl());
|
||||
public function download(DownloadDocumentRequest $request, Document $document)
|
||||
{
|
||||
return response()->streamDownload(function () use($document) {
|
||||
echo file_get_contents($document->generateUrl());
|
||||
}, basename($document->generateUrl()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,11 +116,35 @@ class DocumentController extends BaseController
|
||||
*/
|
||||
public function destroy(DestroyDocumentRequest $request, Document $document)
|
||||
{
|
||||
//
|
||||
$this->document_repo->delete($document);
|
||||
|
||||
return response()->json(['message'=>'success']);
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
public function deleteFile()
|
||||
{
|
||||
Storage::disk($this->disk)->delete($this->url);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,9 @@ class PaymentTransformer extends EntityTransformer
|
||||
|
||||
protected $serializer;
|
||||
|
||||
protected $defaultIncludes = ['invoices'];
|
||||
protected $defaultIncludes = [
|
||||
// 'invoices'
|
||||
];
|
||||
|
||||
protected $availableIncludes = [
|
||||
'client',
|
||||
|
@ -265,29 +265,29 @@ class RandomDataSeeder extends Seeder
|
||||
]);
|
||||
|
||||
|
||||
// if (config('ninja.testvars.stripe')) {
|
||||
// $cg = new CompanyGateway;
|
||||
// $cg->company_id = $company->id;
|
||||
// $cg->user_id = $user->id;
|
||||
// $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
|
||||
// $cg->require_cvv = true;
|
||||
// $cg->show_billing_address = true;
|
||||
// $cg->show_shipping_address = true;
|
||||
// $cg->update_details = true;
|
||||
// $cg->config = encrypt(config('ninja.testvars.stripe'));
|
||||
// $cg->save();
|
||||
if (config('ninja.testvars.stripe')) {
|
||||
$cg = new CompanyGateway;
|
||||
$cg->company_id = $company->id;
|
||||
$cg->user_id = $user->id;
|
||||
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
|
||||
$cg->require_cvv = true;
|
||||
$cg->show_billing_address = true;
|
||||
$cg->show_shipping_address = true;
|
||||
$cg->update_details = true;
|
||||
$cg->config = encrypt(config('ninja.testvars.stripe'));
|
||||
$cg->save();
|
||||
|
||||
// $cg = new CompanyGateway;
|
||||
// $cg->company_id = $company->id;
|
||||
// $cg->user_id = $user->id;
|
||||
// $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
|
||||
// $cg->require_cvv = true;
|
||||
// $cg->show_billing_address = true;
|
||||
// $cg->show_shipping_address = true;
|
||||
// $cg->update_details = true;
|
||||
// $cg->config = encrypt(config('ninja.testvars.stripe'));
|
||||
// $cg->save();
|
||||
// }
|
||||
$cg = new CompanyGateway;
|
||||
$cg->company_id = $company->id;
|
||||
$cg->user_id = $user->id;
|
||||
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
|
||||
$cg->require_cvv = true;
|
||||
$cg->show_billing_address = true;
|
||||
$cg->show_shipping_address = true;
|
||||
$cg->update_details = true;
|
||||
$cg->config = encrypt(config('ninja.testvars.stripe'));
|
||||
$cg->save();
|
||||
}
|
||||
|
||||
// if (config('ninja.testvars.paypal')) {
|
||||
// $cg = new CompanyGateway;
|
||||
@ -315,18 +315,18 @@ class RandomDataSeeder extends Seeder
|
||||
// $cg->save();
|
||||
// }
|
||||
|
||||
if(config('ninja.testvars.authorize')) {
|
||||
$cg = new CompanyGateway;
|
||||
$cg->company_id = $company->id;
|
||||
$cg->user_id = $user->id;
|
||||
$cg->gateway_key = '3b6621f970ab18887c4f6dca78d3f8bb';
|
||||
$cg->require_cvv = true;
|
||||
$cg->show_billing_address = true;
|
||||
$cg->show_shipping_address = true;
|
||||
$cg->update_details = true;
|
||||
$cg->config = encrypt(config('ninja.testvars.authorize'));
|
||||
$cg->save();
|
||||
}
|
||||
// if(config('ninja.testvars.authorize')) {
|
||||
// $cg = new CompanyGateway;
|
||||
// $cg->company_id = $company->id;
|
||||
// $cg->user_id = $user->id;
|
||||
// $cg->gateway_key = '3b6621f970ab18887c4f6dca78d3f8bb';
|
||||
// $cg->require_cvv = true;
|
||||
// $cg->show_billing_address = true;
|
||||
// $cg->show_shipping_address = true;
|
||||
// $cg->update_details = true;
|
||||
// $cg->config = encrypt(config('ninja.testvars.authorize'));
|
||||
// $cg->save();
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user