'required|integer|exists:accounts,id', 'happened_at' => 'required|date', 'contact_field_type_id' => 'required|integer', 'conversation_id' => 'required|integer|exists:conversations,id', ]; } /** * Update a conversation. * * @param array $data * @return Conversation */ public function execute(array $data): Conversation { $this->validate($data); /** @var Conversation */ $conversation = Conversation::where('account_id', $data['account_id']) ->findOrFail($data['conversation_id']); $conversation->contact->throwInactive(); ContactFieldType::where('account_id', $data['account_id']) ->findOrFail($data['contact_field_type_id']); $conversation->update([ 'happened_at' => $data['happened_at'], 'contact_field_type_id' => $data['contact_field_type_id'], ]); return $conversation; } }