mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 21:47:32 -05:00 
			
		
		
		
	Removed extra entity load in the repos save function
This commit is contained in:
		
							parent
							
								
									325cac1603
								
							
						
					
					
						commit
						e6bcdb36b3
					
				@ -24,28 +24,4 @@ class BaseController extends Controller
 | 
				
			|||||||
            $this->layout = View::make($this->layout);
 | 
					            $this->layout = View::make($this->layout);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    protected function authorizeCreate() {
 | 
					 | 
				
			||||||
        $this->authorize('create', $this->entityType);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    /*
 | 
					 | 
				
			||||||
    protected function authorizeUpdate($entity) {
 | 
					 | 
				
			||||||
        $this->authorize('edit', $entity);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    */
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    protected function authorizeUpdate($input){
 | 
					 | 
				
			||||||
        $creating = empty($input['public_id']) || $input['public_id'] == '-1';
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        if($creating){
 | 
					 | 
				
			||||||
            $this->authorize('create', $this->entityType);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else{
 | 
					 | 
				
			||||||
            $className = Utils::getEntityName($this->entityType);
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            $object = call_user_func(array("App\\Models\\{$className}", 'scope'), $input['public_id'])->firstOrFail();
 | 
					 | 
				
			||||||
            $this->authorize('edit', $object);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -116,7 +116,7 @@ class ClientApiController extends BaseAPIController
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        $data = $request->input();
 | 
					        $data = $request->input();
 | 
				
			||||||
        $data['public_id'] = $publicId;
 | 
					        $data['public_id'] = $publicId;
 | 
				
			||||||
        $client = $this->clientRepo->save($data);
 | 
					        $client = $this->clientRepo->save($data, $request->entity());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->itemResponse($client);
 | 
					        return $this->itemResponse($client);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -146,7 +146,7 @@ class ExpenseController extends BaseController
 | 
				
			|||||||
        $data = $request->input();
 | 
					        $data = $request->input();
 | 
				
			||||||
        $data['documents'] = $request->file('documents');
 | 
					        $data['documents'] = $request->file('documents');
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
        $expense = $this->expenseService->save($data);
 | 
					        $expense = $this->expenseService->save($data, $request->entity());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Session::flash('message', trans('texts.updated_expense'));
 | 
					        Session::flash('message', trans('texts.updated_expense'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -318,7 +318,7 @@ class InvoiceApiController extends BaseAPIController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $data = $request->input();
 | 
					        $data = $request->input();
 | 
				
			||||||
        $data['public_id'] = $publicId;
 | 
					        $data['public_id'] = $publicId;
 | 
				
			||||||
        $this->invoiceService->save($data);
 | 
					        $this->invoiceService->save($data, $request->entity());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $invoice = Invoice::scope($publicId)
 | 
					        $invoice = Invoice::scope($publicId)
 | 
				
			||||||
                        ->with('client', 'invoice_items', 'invitations')
 | 
					                        ->with('client', 'invoice_items', 'invitations')
 | 
				
			||||||
 | 
				
			|||||||
@ -397,8 +397,6 @@ class InvoiceController extends BaseController
 | 
				
			|||||||
        $data = $request->input();
 | 
					        $data = $request->input();
 | 
				
			||||||
        $data['documents'] = $request->file('documents');
 | 
					        $data['documents'] = $request->file('documents');
 | 
				
			||||||
                        
 | 
					                        
 | 
				
			||||||
        $this->authorizeUpdate($data);
 | 
					 | 
				
			||||||
                
 | 
					 | 
				
			||||||
        $action = Input::get('action');
 | 
					        $action = Input::get('action');
 | 
				
			||||||
        $entityType = Input::get('entityType');
 | 
					        $entityType = Input::get('entityType');
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
@ -436,12 +434,10 @@ class InvoiceController extends BaseController
 | 
				
			|||||||
        $data = $request->input();
 | 
					        $data = $request->input();
 | 
				
			||||||
        $data['documents'] = $request->file('documents');
 | 
					        $data['documents'] = $request->file('documents');
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
        $this->authorizeUpdate($data);
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        $action = Input::get('action');
 | 
					        $action = Input::get('action');
 | 
				
			||||||
        $entityType = Input::get('entityType');
 | 
					        $entityType = Input::get('entityType');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $invoice = $this->invoiceService->save($data);
 | 
					        $invoice = $this->invoiceService->save($data, $request->entity());
 | 
				
			||||||
        $entityType = $invoice->getEntityType();
 | 
					        $entityType = $invoice->getEntityType();
 | 
				
			||||||
        $message = trans("texts.updated_{$entityType}");
 | 
					        $message = trans("texts.updated_{$entityType}");
 | 
				
			||||||
        Session::flash('message', $message);
 | 
					        Session::flash('message', $message);
 | 
				
			||||||
 | 
				
			|||||||
@ -85,7 +85,7 @@ class PaymentApiController extends BaseAPIController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $data = $request->input();
 | 
					        $data = $request->input();
 | 
				
			||||||
        $data['public_id'] = $publicId;
 | 
					        $data['public_id'] = $publicId;
 | 
				
			||||||
        $payment = $this->paymentRepo->save($data);
 | 
					        $payment = $this->paymentRepo->save($data, $request->entity());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->itemResponse($payment);
 | 
					        return $this->itemResponse($payment);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -603,7 +603,7 @@ class PaymentController extends BaseController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function update(UpdatePaymentRequest $request)
 | 
					    public function update(UpdatePaymentRequest $request)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $payment = $this->paymentRepo->save($request->input());
 | 
					        $payment = $this->paymentRepo->save($request->input(), $request->entity());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Session::flash('message', trans('texts.updated_payment'));
 | 
					        Session::flash('message', trans('texts.updated_payment'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -42,7 +42,7 @@ class ProductApiController extends BaseAPIController
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        $data = $request->input();
 | 
					        $data = $request->input();
 | 
				
			||||||
        $data['public_id'] = $publicId;
 | 
					        $data['public_id'] = $publicId;
 | 
				
			||||||
        $product = $this->productRepo->save($data);
 | 
					        $product = $this->productRepo->save($data, $request->entity());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->itemResponse($product);
 | 
					        return $this->itemResponse($product);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -42,7 +42,7 @@ class TaxRateApiController extends BaseAPIController
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        $data = $request->input();
 | 
					        $data = $request->input();
 | 
				
			||||||
        $data['public_id'] = $publicId;
 | 
					        $data['public_id'] = $publicId;
 | 
				
			||||||
        $taxRate = $this->taxRateRepo->save($data);
 | 
					        $taxRate = $this->taxRateRepo->save($data, $request->entity());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->itemResponse($taxRate);
 | 
					        return $this->itemResponse($taxRate);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -75,9 +75,7 @@ class TaxRateController extends BaseController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function update(UpdateTaxRateRequest $request, $publicId)
 | 
					    public function update(UpdateTaxRateRequest $request, $publicId)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $taxRate = TaxRate::scope($publicId)->firstOrFail();
 | 
					        $this->taxRateRepo->save($request->input(), $request->entity());
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->taxRateRepo->save($request->input(), $taxRate);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Session::flash('message', trans('texts.updated_tax_rate'));
 | 
					        Session::flash('message', trans('texts.updated_tax_rate'));
 | 
				
			||||||
        return Redirect::to('settings/' . ACCOUNT_TAX_RATES);
 | 
					        return Redirect::to('settings/' . ACCOUNT_TAX_RATES);
 | 
				
			||||||
 | 
				
			|||||||
@ -182,7 +182,7 @@ class VendorController extends BaseController
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function update(UpdateVendorRequest $request)
 | 
					    public function update(UpdateVendorRequest $request)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $vendor = $this->vendorService->save($request->input());
 | 
					        $vendor = $this->vendorService->save($request->input(), $request->entity());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Session::flash('message', trans('texts.updated_vendor'));
 | 
					        Session::flash('message', trans('texts.updated_vendor'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -72,10 +72,11 @@ class ClientRepository extends BaseRepository
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if ($client) {
 | 
					        if ($client) {
 | 
				
			||||||
           // do nothing
 | 
					           // do nothing
 | 
				
			||||||
        } if (!$publicId || $publicId == '-1') {
 | 
					        } elseif (!$publicId || $publicId == '-1') {
 | 
				
			||||||
            $client = Client::createNew();
 | 
					            $client = Client::createNew();
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $client = Client::scope($publicId)->with('contacts')->firstOrFail();
 | 
					            $client = Client::scope($publicId)->with('contacts')->firstOrFail();
 | 
				
			||||||
 | 
					            \Log::warning('Entity not set in client repo save');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // convert currency code to id
 | 
					        // convert currency code to id
 | 
				
			||||||
 | 
				
			|||||||
@ -59,12 +59,15 @@ class CreditRepository extends BaseRepository
 | 
				
			|||||||
        return $query;
 | 
					        return $query;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function save($input)
 | 
					    public function save($input, $credit = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $publicId = isset($data['public_id']) ? $data['public_id'] : false;
 | 
					        $publicId = isset($data['public_id']) ? $data['public_id'] : false;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        if ($publicId) {
 | 
					        if ($credit) {
 | 
				
			||||||
 | 
					            // do nothing
 | 
				
			||||||
 | 
					        } elseif ($publicId) {
 | 
				
			||||||
            $credit = Credit::scope($publicId)->firstOrFail();
 | 
					            $credit = Credit::scope($publicId)->firstOrFail();
 | 
				
			||||||
 | 
					            \Log::warning('Entity not set in credit repo save');
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $credit = Credit::createNew();
 | 
					            $credit = Credit::createNew();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -122,12 +122,15 @@ class ExpenseRepository extends BaseRepository
 | 
				
			|||||||
        return $query;
 | 
					        return $query;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function save($input)
 | 
					    public function save($input, $expense = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $publicId = isset($input['public_id']) ? $input['public_id'] : false;
 | 
					        $publicId = isset($input['public_id']) ? $input['public_id'] : false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($publicId) {
 | 
					        if ($expense) {
 | 
				
			||||||
 | 
					            // do nothing
 | 
				
			||||||
 | 
					        } elseif ($publicId) {
 | 
				
			||||||
            $expense = Expense::scope($publicId)->firstOrFail();
 | 
					            $expense = Expense::scope($publicId)->firstOrFail();
 | 
				
			||||||
 | 
					            \Log::warning('Entity not set in expense repo save');
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $expense = Expense::createNew();
 | 
					            $expense = Expense::createNew();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -201,14 +201,16 @@ class InvoiceRepository extends BaseRepository
 | 
				
			|||||||
            ->make();
 | 
					            ->make();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function save($data)
 | 
					    public function save($data, $invoice = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $account = \Auth::user()->account;
 | 
					        $account = \Auth::user()->account;
 | 
				
			||||||
        $publicId = isset($data['public_id']) ? $data['public_id'] : false;
 | 
					        $publicId = isset($data['public_id']) ? $data['public_id'] : false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $isNew = !$publicId || $publicId == '-1';
 | 
					        $isNew = !$publicId || $publicId == '-1';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($isNew) {
 | 
					        if ($invoice) {
 | 
				
			||||||
 | 
					            // do nothing
 | 
				
			||||||
 | 
					        } elseif ($isNew) {
 | 
				
			||||||
            $entityType = ENTITY_INVOICE;
 | 
					            $entityType = ENTITY_INVOICE;
 | 
				
			||||||
            if (isset($data['is_recurring']) && filter_var($data['is_recurring'], FILTER_VALIDATE_BOOLEAN)) {
 | 
					            if (isset($data['is_recurring']) && filter_var($data['is_recurring'], FILTER_VALIDATE_BOOLEAN)) {
 | 
				
			||||||
                $entityType = ENTITY_RECURRING_INVOICE;
 | 
					                $entityType = ENTITY_RECURRING_INVOICE;
 | 
				
			||||||
@ -224,6 +226,7 @@ class InvoiceRepository extends BaseRepository
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $invoice = Invoice::scope($publicId)->firstOrFail();
 | 
					            $invoice = Invoice::scope($publicId)->firstOrFail();
 | 
				
			||||||
 | 
					            \Log::warning('Entity not set in invoice repo save');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $invoice->fill($data);
 | 
					        $invoice->fill($data);
 | 
				
			||||||
 | 
				
			|||||||
@ -123,12 +123,15 @@ class PaymentRepository extends BaseRepository
 | 
				
			|||||||
        return $query;
 | 
					        return $query;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function save($input)
 | 
					    public function save($input, $payment = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $publicId = isset($input['public_id']) ? $input['public_id'] : false;
 | 
					        $publicId = isset($input['public_id']) ? $input['public_id'] : false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($publicId) {
 | 
					        if ($payment) {
 | 
				
			||||||
 | 
					            // do nothing
 | 
				
			||||||
 | 
					        } elseif ($publicId) {
 | 
				
			||||||
            $payment = Payment::scope($publicId)->firstOrFail();
 | 
					            $payment = Payment::scope($publicId)->firstOrFail();
 | 
				
			||||||
 | 
					            \Log::warning('Entity not set in payment repo save');
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $payment = Payment::createNew();
 | 
					            $payment = Payment::createNew();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -31,12 +31,15 @@ class ProductRepository extends BaseRepository
 | 
				
			|||||||
                );
 | 
					                );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    public function save($data)
 | 
					    public function save($data, $product = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $publicId = isset($data['public_id']) ? $data['public_id'] : false;
 | 
					        $publicId = isset($data['public_id']) ? $data['public_id'] : false;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        if ($publicId) {
 | 
					        if ($product) {
 | 
				
			||||||
 | 
					            // do nothing
 | 
				
			||||||
 | 
					        } elseif ($publicId) {
 | 
				
			||||||
            $product = Product::scope($publicId)->firstOrFail();
 | 
					            $product = Product::scope($publicId)->firstOrFail();
 | 
				
			||||||
 | 
					            \Log::warning('Entity not set in product repo save');
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $product = Product::createNew();
 | 
					            $product = Product::createNew();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -64,10 +64,13 @@ class TaskRepository
 | 
				
			|||||||
        return $query;
 | 
					        return $query;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function save($publicId, $data)
 | 
					    public function save($publicId, $data, $task = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if ($publicId) {
 | 
					        if ($task) {
 | 
				
			||||||
 | 
					            // do nothing
 | 
				
			||||||
 | 
					        } elseif ($publicId) {
 | 
				
			||||||
            $task = Task::scope($publicId)->firstOrFail();
 | 
					            $task = Task::scope($publicId)->firstOrFail();
 | 
				
			||||||
 | 
					            \Log::warning('Entity not set in task repo save');
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $task = Task::createNew();
 | 
					            $task = Task::createNew();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -20,15 +20,16 @@ class TaxRateRepository extends BaseRepository
 | 
				
			|||||||
                ->select('tax_rates.public_id', 'tax_rates.name', 'tax_rates.rate', 'tax_rates.deleted_at');
 | 
					                ->select('tax_rates.public_id', 'tax_rates.name', 'tax_rates.rate', 'tax_rates.deleted_at');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function save($data, $taxRate = false)
 | 
					    public function save($data, $taxRate = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if ( ! $taxRate) {
 | 
					        if ($taxRate) {
 | 
				
			||||||
            if (isset($data['public_id'])) {
 | 
					            // do nothing
 | 
				
			||||||
 | 
					        } elseif (isset($data['public_id'])) {
 | 
				
			||||||
            $taxRate = TaxRate::scope($data['public_id'])->firstOrFail();
 | 
					            $taxRate = TaxRate::scope($data['public_id'])->firstOrFail();
 | 
				
			||||||
 | 
					            \Log::warning('Entity not set in tax rate repo save');
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $taxRate = TaxRate::createNew();
 | 
					            $taxRate = TaxRate::createNew();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        $taxRate->fill($data);
 | 
					        $taxRate->fill($data);
 | 
				
			||||||
        $taxRate->save();
 | 
					        $taxRate->save();
 | 
				
			||||||
 | 
				
			|||||||
@ -62,14 +62,17 @@ class VendorRepository extends BaseRepository
 | 
				
			|||||||
        return $query;
 | 
					        return $query;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function save($data)
 | 
					    public function save($data, $vendor = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $publicId = isset($data['public_id']) ? $data['public_id'] : false;
 | 
					        $publicId = isset($data['public_id']) ? $data['public_id'] : false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!$publicId || $publicId == '-1') {
 | 
					        if ($vendor) {
 | 
				
			||||||
 | 
					            // do nothing
 | 
				
			||||||
 | 
					        } elseif (!$publicId || $publicId == '-1') {
 | 
				
			||||||
            $vendor = Vendor::createNew();
 | 
					            $vendor = Vendor::createNew();
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $vendor = Vendor::scope($publicId)->with('vendorcontacts')->firstOrFail();
 | 
					            $vendor = Vendor::scope($publicId)->with('vendorcontacts')->firstOrFail();
 | 
				
			||||||
 | 
					            \Log::warning('Entity not set in vendor repo save');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $vendor->fill($data);
 | 
					        $vendor->fill($data);
 | 
				
			||||||
 | 
				
			|||||||
@ -28,7 +28,7 @@ class ExpenseService extends BaseService
 | 
				
			|||||||
        return $this->expenseRepo;
 | 
					        return $this->expenseRepo;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function save($data)
 | 
					    public function save($data, $expense = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (isset($data['client_id']) && $data['client_id']) {
 | 
					        if (isset($data['client_id']) && $data['client_id']) {
 | 
				
			||||||
            $data['client_id'] = Client::getPrivateId($data['client_id']);
 | 
					            $data['client_id'] = Client::getPrivateId($data['client_id']);
 | 
				
			||||||
@ -38,7 +38,7 @@ class ExpenseService extends BaseService
 | 
				
			|||||||
            $data['vendor_id'] = Vendor::getPrivateId($data['vendor_id']);
 | 
					            $data['vendor_id'] = Vendor::getPrivateId($data['vendor_id']);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->expenseRepo->save($data);
 | 
					        return $this->expenseRepo->save($data, $expense);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getDatatable($search)
 | 
					    public function getDatatable($search)
 | 
				
			||||||
 | 
				
			|||||||
@ -30,7 +30,7 @@ class InvoiceService extends BaseService
 | 
				
			|||||||
        return $this->invoiceRepo;
 | 
					        return $this->invoiceRepo;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function save($data)
 | 
					    public function save($data, $invoice = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (isset($data['client'])) {
 | 
					        if (isset($data['client'])) {
 | 
				
			||||||
            $canSaveClient = false;
 | 
					            $canSaveClient = false;
 | 
				
			||||||
@ -46,7 +46,7 @@ class InvoiceService extends BaseService
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $invoice = $this->invoiceRepo->save($data);
 | 
					        $invoice = $this->invoiceRepo->save($data, $invoice);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $client = $invoice->client;
 | 
					        $client = $invoice->client;
 | 
				
			||||||
        $client->load('contacts');
 | 
					        $client->load('contacts');
 | 
				
			||||||
 | 
				
			|||||||
@ -26,13 +26,13 @@ class VendorService extends BaseService
 | 
				
			|||||||
        return $this->vendorRepo;
 | 
					        return $this->vendorRepo;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function save($data)
 | 
					    public function save($data, $vendor = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (Auth::user()->account->isNinjaAccount() && isset($data['plan'])) {
 | 
					        if (Auth::user()->account->isNinjaAccount() && isset($data['plan'])) {
 | 
				
			||||||
            $this->ninjaRepo->updatePlanDetails($data['public_id'], $data);
 | 
					            $this->ninjaRepo->updatePlanDetails($data['public_id'], $data);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->vendorRepo->save($data);
 | 
					        return $this->vendorRepo->save($data, $vendor);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getDatatable($search)
 | 
					    public function getDatatable($search)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user