1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2024-11-24 03:12:46 +01:00

Allow to get via phone conversation last reply via getLastReply()

This commit is contained in:
FreeScout 2021-11-29 22:42:10 -08:00
parent 9e7f2e22dd
commit 79aca06be8

View File

@ -398,10 +398,14 @@ class Conversation extends Model
*
* @return [type] [description]
*/
public function getLastReply()
public function getLastReply($include_phone_replies = false)
{
$types = [Thread::TYPE_CUSTOMER, Thread::TYPE_MESSAGE];
if ($include_phone_replies && $this->isPhone()) {
$types[] = Thread::TYPE_NOTE;
}
return $this->threads()
->whereIn('type', [Thread::TYPE_CUSTOMER, Thread::TYPE_MESSAGE])
->whereIn('type', $types)
->where('state', Thread::STATE_PUBLISHED)
->orderBy('created_at', 'desc')
->first();