type = $type; $this->status = $status; } /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool */ public function passes($attribute, $value) { $this->attribute = $attribute; $value = is_array($value) ? $value : [$value]; if ($this->type == 'contract') { foreach ($value as $key => $row) { if(!empty($row)) { $id = Hasher::decode('contracts', $row); $data = Contract:: where('id', $id) ->whereIn('status', $this->status) ->count(); if (!$data) { return false; } } } } if ($this->type == 'contract_obligation') { foreach ($value as $key => $row) { if(!empty($row)) { $id = Hasher::decode('contract_obligations', $row); $data = ContractObligation:: where('id', $id) ->whereIn('status', $this->status) ->count(); if (!$data) { return false; } } } } return true; } /** * Get the validation error message. * * @return string */ public function message() { return config('error_code.status_error'); } }