'date:d-m-Y' ]; public function isSigned() { return WorkflowDocumentFile::where('workflow_document_id', $this->id)->where('is_signed', 1)->count() >= 1; } public function getRegistrationDate() { return ($this->registration_date != null) ? Carbon::parse($this->registration_date)->format('d-m-Y') .' '. Carbon::parse($this->created_at)->format('H:i') : Carbon::parse($this->created_at)->format('d-m-Y H:i'); } public function getSenderName() { $wd = WorkflowDocumentSender::where('workflow_document_id', $this->id)->first(); $wd = ($wd != null) ? $wd->contact_organization_name : ''; if($this->workflow_type_id == 3) $wd = $this->creator_name; return $wd; } public function getRegNumber() { return ($this->registration_number != '') ? $this->registration_number : $this->temporary_registration_number; } public function hasSenderAPI() { if($this->status != "Approved") return false; if(!WorkflowDocumentFile::where('workflow_document_id', $this->id)->where('is_temp', 0)->where('is_signed', 1)->exists()) return false; if(!in_array(13, auth()->user()->getPermissionList())) return false; $remotecontacts = RemoteContact::where('direction', 1)->whereIn('contact_id', WorkflowDocumentSender::where('workflow_document_id', $this->id)->pluck('contact_id')->toArray())->get(); if($remotecontacts) { foreach($remotecontacts as $remotecontact) if($remotecontact->remotecontactapis->where('type', 0)->where('archive', 0)->count() == 1) return true; } return false; } public function getReviewerUser() { $user = User::find(WorkflowDocumentUser::where('workflow_document_id', $this->id)->where('user_type', "R")->first()->user_id); if($user) return $user->getFullName(); return ''; } public function getSupportUsers() { $users = User::whereIn('id', WorkflowDocumentUser::where('workflow_document_id', $this->id)->where('user_type', "S")->pluck('user_id')->toArray())->get(); $res = ''; foreach($users as $user) $res = $res . $user->last_name . " " . $user->first_name . ", " ; return substr($res, 0, -2); } public function senders() { return $this->hasMany(WorkflowDocumentSender::class, 'workflow_document_id', 'id'); } public function workflowprocesses() { return $this->hasMany(WorkflowDocumentProcess::class, 'workflow_document_id', 'id'); } }