quote = $quote; $this->settings = $settings; $this->company = $company; } /** * Execute the job. * * * @return void */ public function handle() { MultiDB::setDB($this->company->db); //return early if ($this->quote->number != '') { return $this->quote; } switch ($this->settings->quote_number_applied) { case 'when_saved': $this->quote->number = $this->getNextQuoteNumber($this->quote->client); break; case 'when_sent': if ($this->quote->status_id == Quote::STATUS_SENT) { $this->quote->number = $this->getNextQuoteNumber($this->quote->client); } break; default: # code... break; } $this->quote->save(); return $this->quote; } }