invoice = $invoice; } /** * @param string $attribute * @param mixed $value * @return bool */ public function passes($attribute, $value) { return $this->checkIfInvoiceLocked(); //if it exists, return false! } /** * @return string */ public function message() { return ctrans('texts.locked_invoice'); } /** * @return bool */ private function checkIfInvoiceLocked(): bool { $lock_invoices = $this->invoice->client->getSetting('lock_invoices'); switch ($lock_invoices) { case 'off': return true; case 'when_sent': if ($this->invoice->status_id == Invoice::STATUS_SENT) { return false; } return true; case 'when_paid': if ($this->invoice->status_id == Invoice::STATUS_PAID) { return false; } return true; default: return true; } } }