mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 03:57:32 -05:00 
			
		
		
		
	Fixes for N+1
This commit is contained in:
		
							parent
							
								
									af8c56a1f1
								
							
						
					
					
						commit
						ebca34503b
					
				@ -204,6 +204,7 @@ class PreviewController extends BaseController
 | 
				
			|||||||
            if($request->has('entity_id')){
 | 
					            if($request->has('entity_id')){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $entity_obj = $class::on(config('database.default'))
 | 
					                $entity_obj = $class::on(config('database.default'))
 | 
				
			||||||
 | 
					                                    ->with('client.contacts.company')
 | 
				
			||||||
                                    ->where('id', $this->decodePrimaryKey($request->input('entity_id')))
 | 
					                                    ->where('id', $this->decodePrimaryKey($request->input('entity_id')))
 | 
				
			||||||
                                    ->where('company_id', $company->id)
 | 
					                                    ->where('company_id', $company->id)
 | 
				
			||||||
                                    ->withTrashed()
 | 
					                                    ->withTrashed()
 | 
				
			||||||
@ -216,7 +217,7 @@ class PreviewController extends BaseController
 | 
				
			|||||||
            if(!$request->has('entity_id'))
 | 
					            if(!$request->has('entity_id'))
 | 
				
			||||||
                $entity_obj->service()->fillDefaults()->save();
 | 
					                $entity_obj->service()->fillDefaults()->save();
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
            $entity_obj->load('client.contacts','company');
 | 
					            // $entity_obj->load('client.contacts','client.company');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            App::forgetInstance('translator');
 | 
					            App::forgetInstance('translator');
 | 
				
			||||||
            $t = app('translator');
 | 
					            $t = app('translator');
 | 
				
			||||||
 | 
				
			|||||||
@ -449,6 +449,8 @@ class InvoiceService
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function fillDefaults()
 | 
					    public function fillDefaults()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        $this->invoice->load('client.company');
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        $settings = $this->invoice->client->getMergedSettings();
 | 
					        $settings = $this->invoice->client->getMergedSettings();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (! $this->invoice->design_id) 
 | 
					        if (! $this->invoice->design_id) 
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user