1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2024-11-24 11:22:42 +01:00
freescout/app/Folder.php

101 lines
2.3 KiB
PHP
Raw Normal View History

2018-07-14 03:23:37 +02:00
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\MailboxUser;
class Folder extends Model
{
/**
* Folders types (ids from HelpScout interface)
*/
const TYPE_UNASSIGNED = 1;
// User specific
const TYPE_MINE = 20;
2018-07-14 14:17:11 +02:00
// User specific
const TYPE_STARRED = 25;
2018-07-14 03:23:37 +02:00
const TYPE_DRAFTS = 30;
const TYPE_ASSIGNED = 40;
const TYPE_CLOSED = 60;
const TYPE_SPAM = 80;
const TYPE_DELETED = 110;
public static $types = [
self::TYPE_UNASSIGNED => 'Unassigned',
self::TYPE_MINE => 'Mine',
self::TYPE_DRAFTS => 'Drafts',
self::TYPE_ASSIGNED => 'Assigned',
self::TYPE_CLOSED => 'Closed',
self::TYPE_SPAM => 'Spam',
self::TYPE_DELETED => 'Deleted',
self::TYPE_STARRED => 'Starred',
];
2018-07-14 14:17:11 +02:00
/**
* https://glyphicons.bootstrapcheatsheets.com/
*/
public static $type_icons = [
self::TYPE_UNASSIGNED => 'folder-open',
self::TYPE_MINE => 'hand-right',
self::TYPE_DRAFTS => 'duplicate',
self::TYPE_ASSIGNED => 'user',
self::TYPE_CLOSED => 'lock', // lock
self::TYPE_SPAM => 'ban-circle',
self::TYPE_DELETED => 'trash',
self::TYPE_STARRED => 'star',
];
// Public non-user specific mailbox types
public static $public_types = [
2018-07-14 03:23:37 +02:00
self::TYPE_UNASSIGNED,
self::TYPE_DRAFTS,
self::TYPE_ASSIGNED,
self::TYPE_CLOSED,
self::TYPE_SPAM,
self::TYPE_DELETED,
];
// Folder types which belong to specific user
public static $personal_types = [
self::TYPE_MINE,
self::TYPE_STARRED,
];
public $timestamps = false;
/**
* Get the mailbox to which folder belongs
*/
public function mailbox()
{
return $this->belongsTo('App\Mailbox');
}
/**
* Get the user to which folder belongs
*/
public function user()
{
return $this->belongsTo('App\User');
}
/**
* Get starred conversations
*/
public function conversations()
{
2018-07-14 14:17:11 +02:00
return $this->hasMany('App\Conversation');
2018-07-14 03:23:37 +02:00
}
public function getTypeName()
{
return __(self::$types[$this->type]);
}
2018-07-14 14:17:11 +02:00
public function getTypeIcon()
{
return self::$type_icons[$this->type];
}
2018-07-14 03:23:37 +02:00
}