mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on form requests
This commit is contained in:
parent
65c8ef4078
commit
933f2968d6
@ -12,6 +12,9 @@ use Response;
|
||||
use App\Models\Document;
|
||||
use App\Ninja\Repositories\DocumentRepository;
|
||||
|
||||
use App\Http\Requests\DocumentRequest;
|
||||
use App\Http\Requests\CreateDocumentRequest;
|
||||
|
||||
class DocumentController extends BaseController
|
||||
{
|
||||
protected $documentRepo;
|
||||
@ -24,14 +27,9 @@ class DocumentController extends BaseController
|
||||
$this->documentRepo = $documentRepo;
|
||||
}
|
||||
|
||||
public function get($publicId)
|
||||
public function get(DocumentRequest $request)
|
||||
{
|
||||
$document = Document::scope($publicId)
|
||||
->firstOrFail();
|
||||
|
||||
$this->authorize('view', $document);
|
||||
|
||||
return static::getDownloadResponse($document);
|
||||
return static::getDownloadResponse($request->entity());
|
||||
}
|
||||
|
||||
public static function getDownloadResponse($document){
|
||||
@ -60,12 +58,9 @@ class DocumentController extends BaseController
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getPreview($publicId)
|
||||
public function getPreview(DocumentRequest $request)
|
||||
{
|
||||
$document = Document::scope($publicId)
|
||||
->firstOrFail();
|
||||
|
||||
$this->authorize('view', $document);
|
||||
$document = $request->entity();
|
||||
|
||||
if(empty($document->preview)){
|
||||
return Response::view('error', array('error'=>'Preview does not exist!'), 404);
|
||||
@ -83,16 +78,14 @@ class DocumentController extends BaseController
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getVFSJS($publicId, $name){
|
||||
$document = Document::scope($publicId)
|
||||
->firstOrFail();
|
||||
public function getVFSJS(DocumentRequest $request, $publicId, $name)
|
||||
{
|
||||
$document = $request->entity();
|
||||
|
||||
if(substr($name, -3)=='.js'){
|
||||
$name = substr($name, 0, -3);
|
||||
}
|
||||
|
||||
$this->authorize('view', $document);
|
||||
|
||||
if(!$document->isPDFEmbeddable()){
|
||||
return Response::view('error', array('error'=>'Image does not exist!'), 404);
|
||||
}
|
||||
@ -106,14 +99,12 @@ class DocumentController extends BaseController
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function postUpload()
|
||||
public function postUpload(CreateDocumentRequest $request)
|
||||
{
|
||||
if (!Utils::hasFeature(FEATURE_DOCUMENTS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->authorizeCreate();
|
||||
|
||||
$result = $this->documentRepo->upload(Input::all()['file'], $doc_array);
|
||||
|
||||
if(is_string($result)){
|
||||
|
@ -18,8 +18,8 @@ use App\Ninja\Repositories\InvoiceRepository;
|
||||
use App\Ninja\Mailers\ContactMailer as Mailer;
|
||||
use App\Http\Controllers\BaseAPIController;
|
||||
use App\Ninja\Transformers\InvoiceTransformer;
|
||||
use App\Http\Requests\CreateInvoiceRequest;
|
||||
use App\Http\Requests\UpdateInvoiceRequest;
|
||||
use App\Http\Requests\CreateInvoiceAPIRequest;
|
||||
use App\Http\Requests\UpdateInvoiceAPIRequest;
|
||||
use App\Services\InvoiceService;
|
||||
|
||||
class InvoiceApiController extends BaseAPIController
|
||||
@ -139,7 +139,7 @@ class InvoiceApiController extends BaseAPIController
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function store(CreateInvoiceRequest $request)
|
||||
public function store(CreateInvoiceAPIRequest $request)
|
||||
{
|
||||
$data = Input::all();
|
||||
$error = null;
|
||||
@ -351,7 +351,7 @@ class InvoiceApiController extends BaseAPIController
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function update(UpdateInvoiceRequest $request, $publicId)
|
||||
public function update(UpdateInvoiceAPIRequest $request, $publicId)
|
||||
{
|
||||
if ($request->action == ACTION_ARCHIVE) {
|
||||
$invoice = Invoice::scope($publicId)->firstOrFail();
|
||||
|
@ -27,7 +27,10 @@ use App\Ninja\Repositories\ClientRepository;
|
||||
use App\Ninja\Repositories\DocumentRepository;
|
||||
use App\Services\InvoiceService;
|
||||
use App\Services\RecurringInvoiceService;
|
||||
use App\Http\Requests\SaveInvoiceWithClientRequest;
|
||||
|
||||
use App\Http\Requests\InvoiceRequest;
|
||||
use App\Http\Requests\CreateInvoiceRequest;
|
||||
use App\Http\Requests\UpdateInvoiceRequest;
|
||||
|
||||
class InvoiceController extends BaseController
|
||||
{
|
||||
@ -88,15 +91,10 @@ class InvoiceController extends BaseController
|
||||
return $this->recurringInvoiceService->getDatatable($accountId, $clientPublicId, ENTITY_RECURRING_INVOICE, $search);
|
||||
}
|
||||
|
||||
public function edit($publicId, $clone = false)
|
||||
public function edit(InvoiceRequest $request, $publicId, $clone = false)
|
||||
{
|
||||
$account = Auth::user()->account;
|
||||
$invoice = Invoice::scope($publicId)
|
||||
->with('invitations', 'account.country', 'client.contacts', 'client.country', 'invoice_items', 'documents', 'expenses', 'expenses.documents', 'payments')
|
||||
->withTrashed()
|
||||
->firstOrFail();
|
||||
|
||||
$this->authorize('edit', $invoice);
|
||||
$invoice = $request->entity()->load('invitations', 'account.country', 'client.contacts', 'client.country', 'invoice_items', 'documents', 'expenses', 'expenses.documents', 'payments');
|
||||
|
||||
$entityType = $invoice->getEntityType();
|
||||
|
||||
@ -120,7 +118,7 @@ class InvoiceController extends BaseController
|
||||
} else {
|
||||
Utils::trackViewed($invoice->getDisplayName().' - '.$invoice->client->getDisplayName(), $invoice->getEntityType());
|
||||
$method = 'PUT';
|
||||
$url = "{$entityType}s/{$publicId}";
|
||||
$url = "{$entityType}s/{$invoice->public_id}";
|
||||
$clients->whereId($invoice->client_id);
|
||||
}
|
||||
|
||||
@ -229,16 +227,15 @@ class InvoiceController extends BaseController
|
||||
return View::make('invoices.edit', $data);
|
||||
}
|
||||
|
||||
public function create($clientPublicId = 0, $isRecurring = false)
|
||||
public function create(InvoiceRequest $request, $clientPublicId = 0, $isRecurring = false)
|
||||
{
|
||||
$this->authorizeCreate();
|
||||
|
||||
$account = Auth::user()->account;
|
||||
|
||||
$entityType = $isRecurring ? ENTITY_RECURRING_INVOICE : ENTITY_INVOICE;
|
||||
$clientId = null;
|
||||
|
||||
if ($clientPublicId) {
|
||||
$clientId = Client::getPrivateId($clientPublicId);
|
||||
if ($request->client_id) {
|
||||
$clientId = Client::getPrivateId($request->client_id);
|
||||
}
|
||||
|
||||
$invoice = $account->createInvoice($entityType, $clientId);
|
||||
@ -267,9 +264,9 @@ class InvoiceController extends BaseController
|
||||
return View::make('invoices.edit', $data);
|
||||
}
|
||||
|
||||
public function createRecurring($clientPublicId = 0)
|
||||
public function createRecurring(ClientRequest $request, $clientPublicId = 0)
|
||||
{
|
||||
return self::create($clientPublicId, true);
|
||||
return self::create($request, $clientPublicId, true);
|
||||
}
|
||||
|
||||
private static function getViewModel($invoice)
|
||||
@ -395,7 +392,7 @@ class InvoiceController extends BaseController
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function store(SaveInvoiceWithClientRequest $request)
|
||||
public function store(CreateInvoiceRequest $request)
|
||||
{
|
||||
$data = $request->input();
|
||||
$data['documents'] = $request->file('documents');
|
||||
@ -434,7 +431,7 @@ class InvoiceController extends BaseController
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function update(SaveInvoiceWithClientRequest $request)
|
||||
public function update(UpdateInvoiceRequest $request)
|
||||
{
|
||||
$data = $request->input();
|
||||
$data['documents'] = $request->file('documents');
|
||||
@ -521,7 +518,7 @@ class InvoiceController extends BaseController
|
||||
{
|
||||
Session::reflash();
|
||||
|
||||
return Redirect::to("invoices/{$publicId}/edit");
|
||||
return Redirect::to("invoices/$publicId/edit");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -558,9 +555,9 @@ class InvoiceController extends BaseController
|
||||
return Redirect::to('invoices/'.$clone->public_id);
|
||||
}
|
||||
|
||||
public function cloneInvoice($publicId)
|
||||
public function cloneInvoice(InvoiceRequest $request, $publicId)
|
||||
{
|
||||
return self::edit($publicId, true);
|
||||
return self::edit($request, $publicId, true);
|
||||
}
|
||||
|
||||
public function invoiceHistory($publicId)
|
||||
|
@ -26,6 +26,7 @@ use App\Ninja\Repositories\InvoiceRepository;
|
||||
use App\Ninja\Repositories\ClientRepository;
|
||||
use App\Events\QuoteInvitationWasApproved;
|
||||
use App\Services\InvoiceService;
|
||||
use App\Http\Requests\InvoiceRequest;
|
||||
|
||||
class QuoteController extends BaseController
|
||||
{
|
||||
@ -78,10 +79,8 @@ class QuoteController extends BaseController
|
||||
return $this->invoiceService->getDatatable($accountId, $clientPublicId, ENTITY_QUOTE, $search);
|
||||
}
|
||||
|
||||
public function create($clientPublicId = 0)
|
||||
public function create(InvoiceRequest $request, $clientPublicId = 0)
|
||||
{
|
||||
$this->authorizeCreate();
|
||||
|
||||
if (!Utils::hasFeature(FEATURE_QUOTES)) {
|
||||
return Redirect::to('/invoices/create');
|
||||
}
|
||||
|
@ -75,11 +75,11 @@ class TaskController extends BaseController
|
||||
return $this->save();
|
||||
}
|
||||
|
||||
public function show(TaskRequest $request)
|
||||
public function show($publicId)
|
||||
{
|
||||
Session::reflash();
|
||||
|
||||
return Redirect::to("tasks/{$request->task_id}/edit");
|
||||
return Redirect::to("tasks/{$publicId}/edit");
|
||||
}
|
||||
|
||||
/**
|
||||
|
26
app/Http/Requests/CreateDocumentRequest.php
Normal file
26
app/Http/Requests/CreateDocumentRequest.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php namespace App\Http\Requests;
|
||||
|
||||
class CreateDocumentRequest extends DocumentRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('create', ENTITY_DOCUMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
|
||||
];
|
||||
}
|
||||
}
|
32
app/Http/Requests/CreateInvoiceAPIRequest.php
Normal file
32
app/Http/Requests/CreateInvoiceAPIRequest.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php namespace App\Http\Requests;
|
||||
|
||||
class CreateInvoiceAPIRequest extends InvoiceRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('create', ENTITY_INVOICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$rules = [
|
||||
'email' => 'required_without:client_id',
|
||||
'client_id' => 'required_without:email',
|
||||
'invoice_items' => 'valid_invoice_items',
|
||||
'invoice_number' => 'unique:invoices,invoice_number,,id,account_id,' . $this->user()->account_id,
|
||||
'discount' => 'positive',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
@ -1,11 +1,6 @@
|
||||
<?php namespace App\Http\Requests;
|
||||
|
||||
use Auth;
|
||||
use App\Http\Requests\Request;
|
||||
use Illuminate\Validation\Factory;
|
||||
use App\Models\Invoice;
|
||||
|
||||
class CreateInvoiceRequest extends Request
|
||||
class CreateInvoiceRequest extends InvoiceRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
@ -14,7 +9,7 @@ class CreateInvoiceRequest extends Request
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can('create', ENTITY_INVOICE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -25,13 +20,18 @@ class CreateInvoiceRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
$rules = [
|
||||
'email' => 'required_without:client_id',
|
||||
'client_id' => 'required_without:email',
|
||||
'client.contacts' => 'valid_contacts',
|
||||
'invoice_items' => 'valid_invoice_items',
|
||||
'invoice_number' => 'unique:invoices,invoice_number,,id,account_id,'.Auth::user()->account_id,
|
||||
'invoice_number' => 'required|unique:invoices,invoice_number,,id,account_id,' . $this->user()->account_id,
|
||||
'discount' => 'positive',
|
||||
];
|
||||
|
||||
/* There's a problem parsing the dates
|
||||
if (Request::get('is_recurring') && Request::get('start_date') && Request::get('end_date')) {
|
||||
$rules['end_date'] = 'after' . Request::get('start_date');
|
||||
}
|
||||
*/
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
7
app/Http/Requests/DocumentRequest.php
Normal file
7
app/Http/Requests/DocumentRequest.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php namespace App\Http\Requests;
|
||||
|
||||
class DocumentRequest extends EntityRequest {
|
||||
|
||||
protected $entityType = ENTITY_DOCUMENT;
|
||||
|
||||
}
|
@ -23,7 +23,12 @@ class EntityRequest extends Request {
|
||||
}
|
||||
|
||||
$class = Utils::getEntityClass($this->entityType);
|
||||
|
||||
if (method_exists($class, 'withTrashed')) {
|
||||
$this->entity = $class::scope($publicId)->withTrashed()->firstOrFail();
|
||||
} else {
|
||||
$this->entity = $class::scope($publicId)->firstOrFail();
|
||||
}
|
||||
|
||||
return $this->entity;
|
||||
}
|
||||
|
20
app/Http/Requests/InvoiceRequest.php
Normal file
20
app/Http/Requests/InvoiceRequest.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php namespace App\Http\Requests;
|
||||
|
||||
class InvoiceRequest extends EntityRequest {
|
||||
|
||||
protected $entityType = ENTITY_INVOICE;
|
||||
|
||||
/*
|
||||
public function entity()
|
||||
{
|
||||
$expense = parent::entity();
|
||||
|
||||
// eager load the contacts
|
||||
if ($expense && ! count($expense->documents)) {
|
||||
$expense->load('documents');
|
||||
}
|
||||
|
||||
return $expense;
|
||||
}
|
||||
*/
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
<?php namespace App\Http\Requests;
|
||||
|
||||
use Auth;
|
||||
use App\Http\Requests\Request;
|
||||
use Illuminate\Validation\Factory;
|
||||
use App\Models\Invoice;
|
||||
|
||||
class SaveInvoiceWithClientRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$publicId = Request::get('public_id');
|
||||
$invoiceId = $publicId ? Invoice::getPrivateId($publicId) : '';
|
||||
|
||||
$rules = [
|
||||
'client.contacts' => 'valid_contacts',
|
||||
'invoice_items' => 'valid_invoice_items',
|
||||
'invoice_number' => 'required|unique:invoices,invoice_number,'.$invoiceId.',id,account_id,'.Auth::user()->account_id,
|
||||
'discount' => 'positive',
|
||||
];
|
||||
|
||||
/* There's a problem parsing the dates
|
||||
if (Request::get('is_recurring') && Request::get('start_date') && Request::get('end_date')) {
|
||||
$rules['end_date'] = 'after' . Request::get('start_date');
|
||||
}
|
||||
*/
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
36
app/Http/Requests/UpdateInvoiceAPIRequest.php
Normal file
36
app/Http/Requests/UpdateInvoiceAPIRequest.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php namespace App\Http\Requests;
|
||||
|
||||
class UpdateInvoiceAPIRequest extends InvoiceRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
if ($this->action == ACTION_ARCHIVE) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$invoiceId = $this->entity()->id;
|
||||
|
||||
$rules = [
|
||||
'invoice_items' => 'valid_invoice_items',
|
||||
'invoice_number' => 'unique:invoices,invoice_number,' . $invoiceId . ',id,account_id,' . $this->user()->account_id,
|
||||
'discount' => 'positive',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
@ -1,11 +1,6 @@
|
||||
<?php namespace App\Http\Requests;
|
||||
|
||||
use Auth;
|
||||
use App\Http\Requests\Request;
|
||||
use Illuminate\Validation\Factory;
|
||||
use App\Models\Invoice;
|
||||
|
||||
class UpdateInvoiceRequest extends Request
|
||||
class UpdateInvoiceRequest extends InvoiceRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
@ -14,7 +9,7 @@ class UpdateInvoiceRequest extends Request
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -24,19 +19,21 @@ class UpdateInvoiceRequest extends Request
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
if ($this->action == ACTION_ARCHIVE) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$publicId = $this->route('invoices');
|
||||
$invoiceId = Invoice::getPrivateId($publicId);
|
||||
$invoiceId = $this->entity()->id;
|
||||
|
||||
$rules = [
|
||||
'client.contacts' => 'valid_contacts',
|
||||
'invoice_items' => 'valid_invoice_items',
|
||||
'invoice_number' => 'unique:invoices,invoice_number,'.$invoiceId.',id,account_id,'.Auth::user()->account_id,
|
||||
'invoice_number' => 'required|unique:invoices,invoice_number,' . $invoiceId . ',id,account_id,' . $this->user()->account_id,
|
||||
'discount' => 'positive',
|
||||
];
|
||||
|
||||
/* There's a problem parsing the dates
|
||||
if (Request::get('is_recurring') && Request::get('start_date') && Request::get('end_date')) {
|
||||
$rules['end_date'] = 'after' . Request::get('start_date');
|
||||
}
|
||||
*/
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ Route::group(['middleware' => 'auth:client'], function() {
|
||||
Route::get('client/documents', 'PublicClientController@documentIndex');
|
||||
Route::get('client/payments', 'PublicClientController@paymentIndex');
|
||||
Route::get('client/dashboard', 'PublicClientController@dashboard');
|
||||
Route::get('client/document/js/{public_id}/{filename}', 'PublicClientController@getDocumentVFSJS');
|
||||
Route::get('client/document/{invitation_key}/{public_id}/{filename?}', 'PublicClientController@getDocument');
|
||||
Route::get('client/documents/js/{documents}/{filename}', 'PublicClientController@getDocumentVFSJS');
|
||||
Route::get('client/documents/{invitation_key}/{documents}/{filename?}', 'PublicClientController@getDocument');
|
||||
Route::get('client/documents/{invitation_key}/{filename?}', 'PublicClientController@getInvoiceDocumentsZip');
|
||||
|
||||
Route::get('api/client.quotes', array('as'=>'api.client.quotes', 'uses'=>'PublicClientController@quoteDatatable'));
|
||||
@ -134,20 +134,20 @@ Route::group(['middleware' => 'auth:user'], function() {
|
||||
Route::get('invoices/create/{client_id?}', 'InvoiceController@create');
|
||||
Route::get('recurring_invoices/create/{client_id?}', 'InvoiceController@createRecurring');
|
||||
Route::get('recurring_invoices', 'RecurringInvoiceController@index');
|
||||
Route::get('invoices/{public_id}/clone', 'InvoiceController@cloneInvoice');
|
||||
Route::get('invoices/{invoices}/clone', 'InvoiceController@cloneInvoice');
|
||||
Route::post('invoices/bulk', 'InvoiceController@bulk');
|
||||
Route::post('recurring_invoices/bulk', 'InvoiceController@bulk');
|
||||
|
||||
Route::get('document/{public_id}/{filename?}', 'DocumentController@get');
|
||||
Route::get('document/js/{public_id}/{filename}', 'DocumentController@getVFSJS');
|
||||
Route::get('document/preview/{public_id}/{filename?}', 'DocumentController@getPreview');
|
||||
Route::get('documents/{documents}/{filename?}', 'DocumentController@get');
|
||||
Route::get('documents/js/{documents}/{filename}', 'DocumentController@getVFSJS');
|
||||
Route::get('documents/preview/{documents}/{filename?}', 'DocumentController@getPreview');
|
||||
Route::post('document', 'DocumentController@postUpload');
|
||||
|
||||
Route::get('quotes/create/{client_id?}', 'QuoteController@create');
|
||||
Route::get('quotes/{public_id}/clone', 'InvoiceController@cloneInvoice');
|
||||
Route::get('quotes/{public_id}/edit', 'InvoiceController@edit');
|
||||
Route::put('quotes/{public_id}', 'InvoiceController@update');
|
||||
Route::get('quotes/{public_id}', 'InvoiceController@edit');
|
||||
Route::get('quotes/{invoices}/clone', 'InvoiceController@cloneInvoice');
|
||||
Route::get('quotes/{invoices}/edit', 'InvoiceController@edit');
|
||||
Route::put('quotes/{invoices}', 'InvoiceController@update');
|
||||
Route::get('quotes/{invoices}', 'InvoiceController@edit');
|
||||
Route::post('quotes', 'InvoiceController@store');
|
||||
Route::get('quotes', 'QuoteController@index');
|
||||
Route::get('api/quotes/{client_id?}', array('as'=>'api.quotes', 'uses'=>'QuoteController@getDatatable'));
|
||||
|
@ -173,11 +173,11 @@ class Document extends EntityModel
|
||||
}
|
||||
|
||||
public function getUrl(){
|
||||
return url('document/'.$this->public_id.'/'.$this->name);
|
||||
return url('documents/'.$this->public_id.'/'.$this->name);
|
||||
}
|
||||
|
||||
public function getClientUrl($invitation){
|
||||
return url('client/document/'.$invitation->invitation_key.'/'.$this->public_id.'/'.$this->name);
|
||||
return url('client/documents/'.$invitation->invitation_key.'/'.$this->public_id.'/'.$this->name);
|
||||
}
|
||||
|
||||
public function isPDFEmbeddable(){
|
||||
@ -186,16 +186,16 @@ class Document extends EntityModel
|
||||
|
||||
public function getVFSJSUrl(){
|
||||
if(!$this->isPDFEmbeddable())return null;
|
||||
return url('document/js/'.$this->public_id.'/'.$this->name.'.js');
|
||||
return url('documents/js/'.$this->public_id.'/'.$this->name.'.js');
|
||||
}
|
||||
|
||||
public function getClientVFSJSUrl(){
|
||||
if(!$this->isPDFEmbeddable())return null;
|
||||
return url('client/document/js/'.$this->public_id.'/'.$this->name.'.js');
|
||||
return url('client/documents/js/'.$this->public_id.'/'.$this->name.'.js');
|
||||
}
|
||||
|
||||
public function getPreviewUrl(){
|
||||
return $this->preview?url('document/preview/'.$this->public_id.'/'.$this->name.'.'.pathinfo($this->preview, PATHINFO_EXTENSION)):null;
|
||||
return $this->preview?url('documents/preview/'.$this->public_id.'/'.$this->name.'.'.pathinfo($this->preview, PATHINFO_EXTENSION)):null;
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
|
@ -211,7 +211,7 @@ class DocumentRepository extends BaseRepository
|
||||
})
|
||||
->addColumn('name', function ($model) {
|
||||
return link_to(
|
||||
'/client/document/'.$model->invitation_key.'/'.$model->public_id.'/'.$model->name,
|
||||
'/client/documents/'.$model->invitation_key.'/'.$model->public_id.'/'.$model->name,
|
||||
$model->name,
|
||||
['target'=>'_blank']
|
||||
)->toHtml();
|
||||
|
Loading…
x
Reference in New Issue
Block a user