Apply fixes from StyleCI

This commit is contained in:
FreeScout
2018-07-24 06:34:28 +00:00
committed by StyleCI Bot
parent 371a9d523f
commit f5b82add66
80 changed files with 1102 additions and 1075 deletions

View File

@@ -15,7 +15,7 @@ class ActivityLog extends Activity
const DESCRIPTION_USER_LOGIN_FAILED = 'login_failed'; const DESCRIPTION_USER_LOGIN_FAILED = 'login_failed';
const DESCRIPTION_USER_PASSWORD_RESET = 'password_reset'; const DESCRIPTION_USER_PASSWORD_RESET = 'password_reset';
function getEventDescription() public function getEventDescription()
{ {
switch ($this->description) { switch ($this->description) {
case self::DESCRIPTION_USER_LOGIN: case self::DESCRIPTION_USER_LOGIN:

View File

@@ -2,8 +2,8 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\User; use App\User;
use Illuminate\Console\Command;
class CreateUser extends Command class CreateUser extends Command
{ {
@@ -39,46 +39,47 @@ class CreateUser extends Command
public function handle() public function handle()
{ {
$class = config( $class = config(
'auth.providers.' . config( 'auth.providers.'.config(
'auth.guards.' . config( 'auth.guards.'.config(
'auth.defaults.guard' 'auth.defaults.guard'
) . '.provider' ).'.provider'
) . '.model' ).'.model'
); );
$user = new $class; $user = new $class();
$fillables = ['role', 'first_name', 'last_name', 'email', 'password']; $fillables = ['role', 'first_name', 'last_name', 'email', 'password'];
foreach($fillables as $key => $fillable) { foreach ($fillables as $key => $fillable) {
if ($fillable == 'password') { if ($fillable == 'password') {
$user->password = \Hash::make($this->secret(($key+1) . "/" . count($fillables) . " User $fillable")); $user->password = \Hash::make($this->secret(($key + 1).'/'.count($fillables)." User $fillable"));
} elseif ($fillable == 'role') { } elseif ($fillable == 'role') {
$user->$fillable = $this->ask(($key+1) . "/" . count($fillables) . " User $fillable (admin/user)", 'admin'); $user->$fillable = $this->ask(($key + 1).'/'.count($fillables)." User $fillable (admin/user)", 'admin');
if (!$user->$fillable) { if (!$user->$fillable) {
$user->$fillable = 'admin'; $user->$fillable = 'admin';
} }
while (!in_array($user->$fillable, User::$roles)) { while (!in_array($user->$fillable, User::$roles)) {
$this->error("Incorrect role"); $this->error('Incorrect role');
$user->$fillable = $this->ask("Please enter valid role"); $user->$fillable = $this->ask('Please enter valid role');
} }
$user->$fillable = array_flip(User::$roles)[$user->$fillable]; $user->$fillable = array_flip(User::$roles)[$user->$fillable];
} else { } else {
$user->$fillable = $this->ask(($key+1) . "/" . count($fillables) . " User $fillable"); $user->$fillable = $this->ask(($key + 1).'/'.count($fillables)." User $fillable");
if ($fillable == 'email') { if ($fillable == 'email') {
while (!filter_var($user->$fillable, FILTER_VALIDATE_EMAIL)) { while (!filter_var($user->$fillable, FILTER_VALIDATE_EMAIL)) {
$this->error("Incorrect email address"); $this->error('Incorrect email address');
$user->$fillable = $this->ask("Please enter valid email address"); $user->$fillable = $this->ask('Please enter valid email address');
} }
} }
} }
} }
if ($this->confirm("Do you want to create the user?", true)) { if ($this->confirm('Do you want to create the user?', true)) {
if ($user->isAdmin()) { if ($user->isAdmin()) {
$user->invite_state = User::INVITE_STATE_ACTIVATED; $user->invite_state = User::INVITE_STATE_ACTIVATED;
} }
$user->save(); $user->save();
$this->info("User created (id: {$user->id})"); $this->info("User created (id: {$user->id})");
} }
return true; return true;
} }
} }

View File

@@ -19,7 +19,8 @@ class Kernel extends ConsoleKernel
/** /**
* Define the application's command schedule. * Define the application's command schedule.
* *
* @param \Illuminate\Console\Scheduling\Schedule $schedule * @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @return void * @return void
*/ */
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule)

View File

@@ -6,37 +6,37 @@ use Illuminate\Database\Eloquent\Model;
class Conversation extends Model class Conversation extends Model
{ {
/** /**
* By whom action performed (used in fields: source_via, last_reply_from) * By whom action performed (used in fields: source_via, last_reply_from).
*/ */
const PERSON_CUSTOMER = 1; const PERSON_CUSTOMER = 1;
const PERSON_USER = 2; const PERSON_USER = 2;
public static $persons = array( public static $persons = [
self::PERSON_CUSTOMER => 'customer', self::PERSON_CUSTOMER => 'customer',
self::PERSON_USER => 'user', self::PERSON_USER => 'user',
); ];
/** /**
* Max length of the preview * Max length of the preview.
*/ */
const PREVIEW_MAXLENGTH = 255; const PREVIEW_MAXLENGTH = 255;
/** /**
* Conversation types * Conversation types.
*/ */
const TYPE_EMAIL = 1; const TYPE_EMAIL = 1;
const TYPE_PHONE = 2; const TYPE_PHONE = 2;
const TYPE_CHAT = 3; // not used const TYPE_CHAT = 3; // not used
public static $types = array( public static $types = [
self::TYPE_EMAIL => 'email', self::TYPE_EMAIL => 'email',
self::TYPE_PHONE => 'phone', self::TYPE_PHONE => 'phone',
self::TYPE_CHAT => 'chat', self::TYPE_CHAT => 'chat',
); ];
/** /**
* Conversation statuses * Conversation statuses.
*/ */
const STATUS_ACTIVE = 1; const STATUS_ACTIVE = 1;
const STATUS_PENDING = 2; const STATUS_PENDING = 2;
@@ -45,58 +45,58 @@ class Conversation extends Model
// Present in the API, but what does it mean? // Present in the API, but what does it mean?
const STATUS_OPEN = 5; const STATUS_OPEN = 5;
public static $statuses = array( public static $statuses = [
self::STATUS_ACTIVE => 'active', self::STATUS_ACTIVE => 'active',
self::STATUS_PENDING => 'pending', self::STATUS_PENDING => 'pending',
self::STATUS_CLOSED => 'closed', self::STATUS_CLOSED => 'closed',
self::STATUS_SPAM => 'spam', self::STATUS_SPAM => 'spam',
//self::STATUS_OPEN => 'open', //self::STATUS_OPEN => 'open',
); ];
/** /**
* https://glyphicons.bootstrapcheatsheets.com/ * https://glyphicons.bootstrapcheatsheets.com/.
*/ */
public static $status_icons = array( public static $status_icons = [
self::STATUS_ACTIVE => 'ok', self::STATUS_ACTIVE => 'ok',
self::STATUS_PENDING => 'hourglass', self::STATUS_PENDING => 'hourglass',
self::STATUS_CLOSED => 'lock', self::STATUS_CLOSED => 'lock',
self::STATUS_SPAM => 'ban-circle', self::STATUS_SPAM => 'ban-circle',
//self::STATUS_OPEN => 'folder-open', //self::STATUS_OPEN => 'folder-open',
); ];
public static $status_colors = array( public static $status_colors = [
self::STATUS_ACTIVE => 'success', self::STATUS_ACTIVE => 'success',
self::STATUS_PENDING => 'warning', self::STATUS_PENDING => 'warning',
self::STATUS_CLOSED => 'grey', self::STATUS_CLOSED => 'grey',
self::STATUS_SPAM => 'danger', self::STATUS_SPAM => 'danger',
//self::STATUS_OPEN => 'folder-open', //self::STATUS_OPEN => 'folder-open',
); ];
/** /**
* Conversation states * Conversation states.
*/ */
const STATE_DRAFT = 1; const STATE_DRAFT = 1;
const STATE_PUBLISHED = 2; const STATE_PUBLISHED = 2;
const STATE_DELETED = 3; const STATE_DELETED = 3;
public static $states = array(
self::STATE_DRAFT => 'draft',
self::STATE_PUBLISHED => 'published',
self::STATE_DELETED => 'deleted',
);
/** public static $states = [
* Source types (equal to thread source types) self::STATE_DRAFT => 'draft',
self::STATE_PUBLISHED => 'published',
self::STATE_DELETED => 'deleted',
];
/**
* Source types (equal to thread source types).
*/ */
const SOURCE_TYPE_EMAIL = 1; const SOURCE_TYPE_EMAIL = 1;
const SOURCE_TYPE_WEB = 2; const SOURCE_TYPE_WEB = 2;
const SOURCE_TYPE_API = 3; const SOURCE_TYPE_API = 3;
public static $source_types = array( public static $source_types = [
self::SOURCE_TYPE_EMAIL => 'email', self::SOURCE_TYPE_EMAIL => 'email',
self::SOURCE_TYPE_WEB => 'web', self::SOURCE_TYPE_WEB => 'web',
self::SOURCE_TYPE_API => 'api', self::SOURCE_TYPE_API => 'api',
); ];
/** /**
* Automatically converted into Carbon dates. * Automatically converted into Carbon dates.
@@ -104,7 +104,7 @@ class Conversation extends Model
protected $dates = ['created_at', 'updated_at', 'last_reply_at']; protected $dates = ['created_at', 'updated_at', 'last_reply_at'];
/** /**
* Attributes which are not fillable using fill() method * Attributes which are not fillable using fill() method.
*/ */
protected $guarded = ['id', 'folder_id']; protected $guarded = ['id', 'folder_id'];
@@ -112,14 +112,13 @@ class Conversation extends Model
{ {
parent::boot(); parent::boot();
self::creating(function (Conversation $model) self::creating(function (Conversation $model) {
{ $model->number = Conversation::where('mailbox_id', $model->mailbox_id)->max('number') + 1;
$model->number = Conversation::where('mailbox_id', $model->mailbox_id)->max('number')+1;
}); });
} }
/** /**
* Who the conversation is assigned to (assignee) * Who the conversation is assigned to (assignee).
*/ */
public function user() public function user()
{ {
@@ -127,7 +126,7 @@ class Conversation extends Model
} }
/** /**
* Get the folder to which conversation belongs * Get the folder to which conversation belongs.
*/ */
public function folder() public function folder()
{ {
@@ -135,7 +134,7 @@ class Conversation extends Model
} }
/** /**
* Get the mailbox to which conversation belongs * Get the mailbox to which conversation belongs.
*/ */
public function mailbox() public function mailbox()
{ {
@@ -143,7 +142,7 @@ class Conversation extends Model
} }
/** /**
* Get the customer associated with this conversation (primaryCustomer) * Get the customer associated with this conversation (primaryCustomer).
*/ */
public function customer() public function customer()
{ {
@@ -151,7 +150,7 @@ class Conversation extends Model
} }
/** /**
* Get conversation threads * Get conversation threads.
*/ */
public function threads() public function threads()
{ {
@@ -159,7 +158,7 @@ class Conversation extends Model
} }
/** /**
* Folders containing starred conversations * Folders containing starred conversations.
*/ */
public function extraFolders() public function extraFolders()
{ {
@@ -167,8 +166,8 @@ class Conversation extends Model
} }
/** /**
* Set preview text * Set preview text.
* *
* @param string $text * @param string $text
*/ */
public function setPreview($text = '') public function setPreview($text = '')
@@ -183,22 +182,24 @@ class Conversation extends Model
$this->preview = mb_substr($first_thread->body, 0, self::PREVIEW_MAXLENGTH); $this->preview = mb_substr($first_thread->body, 0, self::PREVIEW_MAXLENGTH);
} }
} }
return $this->preview; return $this->preview;
} }
/** /**
* Get conversation timestamp title. * Get conversation timestamp title.
* *
* @return string * @return string
*/ */
public function getDateTitle() public function getDateTitle()
{ {
if ($this->threads_count == 1) { if ($this->threads_count == 1) {
$title = __("Created by :person<br/>:date", ['person' => ucfirst(__( $title = __('Created by :person<br/>:date', ['person' => ucfirst(__(
self::$persons[$this->source_via])), 'date' => User::dateFormat($this->created_at, 'M j, Y H:i')]); self::$persons[$this->source_via])), 'date' => User::dateFormat($this->created_at, 'M j, Y H:i')]);
} else { } else {
$title = __("Last reply by :person<br/>:date", ['person' => ucfirst(__(self::$persons[$this->source_via])), 'date' => User::dateFormat($this->created_at, 'M j, Y H:i')]); $title = __('Last reply by :person<br/>:date', ['person' => ucfirst(__(self::$persons[$this->source_via])), 'date' => User::dateFormat($this->created_at, 'M j, Y H:i')]);
} }
return $title; return $title;
} }
@@ -209,31 +210,32 @@ class Conversation extends Model
/** /**
* Get status name. * Get status name.
* *
* @param integer $status * @param int $status
* @return string *
* @return string
*/ */
public static function getStatusName($status) public static function getStatusName($status)
{ {
switch ($status) { switch ($status) {
case self::STATUS_ACTIVE: case self::STATUS_ACTIVE:
return __("Active"); return __('Active');
break; break;
case self::STATUS_PENDING: case self::STATUS_PENDING:
return __("Pending"); return __('Pending');
break; break;
case self::STATUS_CLOSED: case self::STATUS_CLOSED:
return __("Closed"); return __('Closed');
break; break;
case self::STATUS_SPAM: case self::STATUS_SPAM:
return __("Spam"); return __('Spam');
break; break;
case self::STATUS_OPEN: case self::STATUS_OPEN:
return __("Open"); return __('Open');
break; break;
default: default:

View File

@@ -3,28 +3,27 @@
namespace App; namespace App;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use App\Email;
class Customer extends Model class Customer extends Model
{ {
/** /**
* Genders * Genders.
*/ */
const GENDER_UNKNOWN = 1; const GENDER_UNKNOWN = 1;
const GENDER_MALE = 2; const GENDER_MALE = 2;
const GENDER_FEMALE = 3; const GENDER_FEMALE = 3;
/** /**
* For API * For API.
*/ */
public static $genders = [ public static $genders = [
self::GENDER_UNKNOWN => 'unknown', self::GENDER_UNKNOWN => 'unknown',
self::GENDER_MALE => 'male', self::GENDER_MALE => 'male',
self::GENDER_FEMALE => 'female', self::GENDER_FEMALE => 'female',
]; ];
/** /**
* Phone types * Phone types.
*/ */
const PHONE_TYPE_WORK = 1; const PHONE_TYPE_WORK = 1;
const PHONE_TYPE_HOME = 2; const PHONE_TYPE_HOME = 2;
@@ -34,19 +33,19 @@ class Customer extends Model
const PHONE_TYPE_PAGER = 6; const PHONE_TYPE_PAGER = 6;
/** /**
* For API * For API.
*/ */
public static $phone_types = [ public static $phone_types = [
self::PHONE_TYPE_WORK => 'work', self::PHONE_TYPE_WORK => 'work',
self::PHONE_TYPE_HOME => 'home', self::PHONE_TYPE_HOME => 'home',
self::PHONE_TYPE_OTHER => 'other', self::PHONE_TYPE_OTHER => 'other',
self::PHONE_TYPE_MOBILE => 'mobile', self::PHONE_TYPE_MOBILE => 'mobile',
self::PHONE_TYPE_FAX => 'Fax', self::PHONE_TYPE_FAX => 'Fax',
self::PHONE_TYPE_PAGER => 'pager', self::PHONE_TYPE_PAGER => 'pager',
]; ];
/** /**
* Photo types * Photo types.
*/ */
const PHOTO_TYPE_UKNOWN = 1; const PHOTO_TYPE_UKNOWN = 1;
const PHOTO_TYPE_GRAVATAR = 2; const PHOTO_TYPE_GRAVATAR = 2;
@@ -58,21 +57,21 @@ class Customer extends Model
const PHOTO_TYPE_VK = 8; // Extra const PHOTO_TYPE_VK = 8; // Extra
/** /**
* For API * For API.
*/ */
public static $photo_types = [ public static $photo_types = [
self::PHOTO_TYPE_UKNOWN => 'unknown', self::PHOTO_TYPE_UKNOWN => 'unknown',
self::PHOTO_TYPE_GRAVATAR => 'gravatar', self::PHOTO_TYPE_GRAVATAR => 'gravatar',
self::PHOTO_TYPE_TWITTER => 'twitter', self::PHOTO_TYPE_TWITTER => 'twitter',
self::PHOTO_TYPE_FACEBOOK => 'facebook', self::PHOTO_TYPE_FACEBOOK => 'facebook',
self::PHOTO_TYPE_GOOGLEPROFILE => 'googleprofile', self::PHOTO_TYPE_GOOGLEPROFILE => 'googleprofile',
self::PHOTO_TYPE_GOOGLEPLUS => 'googleplus', self::PHOTO_TYPE_GOOGLEPLUS => 'googleplus',
self::PHOTO_TYPE_LINKEDIN => 'linkedin', self::PHOTO_TYPE_LINKEDIN => 'linkedin',
self::PHOTO_TYPE_VK => 'vk', // Extra self::PHOTO_TYPE_VK => 'vk', // Extra
]; ];
/** /**
* Chat types * Chat types.
*/ */
const CHAT_TYPE_AIM = 1; const CHAT_TYPE_AIM = 1;
const CHAT_TYPE_GTALK = 2; const CHAT_TYPE_GTALK = 2;
@@ -86,36 +85,36 @@ class Customer extends Model
const CHAT_TYPE_OTHER = 9; const CHAT_TYPE_OTHER = 9;
/** /**
* For API * For API.
*/ */
public static $chat_types = [ public static $chat_types = [
self::CHAT_TYPE_AIM => 'aim', self::CHAT_TYPE_AIM => 'aim',
self::CHAT_TYPE_GTALK => 'gtalk', self::CHAT_TYPE_GTALK => 'gtalk',
self::CHAT_TYPE_ICQ => 'icq', self::CHAT_TYPE_ICQ => 'icq',
self::CHAT_TYPE_XMPP => 'xmpp', self::CHAT_TYPE_XMPP => 'xmpp',
self::CHAT_TYPE_MSN => 'msn', self::CHAT_TYPE_MSN => 'msn',
self::CHAT_TYPE_SKYPE => 'skype', self::CHAT_TYPE_SKYPE => 'skype',
self::CHAT_TYPE_YAHOO => 'yahoo', self::CHAT_TYPE_YAHOO => 'yahoo',
self::CHAT_TYPE_QQ => 'qq', self::CHAT_TYPE_QQ => 'qq',
self::CHAT_TYPE_WECHAT => 'wechat', // Extra self::CHAT_TYPE_WECHAT => 'wechat', // Extra
self::CHAT_TYPE_OTHER => 'other', self::CHAT_TYPE_OTHER => 'other',
]; ];
public static $chat_type_names = [ public static $chat_type_names = [
self::CHAT_TYPE_AIM => 'AIM', self::CHAT_TYPE_AIM => 'AIM',
self::CHAT_TYPE_GTALK => 'Google+', self::CHAT_TYPE_GTALK => 'Google+',
self::CHAT_TYPE_ICQ => 'ICQ', self::CHAT_TYPE_ICQ => 'ICQ',
self::CHAT_TYPE_XMPP => 'XMPP', self::CHAT_TYPE_XMPP => 'XMPP',
self::CHAT_TYPE_MSN => 'MSN', self::CHAT_TYPE_MSN => 'MSN',
self::CHAT_TYPE_SKYPE => 'Skype', self::CHAT_TYPE_SKYPE => 'Skype',
self::CHAT_TYPE_YAHOO => 'Yahoo', self::CHAT_TYPE_YAHOO => 'Yahoo',
self::CHAT_TYPE_QQ => 'QQ', self::CHAT_TYPE_QQ => 'QQ',
self::CHAT_TYPE_WECHAT => 'WeChat', // Extra self::CHAT_TYPE_WECHAT => 'WeChat', // Extra
self::CHAT_TYPE_OTHER => 'Other', self::CHAT_TYPE_OTHER => 'Other',
]; ];
/** /**
* Social types * Social types.
*/ */
const SOCIAL_TYPE_TWITTER = 1; const SOCIAL_TYPE_TWITTER = 1;
const SOCIAL_TYPE_FACEBOOK = 2; const SOCIAL_TYPE_FACEBOOK = 2;
@@ -132,306 +131,307 @@ class Customer extends Model
const SOCIAL_TYPE_OTHER = 12; const SOCIAL_TYPE_OTHER = 12;
public static $social_types = [ public static $social_types = [
self::SOCIAL_TYPE_TWITTER => 'twitter', self::SOCIAL_TYPE_TWITTER => 'twitter',
self::SOCIAL_TYPE_FACEBOOK => 'facebook', self::SOCIAL_TYPE_FACEBOOK => 'facebook',
self::SOCIAL_TYPE_LINKEDIN => 'linkedin', self::SOCIAL_TYPE_LINKEDIN => 'linkedin',
self::SOCIAL_TYPE_ABOUTME => 'aboutme', self::SOCIAL_TYPE_ABOUTME => 'aboutme',
self::SOCIAL_TYPE_GOOGLE => 'google', self::SOCIAL_TYPE_GOOGLE => 'google',
self::SOCIAL_TYPE_GOOGLEPLUS => 'googleplus', self::SOCIAL_TYPE_GOOGLEPLUS => 'googleplus',
self::SOCIAL_TYPE_TUNGLEME => 'tungleme', self::SOCIAL_TYPE_TUNGLEME => 'tungleme',
self::SOCIAL_TYPE_QUORA => 'quora', self::SOCIAL_TYPE_QUORA => 'quora',
self::SOCIAL_TYPE_FOURSQUARE => 'foursquare', self::SOCIAL_TYPE_FOURSQUARE => 'foursquare',
self::SOCIAL_TYPE_YOUTUBE => 'youtube', self::SOCIAL_TYPE_YOUTUBE => 'youtube',
self::SOCIAL_TYPE_FLICKR => 'flickr', self::SOCIAL_TYPE_FLICKR => 'flickr',
self::SOCIAL_TYPE_VK => 'vk', // Extra self::SOCIAL_TYPE_VK => 'vk', // Extra
self::SOCIAL_TYPE_OTHER => 'other', self::SOCIAL_TYPE_OTHER => 'other',
]; ];
public static $social_type_names = [ public static $social_type_names = [
self::SOCIAL_TYPE_TWITTER => 'Twitter', self::SOCIAL_TYPE_TWITTER => 'Twitter',
self::SOCIAL_TYPE_FACEBOOK => 'Facebook', self::SOCIAL_TYPE_FACEBOOK => 'Facebook',
self::SOCIAL_TYPE_LINKEDIN => 'Linkedin', self::SOCIAL_TYPE_LINKEDIN => 'Linkedin',
self::SOCIAL_TYPE_ABOUTME => 'About.me', self::SOCIAL_TYPE_ABOUTME => 'About.me',
self::SOCIAL_TYPE_GOOGLE => 'Google', self::SOCIAL_TYPE_GOOGLE => 'Google',
self::SOCIAL_TYPE_GOOGLEPLUS => 'Google+', self::SOCIAL_TYPE_GOOGLEPLUS => 'Google+',
self::SOCIAL_TYPE_TUNGLEME => 'Tungle.me', self::SOCIAL_TYPE_TUNGLEME => 'Tungle.me',
self::SOCIAL_TYPE_QUORA => 'Quora', self::SOCIAL_TYPE_QUORA => 'Quora',
self::SOCIAL_TYPE_FOURSQUARE => 'Foursquare', self::SOCIAL_TYPE_FOURSQUARE => 'Foursquare',
self::SOCIAL_TYPE_YOUTUBE => 'YouTube', self::SOCIAL_TYPE_YOUTUBE => 'YouTube',
self::SOCIAL_TYPE_FLICKR => 'Flickr', self::SOCIAL_TYPE_FLICKR => 'Flickr',
self::SOCIAL_TYPE_VK => 'VK', self::SOCIAL_TYPE_VK => 'VK',
self::SOCIAL_TYPE_OTHER => 'Other', self::SOCIAL_TYPE_OTHER => 'Other',
]; ];
/** /**
* Countries list * Countries list.
*/ */
public static $countries = [ public static $countries = [
"US" => "United States", 'US' => 'United States',
"AU" => "Australia", 'AU' => 'Australia',
"CA" => "Canada", 'CA' => 'Canada',
"DK" => "Denmark", 'DK' => 'Denmark',
"FR" => "France", 'FR' => 'France',
"DE" => "Germany", 'DE' => 'Germany',
"IT" => "Italy", 'IT' => 'Italy',
"JP" => "Japan", 'JP' => 'Japan',
"MX" => "Mexico", 'MX' => 'Mexico',
"ES" => "Spain", 'ES' => 'Spain',
"SE" => "Sweden", 'SE' => 'Sweden',
"GB" => "United Kingdom", 'GB' => 'United Kingdom',
"AF" => "Afghanistan", 'AF' => 'Afghanistan',
"AX" => "Åland Islands", 'AX' => 'Åland Islands',
"AL" => "Albania", 'AL' => 'Albania',
"DZ" => "Algeria", 'DZ' => 'Algeria',
"AS" => "American Samoa", 'AS' => 'American Samoa',
"AD" => "Andorra", 'AD' => 'Andorra',
"AO" => "Angola", 'AO' => 'Angola',
"AI" => "Anguilla", 'AI' => 'Anguilla',
"AQ" => "Antarctica", 'AQ' => 'Antarctica',
"AG" => "Antigua and Barbuda", 'AG' => 'Antigua and Barbuda',
"AR" => "Argentina", 'AR' => 'Argentina',
"AM" => "Armenia", 'AM' => 'Armenia',
"AW" => "Aruba", 'AW' => 'Aruba',
"AT" => "Austria", 'AT' => 'Austria',
"AZ" => "Azerbaijan", 'AZ' => 'Azerbaijan',
"BS" => "Bahamas", 'BS' => 'Bahamas',
"BH" => "Bahrain", 'BH' => 'Bahrain',
"BD" => "Bangladesh", 'BD' => 'Bangladesh',
"BB" => "Barbados", 'BB' => 'Barbados',
"BY" => "Belarus", 'BY' => 'Belarus',
"BE" => "Belgium", 'BE' => 'Belgium',
"BZ" => "Belize", 'BZ' => 'Belize',
"BJ" => "Benin", 'BJ' => 'Benin',
"BM" => "Bermuda", 'BM' => 'Bermuda',
"BT" => "Bhutan", 'BT' => 'Bhutan',
"BO" => "Bolivia", 'BO' => 'Bolivia',
"BQ" => "Bonaire", 'BQ' => 'Bonaire',
"BA" => "Bosnia and Herzegowina", 'BA' => 'Bosnia and Herzegowina',
"BW" => "Botswana", 'BW' => 'Botswana',
"BV" => "Bouvet Island", 'BV' => 'Bouvet Island',
"BR" => "Brazil", 'BR' => 'Brazil',
"IO" => "British Indian Ocean Territory", 'IO' => 'British Indian Ocean Territory',
"BN" => "Brunei Darussalam", 'BN' => 'Brunei Darussalam',
"BG" => "Bulgaria", 'BG' => 'Bulgaria',
"BF" => "Burkina Faso", 'BF' => 'Burkina Faso',
"BI" => "Burundi", 'BI' => 'Burundi',
"KH" => "Cambodia", 'KH' => 'Cambodia',
"CM" => "Cameroon", 'CM' => 'Cameroon',
"CV" => "Cape Verde", 'CV' => 'Cape Verde',
"KY" => "Cayman Islands", 'KY' => 'Cayman Islands',
"CF" => "Central African Republic", 'CF' => 'Central African Republic',
"TD" => "Chad", 'TD' => 'Chad',
"CL" => "Chile", 'CL' => 'Chile',
"CN" => "China", 'CN' => 'China',
"CX" => "Christmas Island", 'CX' => 'Christmas Island',
"CC" => "Cocos (Keeling) Islands", 'CC' => 'Cocos (Keeling) Islands',
"CO" => "Colombia", 'CO' => 'Colombia',
"KM" => "Comoros", 'KM' => 'Comoros',
"CG" => "Congo", 'CG' => 'Congo',
"CD" => "Congo, DR", 'CD' => 'Congo, DR',
"CK" => "Cook Islands", 'CK' => 'Cook Islands',
"CR" => "Costa Rica", 'CR' => 'Costa Rica',
"CI" => "Cote D'Ivoire", 'CI' => "Cote D'Ivoire",
"HR" => "Croatia", 'HR' => 'Croatia',
"CU" => "Cuba", 'CU' => 'Cuba',
"CW" => "Curacao", 'CW' => 'Curacao',
"CY" => "Cyprus", 'CY' => 'Cyprus',
"CZ" => "Czech Republic", 'CZ' => 'Czech Republic',
"DJ" => "Djibouti", 'DJ' => 'Djibouti',
"DM" => "Dominica", 'DM' => 'Dominica',
"DO" => "Dominican Republic", 'DO' => 'Dominican Republic',
"EC" => "Ecuador", 'EC' => 'Ecuador',
"EG" => "Egypt", 'EG' => 'Egypt',
"SV" => "El Salvador", 'SV' => 'El Salvador',
"GQ" => "Equatorial Guinea", 'GQ' => 'Equatorial Guinea',
"ER" => "Eritrea", 'ER' => 'Eritrea',
"EE" => "Estonia", 'EE' => 'Estonia',
"ET" => "Ethiopia", 'ET' => 'Ethiopia',
"FK" => "Falkland Islands (Malvinas)", 'FK' => 'Falkland Islands (Malvinas)',
"FO" => "Faroe Islands", 'FO' => 'Faroe Islands',
"FJ" => "Fiji", 'FJ' => 'Fiji',
"FI" => "Finland", 'FI' => 'Finland',
"GF" => "French Guiana", 'GF' => 'French Guiana',
"PF" => "French Polynesia", 'PF' => 'French Polynesia',
"TF" => "French Southern Territories", 'TF' => 'French Southern Territories',
"GA" => "Gabon", 'GA' => 'Gabon',
"GM" => "Gambia", 'GM' => 'Gambia',
"GE" => "Georgia", 'GE' => 'Georgia',
"GH" => "Ghana", 'GH' => 'Ghana',
"GI" => "Gibraltar", 'GI' => 'Gibraltar',
"GR" => "Greece", 'GR' => 'Greece',
"GL" => "Greenland", 'GL' => 'Greenland',
"GD" => "Grenada", 'GD' => 'Grenada',
"GP" => "Guadeloupe", 'GP' => 'Guadeloupe',
"GU" => "Guam", 'GU' => 'Guam',
"GT" => "Guatemala", 'GT' => 'Guatemala',
"GG" => "Guernsey", 'GG' => 'Guernsey',
"GN" => "Guinea", 'GN' => 'Guinea',
"GW" => "Guinea-bissau", 'GW' => 'Guinea-bissau',
"GY" => "Guyana", 'GY' => 'Guyana',
"HT" => "Haiti", 'HT' => 'Haiti',
"HM" => "Heard and Mc Donald Islands", 'HM' => 'Heard and Mc Donald Islands',
"HN" => "Honduras", 'HN' => 'Honduras',
"HK" => "Hong Kong", 'HK' => 'Hong Kong',
"HU" => "Hungary", 'HU' => 'Hungary',
"IS" => "Iceland", 'IS' => 'Iceland',
"IN" => "India", 'IN' => 'India',
"ID" => "Indonesia", 'ID' => 'Indonesia',
"IR" => "Iran (Islamic Republic of)", 'IR' => 'Iran (Islamic Republic of)',
"IQ" => "Iraq", 'IQ' => 'Iraq',
"IE" => "Ireland", 'IE' => 'Ireland',
"IM" => "Isle of Man", 'IM' => 'Isle of Man',
"IL" => "Israel", 'IL' => 'Israel',
"JM" => "Jamaica", 'JM' => 'Jamaica',
"JE" => "Jersey", 'JE' => 'Jersey',
"JO" => "Jordan", 'JO' => 'Jordan',
"KZ" => "Kazakhstan", 'KZ' => 'Kazakhstan',
"KE" => "Kenya", 'KE' => 'Kenya',
"KI" => "Kiribati", 'KI' => 'Kiribati',
"KP" => "Korea, Democratic People's Republic of", 'KP' => "Korea, Democratic People's Republic of",
"KR" => "Korea, Republic of", 'KR' => 'Korea, Republic of',
"KW" => "Kuwait", 'KW' => 'Kuwait',
"KG" => "Kyrgyzstan", 'KG' => 'Kyrgyzstan',
"LA" => "Lao People's Democratic Republic", 'LA' => "Lao People's Democratic Republic",
"LV" => "Latvia", 'LV' => 'Latvia',
"LB" => "Lebanon", 'LB' => 'Lebanon',
"LS" => "Lesotho", 'LS' => 'Lesotho',
"LR" => "Liberia", 'LR' => 'Liberia',
"LY" => "Libya", 'LY' => 'Libya',
"LI" => "Liechtenstein", 'LI' => 'Liechtenstein',
"LT" => "Lithuania", 'LT' => 'Lithuania',
"LU" => "Luxembourg", 'LU' => 'Luxembourg',
"MO" => "Macao", 'MO' => 'Macao',
"MK" => "Macedonia, The Former Yugoslav Republic of", 'MK' => 'Macedonia, The Former Yugoslav Republic of',
"MG" => "Madagascar", 'MG' => 'Madagascar',
"MW" => "Malawi", 'MW' => 'Malawi',
"MY" => "Malaysia", 'MY' => 'Malaysia',
"MV" => "Maldives", 'MV' => 'Maldives',
"ML" => "Mali", 'ML' => 'Mali',
"MT" => "Malta", 'MT' => 'Malta',
"MH" => "Marshall Islands", 'MH' => 'Marshall Islands',
"MQ" => "Martinique", 'MQ' => 'Martinique',
"MR" => "Mauritania", 'MR' => 'Mauritania',
"MU" => "Mauritius", 'MU' => 'Mauritius',
"YT" => "Mayotte", 'YT' => 'Mayotte',
"FM" => "Micronesia, Federated States of", 'FM' => 'Micronesia, Federated States of',
"MD" => "Moldova, Republic of", 'MD' => 'Moldova, Republic of',
"MC" => "Monaco", 'MC' => 'Monaco',
"MN" => "Mongolia", 'MN' => 'Mongolia',
"ME" => "Montenegro", 'ME' => 'Montenegro',
"MS" => "Montserrat", 'MS' => 'Montserrat',
"MA" => "Morocco", 'MA' => 'Morocco',
"MZ" => "Mozambique", 'MZ' => 'Mozambique',
"MM" => "Myanmar", 'MM' => 'Myanmar',
"NA" => "Namibia", 'NA' => 'Namibia',
"NR" => "Nauru", 'NR' => 'Nauru',
"NP" => "Nepal", 'NP' => 'Nepal',
"NL" => "Netherlands", 'NL' => 'Netherlands',
"NC" => "New Caledonia", 'NC' => 'New Caledonia',
"NZ" => "New Zealand", 'NZ' => 'New Zealand',
"NI" => "Nicaragua", 'NI' => 'Nicaragua',
"NE" => "Niger", 'NE' => 'Niger',
"NG" => "Nigeria", 'NG' => 'Nigeria',
"NU" => "Niue", 'NU' => 'Niue',
"00" => "None Available", '00' => 'None Available',
"NF" => "Norfolk Island", 'NF' => 'Norfolk Island',
"MP" => "Northern Mariana Islands", 'MP' => 'Northern Mariana Islands',
"NO" => "Norway", 'NO' => 'Norway',
"OM" => "Oman", 'OM' => 'Oman',
"PK" => "Pakistan", 'PK' => 'Pakistan',
"PW" => "Palau", 'PW' => 'Palau',
"PS" => "Palestine, State of", 'PS' => 'Palestine, State of',
"PA" => "Panama", 'PA' => 'Panama',
"PG" => "Papua New Guinea", 'PG' => 'Papua New Guinea',
"PY" => "Paraguay", 'PY' => 'Paraguay',
"PE" => "Peru", 'PE' => 'Peru',
"PH" => "Philippines", 'PH' => 'Philippines',
"PN" => "Pitcairn", 'PN' => 'Pitcairn',
"PL" => "Poland", 'PL' => 'Poland',
"PT" => "Portugal", 'PT' => 'Portugal',
"PR" => "Puerto Rico", 'PR' => 'Puerto Rico',
"QA" => "Qatar", 'QA' => 'Qatar',
"RE" => "Reunion", 'RE' => 'Reunion',
"RO" => "Romania", 'RO' => 'Romania',
"RU" => "Russia", 'RU' => 'Russia',
"RW" => "Rwanda", 'RW' => 'Rwanda',
"BL" => "Saint Barthelemy", 'BL' => 'Saint Barthelemy',
"KN" => "Saint Kitts and Nevis", 'KN' => 'Saint Kitts and Nevis',
"LC" => "Saint Lucia", 'LC' => 'Saint Lucia',
"MF" => "Saint Martin (French part)", 'MF' => 'Saint Martin (French part)',
"VC" => "Saint Vincent and the Grenadines", 'VC' => 'Saint Vincent and the Grenadines',
"WS" => "Samoa", 'WS' => 'Samoa',
"SM" => "San Marino", 'SM' => 'San Marino',
"ST" => "Sao Tome and Principe", 'ST' => 'Sao Tome and Principe',
"SA" => "Saudi Arabia", 'SA' => 'Saudi Arabia',
"SN" => "Senegal", 'SN' => 'Senegal',
"RS" => "Serbia", 'RS' => 'Serbia',
"SC" => "Seychelles", 'SC' => 'Seychelles',
"SL" => "Sierra Leone", 'SL' => 'Sierra Leone',
"SG" => "Singapore", 'SG' => 'Singapore',
"SX" => "Sint Maarten (Dutch part)", 'SX' => 'Sint Maarten (Dutch part)',
"SK" => "Slovakia", 'SK' => 'Slovakia',
"SI" => "Slovenia", 'SI' => 'Slovenia',
"SB" => "Solomon Islands", 'SB' => 'Solomon Islands',
"SO" => "Somalia", 'SO' => 'Somalia',
"ZA" => "South Africa", 'ZA' => 'South Africa',
"GS" => "South Georgia and the South Sandwich Islands", 'GS' => 'South Georgia and the South Sandwich Islands',
"SS" => "South Sudan", 'SS' => 'South Sudan',
"LK" => "Sri Lanka", 'LK' => 'Sri Lanka',
"SH" => "St. Helena", 'SH' => 'St. Helena',
"PM" => "St. Pierre and Miquelon", 'PM' => 'St. Pierre and Miquelon',
"SD" => "Sudan", 'SD' => 'Sudan',
"SR" => "Suriname", 'SR' => 'Suriname',
"SJ" => "Svalbard and Jan Mayen", 'SJ' => 'Svalbard and Jan Mayen',
"SZ" => "Swaziland", 'SZ' => 'Swaziland',
"CH" => "Switzerland", 'CH' => 'Switzerland',
"SY" => "Syrian Arab Republic", 'SY' => 'Syrian Arab Republic',
"TW" => "Taiwan, Province of China", 'TW' => 'Taiwan, Province of China',
"TJ" => "Tajikistan", 'TJ' => 'Tajikistan',
"TZ" => "Tanzania, United Republic of", 'TZ' => 'Tanzania, United Republic of',
"TH" => "Thailand", 'TH' => 'Thailand',
"TL" => "Timor-Leste", 'TL' => 'Timor-Leste',
"TG" => "Togo", 'TG' => 'Togo',
"TK" => "Tokelau", 'TK' => 'Tokelau',
"TO" => "Tonga", 'TO' => 'Tonga',
"TT" => "Trinidad and Tobago", 'TT' => 'Trinidad and Tobago',
"TN" => "Tunisia", 'TN' => 'Tunisia',
"TR" => "Turkey", 'TR' => 'Turkey',
"TM" => "Turkmenistan", 'TM' => 'Turkmenistan',
"TC" => "Turks and Caicos Islands", 'TC' => 'Turks and Caicos Islands',
"TV" => "Tuvalu", 'TV' => 'Tuvalu',
"UG" => "Uganda", 'UG' => 'Uganda',
"UA" => "Ukraine", 'UA' => 'Ukraine',
"AE" => "United Arab Emirates", 'AE' => 'United Arab Emirates',
"UM" => "United States Minor Outlying Islands", 'UM' => 'United States Minor Outlying Islands',
"UY" => "Uruguay", 'UY' => 'Uruguay',
"UZ" => "Uzbekistan", 'UZ' => 'Uzbekistan',
"VU" => "Vanuatu", 'VU' => 'Vanuatu',
"VA" => "Vatican City State (Holy See)", 'VA' => 'Vatican City State (Holy See)',
"VE" => "Venezuela", 'VE' => 'Venezuela',
"VN" => "Vietnam", 'VN' => 'Vietnam',
"VG" => "Virgin Islands (British)", 'VG' => 'Virgin Islands (British)',
"VI" => "Virgin Islands (U.S.)", 'VI' => 'Virgin Islands (U.S.)',
"WF" => "Wallis and Futuna Islands", 'WF' => 'Wallis and Futuna Islands',
"EH" => "Western Sahara", 'EH' => 'Western Sahara',
"YE" => "Yemen", 'YE' => 'Yemen',
"ZM" => "Zambia", 'ZM' => 'Zambia',
"ZW" => "Zimbabwe", 'ZW' => 'Zimbabwe',
]; ];
/** /**
* Attributes which are not fillable using fill() method * Attributes which are not fillable using fill() method.
*/ */
protected $guarded = ['id']; protected $guarded = ['id'];
/** /**
* Attributes fillable using fill() method * Attributes fillable using fill() method.
*
* @var [type] * @var [type]
*/ */
protected $fillable = ['first_name', 'last_name', 'company', 'job_title', 'address', 'city', 'state', 'zip', 'country']; protected $fillable = ['first_name', 'last_name', 'company', 'job_title', 'address', 'city', 'state', 'zip', 'country'];
/** /**
* Get customer emails * Get customer emails.
*/ */
public function emails() public function emails()
{ {
@@ -439,7 +439,7 @@ class Customer extends Model
} }
/** /**
* Get customer conversations * Get customer conversations.
*/ */
public function conversations() public function conversations()
{ {
@@ -447,7 +447,7 @@ class Customer extends Model
} }
/** /**
* Get main email * Get main email.
*/ */
public function getMainEmail() public function getMainEmail()
{ {
@@ -456,23 +456,24 @@ class Customer extends Model
/** /**
* Get customer full name. * Get customer full name.
* *
* @return string * @return string
*/ */
public function getFullName() public function getFullName()
{ {
if ($this->first_name || $this->last_name) { if ($this->first_name || $this->last_name) {
return $this->first_name . ' ' . $this->last_name; return $this->first_name.' '.$this->last_name;
} elseif ($this->emails) { } elseif ($this->emails) {
return explode('@', $this->emails[0]->email)[0]; return explode('@', $this->emails[0]->email)[0];
} else { } else {
return $this->id; return $this->id;
} }
} }
/** /**
* Set customer emails * Set customer emails.
* @param array $emails *
* @param array $emails
*/ */
public function syncEmails($emails) public function syncEmails($emails)
{ {
@@ -508,7 +509,7 @@ class Customer extends Model
} }
// Create customers for deleted emails // Create customers for deleted emails
foreach ($deleted_emails as $email) { foreach ($deleted_emails as $email) {
$customer = new Customer(); $customer = new self();
$customer->save(); $customer->save();
$email->customer()->associate($customer); $email->customer()->associate($customer);
$email->save(); $email->save();
@@ -518,7 +519,7 @@ class Customer extends Model
/** /**
* Get customers phones as array. * Get customers phones as array.
* *
* @return array * @return array
*/ */
public function getPhones() public function getPhones()
@@ -532,7 +533,7 @@ class Customer extends Model
/** /**
* Set phones as JSON. * Set phones as JSON.
* *
* @param array $phones_array * @param array $phones_array
*/ */
public function setPhones(array $phones_array) public function setPhones(array $phones_array)
@@ -541,10 +542,11 @@ class Customer extends Model
} }
/** /**
* Sanitize phones array * Sanitize phones array.
* *
* @param array $phones_array [description] * @param array $phones_array [description]
* @return array [description] *
* @return array [description]
*/ */
public static function formatPhones(array $phones_array) public static function formatPhones(array $phones_array)
{ {
@@ -552,17 +554,18 @@ class Customer extends Model
foreach ($phones_array as $phone) { foreach ($phones_array as $phone) {
if (!empty($phone['value']) && !empty($phone['type']) && in_array($phone['type'], array_keys(self::$phone_types))) { if (!empty($phone['value']) && !empty($phone['type']) && in_array($phone['type'], array_keys(self::$phone_types))) {
$phones[] = [ $phones[] = [
'value' => (string)$phone['value'], 'value' => (string) $phone['value'],
'type' => (int)$phone['type'], 'type' => (int) $phone['type'],
]; ];
} }
} }
return json_encode($phones); return json_encode($phones);
} }
/** /**
* Get customers social profiles as array. * Get customers social profiles as array.
* *
* @return array * @return array
*/ */
public function getSocialProfiles() public function getSocialProfiles()
@@ -576,7 +579,7 @@ class Customer extends Model
/** /**
* Get customers social profiles as array. * Get customers social profiles as array.
* *
* @return array * @return array
*/ */
public function getWebsites($dummy_if_empty = false) public function getWebsites($dummy_if_empty = false)
@@ -591,18 +594,19 @@ class Customer extends Model
} }
/** /**
* Set websites as JSON * Set websites as JSON.
*
* @param array $websites_array * @param array $websites_array
*/ */
public function setWebsites(array $websites_array) public function setWebsites(array $websites_array)
{ {
$websites = []; $websites = [];
foreach ($websites_array as $key => $value) { foreach ($websites_array as $key => $value) {
$value = filter_var((string)$value, FILTER_SANITIZE_URL); $value = filter_var((string) $value, FILTER_SANITIZE_URL);
if (!preg_match("/http(s)?:\/\//i", $value)) { if (!preg_match("/http(s)?:\/\//i", $value)) {
$value = 'http://'.$value; $value = 'http://'.$value;
} }
$websites[] = (string)$value; $websites[] = (string) $value;
} }
$this->websites = json_encode($websites); $this->websites = json_encode($websites);
} }

View File

@@ -6,22 +6,22 @@ use Illuminate\Database\Eloquent\Model;
class Email extends Model class Email extends Model
{ {
/** /**
* Email types * Email types.
*/ */
const TYPE_WORK = 'work'; const TYPE_WORK = 'work';
const TYPE_HOME = 'home'; const TYPE_HOME = 'home';
const TYPE_OTHER = 'other'; const TYPE_OTHER = 'other';
public $timestamps = false; public $timestamps = false;
/** /**
* Attributes which are not fillable using fill() method * Attributes which are not fillable using fill() method.
*/ */
protected $guarded = ['id', 'customer_id']; protected $guarded = ['id', 'customer_id'];
/** /**
* Get email's customer * Get email's customer.
*/ */
public function customer() public function customer()
{ {
@@ -29,9 +29,11 @@ class Email extends Model
} }
/** /**
* Sanatize email address * Sanatize email address.
* @param string $email *
* @return string * @param string $email
*
* @return string
*/ */
public static function sanatizeEmail($email) public static function sanatizeEmail($email)
{ {

View File

@@ -3,12 +3,10 @@
namespace App\Events; namespace App\Events;
use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class Event class Event
{ {

View File

@@ -31,7 +31,8 @@ class Handler extends ExceptionHandler
* *
* This is a great spot to send exceptions to Sentry, Bugsnag, etc. * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
* *
* @param \Exception $exception * @param \Exception $exception
*
* @return void * @return void
*/ */
public function report(Exception $exception) public function report(Exception $exception)
@@ -42,8 +43,9 @@ class Handler extends ExceptionHandler
/** /**
* Render an exception into an HTTP response. * Render an exception into an HTTP response.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Exception $exception * @param \Exception $exception
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function render($request, Exception $exception) public function render($request, Exception $exception)

View File

@@ -3,12 +3,11 @@
namespace App; namespace App;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use App\MailboxUser;
class Folder extends Model class Folder extends Model
{ {
/** /**
* Folders types (ids from HelpScout interface) * Folders types (ids from HelpScout interface).
*/ */
const TYPE_UNASSIGNED = 1; const TYPE_UNASSIGNED = 1;
// User specific // User specific
@@ -23,27 +22,27 @@ class Folder extends Model
public static $types = [ public static $types = [
self::TYPE_UNASSIGNED => 'Unassigned', self::TYPE_UNASSIGNED => 'Unassigned',
self::TYPE_MINE => 'Mine', self::TYPE_MINE => 'Mine',
self::TYPE_DRAFTS => 'Drafts', self::TYPE_DRAFTS => 'Drafts',
self::TYPE_ASSIGNED => 'Assigned', self::TYPE_ASSIGNED => 'Assigned',
self::TYPE_CLOSED => 'Closed', self::TYPE_CLOSED => 'Closed',
self::TYPE_SPAM => 'Spam', self::TYPE_SPAM => 'Spam',
self::TYPE_DELETED => 'Deleted', self::TYPE_DELETED => 'Deleted',
self::TYPE_STARRED => 'Starred', self::TYPE_STARRED => 'Starred',
]; ];
/** /**
* https://glyphicons.bootstrapcheatsheets.com/ * https://glyphicons.bootstrapcheatsheets.com/.
*/ */
public static $type_icons = [ public static $type_icons = [
self::TYPE_UNASSIGNED => 'folder-open', self::TYPE_UNASSIGNED => 'folder-open',
self::TYPE_MINE => 'hand-right', self::TYPE_MINE => 'hand-right',
self::TYPE_DRAFTS => 'duplicate', self::TYPE_DRAFTS => 'duplicate',
self::TYPE_ASSIGNED => 'user', self::TYPE_ASSIGNED => 'user',
self::TYPE_CLOSED => 'lock', // lock self::TYPE_CLOSED => 'lock', // lock
self::TYPE_SPAM => 'ban-circle', self::TYPE_SPAM => 'ban-circle',
self::TYPE_DELETED => 'trash', self::TYPE_DELETED => 'trash',
self::TYPE_STARRED => 'star', self::TYPE_STARRED => 'star',
]; ];
// Public non-user specific mailbox types // Public non-user specific mailbox types
@@ -65,7 +64,7 @@ class Folder extends Model
public $timestamps = false; public $timestamps = false;
/** /**
* Get the mailbox to which folder belongs * Get the mailbox to which folder belongs.
*/ */
public function mailbox() public function mailbox()
{ {
@@ -73,7 +72,7 @@ class Folder extends Model
} }
/** /**
* Get the user to which folder belongs * Get the user to which folder belongs.
*/ */
public function user() public function user()
{ {
@@ -81,7 +80,7 @@ class Folder extends Model
} }
/** /**
* Get starred conversations * Get starred conversations.
*/ */
public function conversations() public function conversations()
{ {

View File

@@ -2,10 +2,10 @@
namespace App\Http\Controllers\Auth; namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator; use App\User;
use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Validator;
class RegisterController extends Controller class RegisterController extends Controller
{ {
@@ -42,37 +42,39 @@ class RegisterController extends Controller
/** /**
* Get a validator for an incoming registration request. * Get a validator for an incoming registration request.
* *
* @param array $data * @param array $data
*
* @return \Illuminate\Contracts\Validation\Validator * @return \Illuminate\Contracts\Validation\Validator
*/ */
protected function validator(array $data) protected function validator(array $data)
{ {
return Validator::make($data, [ return Validator::make($data, [
'first_name' => 'required|string|max:255', 'first_name' => 'required|string|max:255',
'last_name' => 'required|string|max:255', 'last_name' => 'required|string|max:255',
'email' => 'required|string|email|max:191|unique:users', 'email' => 'required|string|email|max:191|unique:users',
'password' => 'required|string|min:8|confirmed', 'password' => 'required|string|min:8|confirmed',
]); ]);
} }
/** /**
* Create a new user instance after a valid registration. * Create a new user instance after a valid registration.
* *
* @param array $data * @param array $data
*
* @return \App\User * @return \App\User
*/ */
protected function create(array $data) protected function create(array $data)
{ {
return User::create([ return User::create([
'first_name' => $data['first_name'], 'first_name' => $data['first_name'],
'last_name' => $data['last_name'], 'last_name' => $data['last_name'],
'email' => $data['email'], 'email' => $data['email'],
'password' => bcrypt($data['password']), 'password' => bcrypt($data['password']),
]); ]);
} }
/** /**
* Registration is disabled * Registration is disabled.
*/ */
public function showRegistrationForm() public function showRegistrationForm()
{ {
@@ -81,6 +83,5 @@ class RegisterController extends Controller
public function register() public function register()
{ {
} }
} }

View File

@@ -2,10 +2,10 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController class Controller extends BaseController
{ {

View File

@@ -2,8 +2,6 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator;
use App\Conversation; use App\Conversation;
class ConversationsController extends Controller class ConversationsController extends Controller
@@ -29,11 +27,11 @@ class ConversationsController extends Controller
return view('conversations/view', [ return view('conversations/view', [
'conversation' => $conversation, 'conversation' => $conversation,
'mailbox' => $conversation->mailbox, 'mailbox' => $conversation->mailbox,
'customer' => $conversation->customer, 'customer' => $conversation->customer,
'threads' => $conversation->threads, 'threads' => $conversation->threads,
'folder' => $conversation->folder, 'folder' => $conversation->folder,
'folders' => $conversation->mailbox->getAssesibleFolders() 'folders' => $conversation->mailbox->getAssesibleFolders(),
]); ]);
} }
} }

View File

@@ -2,11 +2,9 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Customer;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Validator; use Validator;
use Illuminate\Validation\Rule;
use App\Customer;
use App\Email;
class CustomersController extends Controller class CustomersController extends Controller
{ {
@@ -21,7 +19,7 @@ class CustomersController extends Controller
} }
/** /**
* Edit customer * Edit customer.
*/ */
public function update($id) public function update($id)
{ {
@@ -42,7 +40,8 @@ class CustomersController extends Controller
/** /**
* Save customer. * Save customer.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function updateSave($id, Request $request) public function updateSave($id, Request $request)
@@ -51,11 +50,11 @@ class CustomersController extends Controller
$validator = Validator::make($request->all(), [ $validator = Validator::make($request->all(), [
'first_name' => 'nullable|string|max:255', 'first_name' => 'nullable|string|max:255',
'last_name' => 'nullable|string|max:255', 'last_name' => 'nullable|string|max:255',
'city' => 'nullable|string|max:255', 'city' => 'nullable|string|max:255',
'state' => 'nullable|string|max:255', 'state' => 'nullable|string|max:255',
'zip' => 'nullable|string|max:12', 'zip' => 'nullable|string|max:12',
'country' => 'nullable|string|max:2', 'country' => 'nullable|string|max:2',
]); ]);
if ($validator->fails()) { if ($validator->fails()) {
@@ -74,11 +73,12 @@ class CustomersController extends Controller
$customer->syncEmails($request->emails); $customer->syncEmails($request->emails);
\Session::flash('flash_success', __('Customer saved successfully')); \Session::flash('flash_success', __('Customer saved successfully'));
return redirect()->route('customers.update', ['id' => $id]); return redirect()->route('customers.update', ['id' => $id]);
} }
/** /**
* User mailboxes * User mailboxes.
*/ */
public function permissions($id) public function permissions($id)
{ {
@@ -91,10 +91,10 @@ class CustomersController extends Controller
} }
/** /**
* Save user permissions * Save user permissions.
* *
* @param int $id * @param int $id
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*/ */
public function permissionsSave($id, Request $request) public function permissionsSave($id, Request $request)
{ {
@@ -104,13 +104,14 @@ class CustomersController extends Controller
$user->mailboxes()->sync($request->mailboxes); $user->mailboxes()->sync($request->mailboxes);
\Session::flash('flash_success', __('Permissions saved successfully')); \Session::flash('flash_success', __('Permissions saved successfully'));
return redirect()->route('users.permissions', ['id' => $id]); return redirect()->route('users.permissions', ['id' => $id]);
} }
/** /**
* View customer conversations. * View customer conversations.
* *
* @param intg $id * @param intg $id
*/ */
public function conversations($id) public function conversations($id)
{ {

View File

@@ -2,12 +2,12 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Folder;
use App\Mailbox;
use App\User;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use Validator; use Validator;
use App\Mailbox;
use App\User;
use App\Folder;
class MailboxesController extends Controller class MailboxesController extends Controller
{ {
@@ -22,7 +22,7 @@ class MailboxesController extends Controller
} }
/** /**
* Mailboxes list * Mailboxes list.
*/ */
public function mailboxes() public function mailboxes()
{ {
@@ -32,21 +32,21 @@ class MailboxesController extends Controller
} }
/** /**
* New mailbox * New mailbox.
*/ */
public function create() public function create()
{ {
$this->authorize('create', 'App\Mailbox'); $this->authorize('create', 'App\Mailbox');
$users = User::where('role', '!=', User::ROLE_ADMIN)->get(); $users = User::where('role', '!=', User::ROLE_ADMIN)->get();
return view('mailboxes/create', ['users' => $users]); return view('mailboxes/create', ['users' => $users]);
} }
/** /**
* Create new mailbox * Create new mailbox.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*/ */
public function createSave(Request $request) public function createSave(Request $request)
{ {
@@ -54,7 +54,7 @@ class MailboxesController extends Controller
$validator = Validator::make($request->all(), [ $validator = Validator::make($request->all(), [
'email' => 'required|string|email|max:128|unique:mailboxes', 'email' => 'required|string|email|max:128|unique:mailboxes',
'name' => 'required|string|max:40', 'name' => 'required|string|max:40',
]); ]);
// //event(new Registered($user = $this->create($request->all()))); // //event(new Registered($user = $this->create($request->all())));
@@ -65,7 +65,7 @@ class MailboxesController extends Controller
->withInput(); ->withInput();
} }
$mailbox = new Mailbox; $mailbox = new Mailbox();
$mailbox->fill($request->all()); $mailbox->fill($request->all());
$mailbox->save(); $mailbox->save();
@@ -73,11 +73,12 @@ class MailboxesController extends Controller
$mailbox->syncPersonalFolders($request->users); $mailbox->syncPersonalFolders($request->users);
\Session::flash('flash_success', __('Mailbox created successfully')); \Session::flash('flash_success', __('Mailbox created successfully'));
return redirect()->route('mailboxes.update', ['id' => $mailbox->id]); return redirect()->route('mailboxes.update', ['id' => $mailbox->id]);
} }
/** /**
* Edit mailbox * Edit mailbox.
*/ */
public function update($id) public function update($id)
{ {
@@ -90,10 +91,10 @@ class MailboxesController extends Controller
} }
/** /**
* Save mailbox * Save mailbox.
* *
* @param int $id * @param int $id
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*/ */
public function updateSave($id, Request $request) public function updateSave($id, Request $request)
{ {
@@ -102,15 +103,15 @@ class MailboxesController extends Controller
$this->authorize('update', $mailbox); $this->authorize('update', $mailbox);
$validator = Validator::make($request->all(), [ $validator = Validator::make($request->all(), [
'name' => 'required|string|max:40', 'name' => 'required|string|max:40',
'email' => 'required|string|email|max:128|unique:mailboxes,email,'.$id, 'email' => 'required|string|email|max:128|unique:mailboxes,email,'.$id,
'aliases' => 'string|max:128', 'aliases' => 'string|max:128',
'from_name' => 'required|integer', 'from_name' => 'required|integer',
'from_name_custom' => 'nullable|string|max:128', 'from_name_custom' => 'nullable|string|max:128',
'ticket_status' => 'required|integer', 'ticket_status' => 'required|integer',
'template' => 'required|integer', 'template' => 'required|integer',
'ticket_assignee' => 'required|integer', 'ticket_assignee' => 'required|integer',
'signature' => 'nullable|string', 'signature' => 'nullable|string',
]); ]);
//event(new Registered($user = $this->create($request->all()))); //event(new Registered($user = $this->create($request->all())));
@@ -126,16 +127,17 @@ class MailboxesController extends Controller
$mailbox->save(); $mailbox->save();
\Session::flash('flash_success', __('Mailbox settings saved')); \Session::flash('flash_success', __('Mailbox settings saved'));
return redirect()->route('mailboxes.update', ['id' => $id]); return redirect()->route('mailboxes.update', ['id' => $id]);
} }
/** /**
* Mailbox permissions * Mailbox permissions.
*/ */
public function permissions($id) public function permissions($id)
{ {
$mailbox = Mailbox::findOrFail($id); $mailbox = Mailbox::findOrFail($id);
$this->authorize('update', $mailbox); $this->authorize('update', $mailbox);
$users = User::where('role', '!=', User::ROLE_ADMIN)->get(); $users = User::where('role', '!=', User::ROLE_ADMIN)->get();
@@ -144,10 +146,10 @@ class MailboxesController extends Controller
} }
/** /**
* Save mailbox permissions * Save mailbox permissions.
* *
* @param int $id * @param int $id
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*/ */
public function permissionsSave($id, Request $request) public function permissionsSave($id, Request $request)
{ {
@@ -158,11 +160,12 @@ class MailboxesController extends Controller
$mailbox->syncPersonalFolders($request->users); $mailbox->syncPersonalFolders($request->users);
\Session::flash('flash_success', __('Mailbox permissions saved!')); \Session::flash('flash_success', __('Mailbox permissions saved!'));
return redirect()->route('mailboxes.permissions', ['id' => $id]); return redirect()->route('mailboxes.permissions', ['id' => $id]);
} }
/** /**
* Mailbox connection settings * Mailbox connection settings.
*/ */
public function connectionOutgoing($id) public function connectionOutgoing($id)
{ {
@@ -173,7 +176,7 @@ class MailboxesController extends Controller
} }
/** /**
* Save mailbox connection settings * Save mailbox connection settings.
*/ */
public function connectionOutgoingSave($id, Request $request) public function connectionOutgoingSave($id, Request $request)
{ {
@@ -182,11 +185,11 @@ class MailboxesController extends Controller
if ($request->out_method == Mailbox::OUT_METHOD_SMTP) { if ($request->out_method == Mailbox::OUT_METHOD_SMTP) {
$validator = Validator::make($request->all(), [ $validator = Validator::make($request->all(), [
'out_server' => 'required|string|max:255', 'out_server' => 'required|string|max:255',
'out_port' => 'required|integer', 'out_port' => 'required|integer',
'out_username' => 'required|string|max:100', 'out_username' => 'required|string|max:100',
'out_password' => 'required|string|max:255', 'out_password' => 'required|string|max:255',
'out_ssl' => 'required|integer', 'out_ssl' => 'required|integer',
]); ]);
if ($validator->fails()) { if ($validator->fails()) {
@@ -200,11 +203,12 @@ class MailboxesController extends Controller
$mailbox->save(); $mailbox->save();
\Session::flash('flash_success', __('Connection settings saved!')); \Session::flash('flash_success', __('Connection settings saved!'));
return redirect()->route('mailboxes.connection', ['id' => $id]); return redirect()->route('mailboxes.connection', ['id' => $id]);
} }
/** /**
* Mailbox incoming settings * Mailbox incoming settings.
*/ */
public function connectionIncoming($id) public function connectionIncoming($id)
{ {
@@ -215,7 +219,7 @@ class MailboxesController extends Controller
} }
/** /**
* Save mailbox connection settings * Save mailbox connection settings.
*/ */
public function connectionIncomingSave($id, Request $request) public function connectionIncomingSave($id, Request $request)
{ {
@@ -223,8 +227,8 @@ class MailboxesController extends Controller
$this->authorize('update', $mailbox); $this->authorize('update', $mailbox);
$validator = Validator::make($request->all(), [ $validator = Validator::make($request->all(), [
'in_server' => 'required|string|max:255', 'in_server' => 'required|string|max:255',
'in_port' => 'required|integer', 'in_port' => 'required|integer',
'in_username' => 'required|string|max:100', 'in_username' => 'required|string|max:100',
'in_password' => 'required|string|max:255', 'in_password' => 'required|string|max:255',
]); ]);
@@ -239,11 +243,12 @@ class MailboxesController extends Controller
$mailbox->save(); $mailbox->save();
\Session::flash('flash_success', __('Connection settings saved!')); \Session::flash('flash_success', __('Connection settings saved!'));
return redirect()->route('mailboxes.connection.incoming', ['id' => $id]); return redirect()->route('mailboxes.connection.incoming', ['id' => $id]);
} }
/** /**
* View mailbox * View mailbox.
*/ */
public function view($id, $folder_id = null) public function view($id, $folder_id = null)
{ {
@@ -253,13 +258,13 @@ class MailboxesController extends Controller
$folder = null; $folder = null;
if (!empty($folder_id)) { if (!empty($folder_id)) {
$folder = $folders->filter(function($item) use ($folder_id) { $folder = $folders->filter(function ($item) use ($folder_id) {
return $item->id == $folder_id; return $item->id == $folder_id;
})->first(); })->first();
} }
// By default we display Unassigned folder // By default we display Unassigned folder
if (empty($folder)) { if (empty($folder)) {
$folder = $folders->filter(function($item) { $folder = $folders->filter(function ($item) {
return $item->type == Folder::TYPE_UNASSIGNED; return $item->type == Folder::TYPE_UNASSIGNED;
})->first(); })->first();
} }
@@ -267,9 +272,9 @@ class MailboxesController extends Controller
$this->authorize('view', $folder); $this->authorize('view', $folder);
return view('mailboxes/view', [ return view('mailboxes/view', [
'mailbox' => $mailbox, 'mailbox' => $mailbox,
'folders' => $folders, 'folders' => $folders,
'folder' => $folder, 'folder' => $folder,
'conversations' => $folder->conversations()->orderBy('status', 'asc')->orderBy('last_reply_at', 'desc')->get(), 'conversations' => $folder->conversations()->orderBy('status', 'asc')->orderBy('last_reply_at', 'desc')->get(),
]); ]);
} }
@@ -281,16 +286,16 @@ class MailboxesController extends Controller
if ($mailbox) { if ($mailbox) {
if (Route::currentRouteName() != 'mailboxes.connection' && !$mailbox->isOutActive()) { if (Route::currentRouteName() != 'mailboxes.connection' && !$mailbox->isOutActive()) {
$flashes[] = [ $flashes[] = [
'type' => 'warning', 'type' => 'warning',
'text' => __('Sending emails need to be configured for the mailbox in order to send emails to customers and support agents').' (<a href="'.route('mailboxes.connection', ['id' => $mailbox->id]).'">'.__("Connection Settings » Sending Emails").'</a>)', 'text' => __('Sending emails need to be configured for the mailbox in order to send emails to customers and support agents').' (<a href="'.route('mailboxes.connection', ['id' => $mailbox->id]).'">'.__('Connection Settings » Sending Emails').'</a>)',
'unescaped' => true 'unescaped' => true,
]; ];
} }
if (Route::currentRouteName() != 'mailboxes.connection.incoming' && !$mailbox->isInActive()) { if (Route::currentRouteName() != 'mailboxes.connection.incoming' && !$mailbox->isInActive()) {
$flashes[] = [ $flashes[] = [
'type' => 'warning', 'type' => 'warning',
'text' => __('Receiving emails need to be configured for the mailbox in order to fetch emails from your support email address').' (<a href="'.route('mailboxes.connection.incoming', ['id' => $mailbox->id]).'">'.__("Connection Settings » Receiving Emails").'</a>)', 'text' => __('Receiving emails need to be configured for the mailbox in order to fetch emails from your support email address').' (<a href="'.route('mailboxes.connection.incoming', ['id' => $mailbox->id]).'">'.__('Connection Settings » Receiving Emails').'</a>)',
'unescaped' => true 'unescaped' => true,
]; ];
} }
} }

View File

@@ -2,8 +2,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\ActivityLog; use App\ActivityLog;
use Illuminate\Http\Request;
class SecureController extends Controller class SecureController extends Controller
{ {
@@ -30,16 +30,16 @@ class SecureController extends Controller
} }
/** /**
* Logs * Logs.
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function logs(Request $request) public function logs(Request $request)
{ {
//->where('preferences->dining->meal', 'salad') //->where('preferences->dining->meal', 'salad')
//->get(); //->get();
$names = ActivityLog::select('log_name')->distinct()->get()->pluck('log_name'); $names = ActivityLog::select('log_name')->distinct()->get()->pluck('log_name');
$activities = []; $activities = [];
$cols = []; $cols = [];
$current_name = ''; $current_name = '';
@@ -53,12 +53,12 @@ class SecureController extends Controller
$logs = []; $logs = [];
foreach ($activities as $activity) { foreach ($activities as $activity) {
$log = array( $log = [
'date' => $activity->created_at, 'date' => $activity->created_at,
'user' => $activity->causer, 'user' => $activity->causer,
'event' => $activity->getEventDescription(), 'event' => $activity->getEventDescription(),
); ];
$cols = array('date', 'user', 'event'); $cols = ['date', 'user', 'event'];
foreach ($activity->properties as $property_name => $property_value) { foreach ($activity->properties as $property_name => $property_value) {
if (!is_string($property_value)) { if (!is_string($property_value)) {

View File

@@ -2,11 +2,11 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator;
use Illuminate\Validation\Rule;
use App\User;
use App\Mailbox; use App\Mailbox;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use Validator;
class UsersController extends Controller class UsersController extends Controller
{ {
@@ -21,7 +21,7 @@ class UsersController extends Controller
} }
/** /**
* Users list * Users list.
*/ */
public function users() public function users()
{ {
@@ -31,7 +31,7 @@ class UsersController extends Controller
} }
/** /**
* New user * New user.
*/ */
public function create() public function create()
{ {
@@ -42,20 +42,20 @@ class UsersController extends Controller
} }
/** /**
* Create new mailbox * Create new mailbox.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*/ */
public function createSave(Request $request) public function createSave(Request $request)
{ {
$this->authorize('create', 'App\User'); $this->authorize('create', 'App\User');
$rules = [ $rules = [
'role' => 'integer', 'role' => 'integer',
'first_name' => 'required|string|max:20', 'first_name' => 'required|string|max:20',
'last_name' => 'required|string|max:30', 'last_name' => 'required|string|max:30',
'email' => 'required|string|email|max:100|unique:users', 'email' => 'required|string|email|max:100|unique:users',
'role' => [ 'required', Rule::in(array_keys(User::$roles))] 'role' => ['required', Rule::in(array_keys(User::$roles))],
]; ];
if (empty($request->send_invite)) { if (empty($request->send_invite)) {
$rules['password'] = 'required|string|max:255'; $rules['password'] = 'required|string|max:255';
@@ -68,7 +68,7 @@ class UsersController extends Controller
->withInput(); ->withInput();
} }
$user = new User; $user = new User();
$user->fill($request->all()); $user->fill($request->all());
if (!empty($request->send_invite)) { if (!empty($request->send_invite)) {
@@ -86,11 +86,12 @@ class UsersController extends Controller
} }
\Session::flash('flash_success', __('User created successfully')); \Session::flash('flash_success', __('User created successfully'));
return redirect()->route('users.profile', ['id' => $user->id]); return redirect()->route('users.profile', ['id' => $user->id]);
} }
/** /**
* User profile * User profile.
*/ */
public function profile($id) public function profile($id)
{ {
@@ -106,7 +107,8 @@ class UsersController extends Controller
/** /**
* Handle a registration request for the application. * Handle a registration request for the application.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function profileSave($id, Request $request) public function profileSave($id, Request $request)
@@ -115,15 +117,15 @@ class UsersController extends Controller
$this->authorize('update', $user); $this->authorize('update', $user);
$validator = Validator::make($request->all(), [ $validator = Validator::make($request->all(), [
'first_name' => 'required|string|max:20', 'first_name' => 'required|string|max:20',
'last_name' => 'required|string|max:30', 'last_name' => 'required|string|max:30',
'email' => 'required|string|email|max:100|unique:users,email,'.$id, 'email' => 'required|string|email|max:100|unique:users,email,'.$id,
'emails' => 'max:100', 'emails' => 'max:100',
'job_title' => 'max:100', 'job_title' => 'max:100',
'phone' => 'max:60', 'phone' => 'max:60',
'timezone' => 'required|string|max:255', 'timezone' => 'required|string|max:255',
'time_format' => 'required', 'time_format' => 'required',
'role' => [ 'required', Rule::in(array_keys(User::$roles))] 'role' => ['required', Rule::in(array_keys(User::$roles))],
]); ]);
//event(new Registered($user = $this->create($request->all()))); //event(new Registered($user = $this->create($request->all())));
@@ -143,11 +145,12 @@ class UsersController extends Controller
$user->save(); $user->save();
\Session::flash('flash_success', __('Profile saved successfully')); \Session::flash('flash_success', __('Profile saved successfully'));
return redirect()->route('users.profile', ['id' => $id]); return redirect()->route('users.profile', ['id' => $id]);
} }
/** /**
* User mailboxes * User mailboxes.
*/ */
public function permissions($id) public function permissions($id)
{ {
@@ -160,10 +163,10 @@ class UsersController extends Controller
} }
/** /**
* Save user permissions * Save user permissions.
* *
* @param int $id * @param int $id
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*/ */
public function permissionsSave($id, Request $request) public function permissionsSave($id, Request $request)
{ {
@@ -174,6 +177,7 @@ class UsersController extends Controller
$user->syncPersonalFolders($request->mailboxes); $user->syncPersonalFolders($request->mailboxes);
\Session::flash('flash_success', __('Permissions saved successfully')); \Session::flash('flash_success', __('Permissions saved successfully'));
return redirect()->route('users.permissions', ['id' => $id]); return redirect()->route('users.permissions', ['id' => $id]);
} }
} }

View File

@@ -51,11 +51,11 @@ class Kernel extends HttpKernel
* @var array * @var array
*/ */
protected $routeMiddleware = [ protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class, 'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
]; ];
} }

View File

@@ -10,9 +10,10 @@ class RedirectIfAuthenticated
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @param string|null $guard * @param string|null $guard
*
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next, $guard = null) public function handle($request, Closure $next, $guard = null)

View File

@@ -2,8 +2,8 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware; use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware class TrustProxies extends Middleware
{ {
@@ -20,10 +20,10 @@ class TrustProxies extends Middleware
* @var array * @var array
*/ */
protected $headers = [ protected $headers = [
Request::HEADER_FORWARDED => 'FORWARDED', Request::HEADER_FORWARDED => 'FORWARDED',
Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR', Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST', Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT', Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO', Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
]; ];
} }

View File

@@ -3,8 +3,6 @@
namespace App\Listeners; namespace App\Listeners;
use Illuminate\Auth\Events\Failed; use Illuminate\Auth\Events\Failed;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class LogFailedLogin class LogFailedLogin
{ {
@@ -21,7 +19,8 @@ class LogFailedLogin
/** /**
* Handle the event. * Handle the event.
* *
* @param Failed $event * @param Failed $event
*
* @return void * @return void
*/ */
public function handle(Failed $event) public function handle(Failed $event)

View File

@@ -3,8 +3,6 @@
namespace App\Listeners; namespace App\Listeners;
use Illuminate\Auth\Events\Lockout; use Illuminate\Auth\Events\Lockout;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class LogLockout class LogLockout
{ {
@@ -21,7 +19,8 @@ class LogLockout
/** /**
* Handle the event. * Handle the event.
* *
* @param Lockout $event * @param Lockout $event
*
* @return void * @return void
*/ */
public function handle(Lockout $event) public function handle(Lockout $event)

View File

@@ -3,8 +3,6 @@
namespace App\Listeners; namespace App\Listeners;
use Illuminate\Auth\Events\PasswordReset; use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class LogPasswordReset class LogPasswordReset
{ {
@@ -21,7 +19,8 @@ class LogPasswordReset
/** /**
* Handle the event. * Handle the event.
* *
* @param PasswordReset $event * @param PasswordReset $event
*
* @return void * @return void
*/ */
public function handle(PasswordReset $event) public function handle(PasswordReset $event)

View File

@@ -3,8 +3,6 @@
namespace App\Listeners; namespace App\Listeners;
use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Events\Registered;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class LogRegisteredUser class LogRegisteredUser
{ {
@@ -21,7 +19,8 @@ class LogRegisteredUser
/** /**
* Handle the event. * Handle the event.
* *
* @param Registered $event * @param Registered $event
*
* @return void * @return void
*/ */
public function handle(Registered $event) public function handle(Registered $event)

View File

@@ -3,8 +3,6 @@
namespace App\Listeners; namespace App\Listeners;
use Illuminate\Auth\Events\Login; use Illuminate\Auth\Events\Login;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class LogSuccessfulLogin class LogSuccessfulLogin
{ {
@@ -21,7 +19,8 @@ class LogSuccessfulLogin
/** /**
* Handle the event. * Handle the event.
* *
* @param Login $event * @param Login $event
*
* @return void * @return void
*/ */
public function handle(Login $event) public function handle(Login $event)

View File

@@ -3,8 +3,6 @@
namespace App\Listeners; namespace App\Listeners;
use Illuminate\Auth\Events\Logout; use Illuminate\Auth\Events\Logout;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class LogSuccessfulLogout class LogSuccessfulLogout
{ {
@@ -21,7 +19,8 @@ class LogSuccessfulLogout
/** /**
* Handle the event. * Handle the event.
* *
* @param Logout $event * @param Logout $event
*
* @return void * @return void
*/ */
public function handle(Logout $event) public function handle(Logout $event)

View File

@@ -7,10 +7,9 @@ use Illuminate\Support\Facades\Hash;
class Mailbox extends Model class Mailbox extends Model
{ {
/**
/** * From Name: name that will appear in the From field when a customer views your email.
* From Name: name that will appear in the From field when a customer views your email. */
*/
const FROM_NAME_MAILBOX = 1; const FROM_NAME_MAILBOX = 1;
const FROM_NAME_USER = 2; const FROM_NAME_USER = 2;
const FROM_NAME_CUSTOM = 3; const FROM_NAME_CUSTOM = 3;
@@ -23,29 +22,29 @@ class Mailbox extends Model
const TICKET_STATUS_CLOSED = 3; const TICKET_STATUS_CLOSED = 3;
/** /**
* Default Assignee * Default Assignee.
*/ */
const TICKET_ASSIGNEE_ANYONE = 1; const TICKET_ASSIGNEE_ANYONE = 1;
const TICKET_ASSIGNEE_REPLYING_UNASSIGNED = 2; const TICKET_ASSIGNEE_REPLYING_UNASSIGNED = 2;
const TICKET_ASSIGNEE_REPLYING = 3; const TICKET_ASSIGNEE_REPLYING = 3;
/** /**
* Email Template * Email Template.
*/ */
const TEMPLATE_FANCY = 1; const TEMPLATE_FANCY = 1;
const TEMPLATE_PLAIN = 2; const TEMPLATE_PLAIN = 2;
/** /**
* Sending Emails * Sending Emails.
*/ */
const OUT_METHOD_PHP_MAIL = 1; const OUT_METHOD_PHP_MAIL = 1;
const OUT_METHOD_SENDMAIL = 2; const OUT_METHOD_SENDMAIL = 2;
const OUT_METHOD_SMTP = 3; const OUT_METHOD_SMTP = 3;
//const OUT_METHOD_GMAIL = 3; // todo //const OUT_METHOD_GMAIL = 3; // todo
// todo: mailgun, sendgrid, mandrill, etc // todo: mailgun, sendgrid, mandrill, etc
/** /**
* Secure Connection * Secure Connection.
*/ */
const OUT_SSL_NONE = 1; const OUT_SSL_NONE = 1;
const OUT_SSL_SSL = 2; const OUT_SSL_SSL = 2;
@@ -58,23 +57,23 @@ class Mailbox extends Model
const RATINGS_PLACEMENT_BELOW = 2; const RATINGS_PLACEMENT_BELOW = 2;
/** /**
* Attributes fillable using fill() method * Attributes fillable using fill() method.
*
* @var [type] * @var [type]
*/ */
protected $fillable = ['name', 'slug', 'email', 'aliases', 'from_name', 'from_name_custom', 'ticket_status', 'ticket_assignee', 'template', 'signature', 'out_method', 'out_server', 'out_username', 'out_password', 'out_port', 'out_ssl', 'in_server', 'in_port', 'in_username', 'in_password', 'auto_reply_enabled', 'auto_reply_subject', 'auto_reply_message', 'office_hours_enabled', 'ratings', 'ratings_placement', 'ratings_text']; protected $fillable = ['name', 'slug', 'email', 'aliases', 'from_name', 'from_name_custom', 'ticket_status', 'ticket_assignee', 'template', 'signature', 'out_method', 'out_server', 'out_username', 'out_password', 'out_port', 'out_ssl', 'in_server', 'in_port', 'in_username', 'in_password', 'auto_reply_enabled', 'auto_reply_subject', 'auto_reply_message', 'office_hours_enabled', 'ratings', 'ratings_placement', 'ratings_text'];
protected static function boot() protected static function boot()
{ {
parent::boot(); parent::boot();
self::created(function (Mailbox $model) self::created(function (Mailbox $model) {
{
$model->slug = strtolower(substr(md5(Hash::make($model->id)), 0, 16)); $model->slug = strtolower(substr(md5(Hash::make($model->id)), 0, 16));
}); });
} }
/** /**
* Get users having access to the mailbox * Get users having access to the mailbox.
*/ */
public function users() public function users()
{ {
@@ -82,7 +81,7 @@ class Mailbox extends Model
} }
/** /**
* Get mailbox conversations * Get mailbox conversations.
*/ */
public function conversations() public function conversations()
{ {
@@ -90,7 +89,7 @@ class Mailbox extends Model
} }
/** /**
* Get mailbox folders * Get mailbox folders.
*/ */
public function folders() public function folders()
{ {
@@ -99,8 +98,8 @@ class Mailbox extends Model
/** /**
* Create personal folders for users. * Create personal folders for users.
* *
* @param mixed $users * @param mixed $users
*/ */
public function syncPersonalFolders($users) public function syncPersonalFolders($users)
{ {
@@ -130,7 +129,7 @@ class Mailbox extends Model
continue; continue;
} }
foreach (Folder::$personal_types as $type) { foreach (Folder::$personal_types as $type) {
$folder = new Folder; $folder = new Folder();
$folder->mailbox_id = $this->id; $folder->mailbox_id = $this->id;
$folder->user_id = $user_id; $folder->user_id = $user_id;
$folder->type = $type; $folder->type = $type;
@@ -155,7 +154,7 @@ class Mailbox extends Model
continue; continue;
} }
foreach (Folder::$personal_types as $type) { foreach (Folder::$personal_types as $type) {
$folder = new Folder; $folder = new Folder();
$folder->mailbox_id = $this->id; $folder->mailbox_id = $this->id;
$folder->user_id = $user_id; $folder->user_id = $user_id;
$folder->type = $type; $folder->type = $type;
@@ -205,11 +204,10 @@ class Mailbox extends Model
{ {
$folders = $this->folders; $folders = $this->folders;
foreach ($folders as $folder) { foreach ($folders as $folder) {
$folder->active_count = $folder->conversations() $folder->active_count = $folder->conversations()
->where('status', Conversation::STATUS_ACTIVE) ->where('status', Conversation::STATUS_ACTIVE)
->count(); ->count();
$folder->total_count = $folder->conversations()->count(); $folder->total_count = $folder->conversations()->count();
$folder->save(); $folder->save();
@@ -218,18 +216,18 @@ class Mailbox extends Model
/** /**
* Is mailbox available for using. * Is mailbox available for using.
* *
* @return boolean * @return bool
*/ */
public function isActive() public function isActive()
{ {
return ($this->isInActive() && $this->isOutActive()); return $this->isInActive() && $this->isOutActive();
} }
/** /**
* Is receiving emails configured for the mailbox. * Is receiving emails configured for the mailbox.
* *
* @return boolean * @return bool
*/ */
public function isInActive() public function isInActive()
{ {
@@ -242,8 +240,8 @@ class Mailbox extends Model
/** /**
* Is sending emails configured for the mailbox. * Is sending emails configured for the mailbox.
* *
* @return boolean * @return bool
*/ */
public function isOutActive() public function isOutActive()
{ {

View File

@@ -6,5 +6,5 @@ use Illuminate\Database\Eloquent\Model;
class MailboxUser extends Model class MailboxUser extends Model
{ {
protected $table = 'mailbox_user'; protected $table = 'mailbox_user';
} }

View File

@@ -8,8 +8,8 @@ class ConversationObserver
{ {
/** /**
* On create. * On create.
* *
* @param Conversation $conversation * @param Conversation $conversation
*/ */
public function created(Conversation $conversation) public function created(Conversation $conversation)
{ {
@@ -18,11 +18,11 @@ class ConversationObserver
/** /**
* On conversation delete. * On conversation delete.
* *
* @param Conversation $conversation * @param Conversation $conversation
*/ */
public function deleting(Conversation $conversation) public function deleting(Conversation $conversation)
{ {
$conversation->threads()->delete(); $conversation->threads()->delete();
} }
} }

View File

@@ -2,22 +2,22 @@
namespace App\Observers; namespace App\Observers;
use App\Mailbox;
use App\Folder; use App\Folder;
use App\Conversation; use App\Mailbox;
class MailboxObserver class MailboxObserver
{ {
/** /**
* Listen to the Mailbox created event. * Listen to the Mailbox created event.
* *
* @param \App\Mailbox $mailbox * @param \App\Mailbox $mailbox
*
* @return void * @return void
*/ */
public function created(Mailbox $mailbox) public function created(Mailbox $mailbox)
{ {
foreach (Folder::$public_types as $type) { foreach (Folder::$public_types as $type) {
$folder = new Folder; $folder = new Folder();
$folder->mailbox_id = $mailbox->id; $folder->mailbox_id = $mailbox->id;
$folder->type = $type; $folder->type = $type;
$folder->save(); $folder->save();
@@ -29,10 +29,11 @@ class MailboxObserver
* Delete the following on mailbox delete: * Delete the following on mailbox delete:
* - folders * - folders
* - conversations * - conversations
* - user permissions * - user permissions.
* *
* @param Mailbox $mailbox * @param Mailbox $mailbox
* @return [type] [description] *
* @return [type] [description]
*/ */
public function deleting(Mailbox $mailbox) public function deleting(Mailbox $mailbox)
{ {
@@ -40,4 +41,4 @@ class MailboxObserver
$mailbox->conversations()->delete(); $mailbox->conversations()->delete();
$mailbox->folders()->delete(); $mailbox->folders()->delete();
} }
} }

View File

@@ -8,15 +8,15 @@ class ThreadObserver
{ {
/** /**
* Thread created. * Thread created.
* *
* @param Thread $thread * @param Thread $thread
*/ */
public function created(Thread $thread) public function created(Thread $thread)
{ {
// Update data in conversation // Update data in conversation
$conversation = $thread->conversation; $conversation = $thread->conversation;
$now = date("Y-m-d H:i:s"); $now = date('Y-m-d H:i:s');
if (!in_array($thread->type, [Thread::TYPE_LINEITEM, Thread::TYPE_NOTE])) { if (!in_array($thread->type, [Thread::TYPE_LINEITEM, Thread::TYPE_NOTE])) {
$conversation->threads_count++; $conversation->threads_count++;
} }
@@ -26,5 +26,4 @@ class ThreadObserver
$conversation->last_reply_at = $now; $conversation->last_reply_at = $now;
$conversation->save(); $conversation->save();
} }
}
}

View File

@@ -8,12 +8,13 @@ class UserObserver
{ {
/** /**
* On user delete. * On user delete.
* *
* @param Conversation $mailbox * @param Conversation $mailbox
* @return [type] [description] *
* @return [type] [description]
*/ */
public function deleting(User $user) public function deleting(User $user)
{ {
$user->folders()->delete(); $user->folders()->delete();
} }
} }

View File

@@ -2,8 +2,8 @@
namespace App\Policies; namespace App\Policies;
use App\User;
use App\Conversation; use App\Conversation;
use App\User;
use Illuminate\Auth\Access\HandlesAuthorization; use Illuminate\Auth\Access\HandlesAuthorization;
class ConversationPolicy class ConversationPolicy
@@ -13,8 +13,9 @@ class ConversationPolicy
/** /**
* Determine whether the user can view the conversation. * Determine whether the user can view the conversation.
* *
* @param \App\User $user * @param \App\User $user
* @param \App\Conversation $conversation * @param \App\Conversation $conversation
*
* @return bool * @return bool
*/ */
public function view(User $user, Conversation $conversation) public function view(User $user, Conversation $conversation)

View File

@@ -2,8 +2,8 @@
namespace App\Policies; namespace App\Policies;
use App\User;
use App\Folder; use App\Folder;
use App\User;
use Illuminate\Auth\Access\HandlesAuthorization; use Illuminate\Auth\Access\HandlesAuthorization;
class FolderPolicy class FolderPolicy
@@ -13,8 +13,9 @@ class FolderPolicy
/** /**
* Determine whether the user can view the folder. * Determine whether the user can view the folder.
* *
* @param \App\User $user * @param \App\User $user
* @param \App\Folder $folder * @param \App\Folder $folder
*
* @return bool * @return bool
*/ */
public function view(User $user, Folder $folder) public function view(User $user, Folder $folder)

View File

@@ -2,8 +2,8 @@
namespace App\Policies; namespace App\Policies;
use App\User;
use App\Mailbox; use App\Mailbox;
use App\User;
use Illuminate\Auth\Access\HandlesAuthorization; use Illuminate\Auth\Access\HandlesAuthorization;
class MailboxPolicy class MailboxPolicy
@@ -13,7 +13,8 @@ class MailboxPolicy
/** /**
* Determine whether the user can create mailboxes. * Determine whether the user can create mailboxes.
* *
* @param \App\User $user * @param \App\User $user
*
* @return mixed * @return mixed
*/ */
public function create(User $user) public function create(User $user)
@@ -28,8 +29,9 @@ class MailboxPolicy
/** /**
* Determine whether the user can update the mailbox. * Determine whether the user can update the mailbox.
* *
* @param \App\User $user * @param \App\User $user
* @param \App\Mailbox $mailbox * @param \App\Mailbox $mailbox
*
* @return mixed * @return mixed
*/ */
public function update(User $user, Mailbox $mailbox) public function update(User $user, Mailbox $mailbox)
@@ -44,8 +46,9 @@ class MailboxPolicy
/** /**
* Determine whether the user can delete the mailbox. * Determine whether the user can delete the mailbox.
* *
* @param \App\User $user * @param \App\User $user
* @param \App\Mailbox $mailbox * @param \App\Mailbox $mailbox
*
* @return mixed * @return mixed
*/ */
public function delete(User $user, Mailbox $mailbox) public function delete(User $user, Mailbox $mailbox)

View File

@@ -12,8 +12,9 @@ class UserPolicy
/** /**
* Determine whether the user can view the model. * Determine whether the user can view the model.
* *
* @param \App\User $user * @param \App\User $user
* @param \App\User $model * @param \App\User $model
*
* @return mixed * @return mixed
*/ */
public function view(User $user, User $model) public function view(User $user, User $model)
@@ -28,7 +29,8 @@ class UserPolicy
/** /**
* Determine whether the user can create models. * Determine whether the user can create models.
* *
* @param \App\User $user * @param \App\User $user
*
* @return mixed * @return mixed
*/ */
public function create(User $user) public function create(User $user)
@@ -43,8 +45,9 @@ class UserPolicy
/** /**
* Determine whether the user can update the model. * Determine whether the user can update the model.
* *
* @param \App\User $user * @param \App\User $user
* @param \App\User $model * @param \App\User $model
*
* @return mixed * @return mixed
*/ */
public function update(User $user, User $model) public function update(User $user, User $model)
@@ -59,8 +62,9 @@ class UserPolicy
/** /**
* Determine whether the user can delete the model. * Determine whether the user can delete the model.
* *
* @param \App\User $user * @param \App\User $user
* @param \App\User $model * @param \App\User $model
*
* @return mixed * @return mixed
*/ */
public function delete(User $user, User $model) public function delete(User $user, User $model)

View File

@@ -2,8 +2,8 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider class AppServiceProvider extends ServiceProvider
{ {

View File

@@ -2,7 +2,6 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider class AuthServiceProvider extends ServiceProvider
@@ -13,9 +12,9 @@ class AuthServiceProvider extends ServiceProvider
* @var array * @var array
*/ */
protected $policies = [ protected $policies = [
'App\User' => 'App\Policies\UserPolicy', 'App\User' => 'App\Policies\UserPolicy',
'App\Mailbox' => 'App\Policies\MailboxPolicy', 'App\Mailbox' => 'App\Policies\MailboxPolicy',
'App\Folder' => 'App\Policies\FolderPolicy', 'App\Folder' => 'App\Policies\FolderPolicy',
'App\Conversation' => 'App\Policies\ConversationPolicy', 'App\Conversation' => 'App\Policies\ConversationPolicy',
]; ];

View File

@@ -2,8 +2,8 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Broadcast; use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider class BroadcastServiceProvider extends ServiceProvider
{ {

View File

@@ -2,8 +2,8 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider class EventServiceProvider extends ServiceProvider
{ {
@@ -16,7 +16,7 @@ class EventServiceProvider extends ServiceProvider
'Illuminate\Auth\Events\Registered' => [ 'Illuminate\Auth\Events\Registered' => [
'App\Listeners\LogRegisteredUser', 'App\Listeners\LogRegisteredUser',
], ],
'Illuminate\Auth\Events\Login' => [ 'Illuminate\Auth\Events\Login' => [
'App\Listeners\LogSuccessfulLogin', 'App\Listeners\LogSuccessfulLogin',
], ],

View File

@@ -2,8 +2,8 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider class RouteServiceProvider extends ServiceProvider
{ {

View File

@@ -7,18 +7,18 @@ use Illuminate\Database\Eloquent\Model;
class Thread extends Model class Thread extends Model
{ {
/** /**
* By whom action performed (source_via) * By whom action performed (source_via).
*/ */
const PERSON_CUSTOMER = 1; const PERSON_CUSTOMER = 1;
const PERSON_USER = 2; const PERSON_USER = 2;
public static $persons = array( public static $persons = [
self::PERSON_CUSTOMER => 'customer', self::PERSON_CUSTOMER => 'customer',
self::PERSON_USER => 'user', self::PERSON_USER => 'user',
); ];
/** /**
* Thread types * Thread types.
*/ */
// Email from customer // Email from customer
const TYPE_CUSTOMER = 1; const TYPE_CUSTOMER = 1;
@@ -35,23 +35,23 @@ class Thread extends Model
public static $types = [ public static $types = [
// Thread by customer // Thread by customer
self::TYPE_CUSTOMER => 'customer', self::TYPE_CUSTOMER => 'customer',
// Thread by user // Thread by user
self::TYPE_MESSAGE => 'message', self::TYPE_MESSAGE => 'message',
self::TYPE_NOTE => 'note', self::TYPE_NOTE => 'note',
// lineitem represents a change of state on the conversation. This could include, but not limited to, the conversation was assigned, the status changed, the conversation was moved from one mailbox to another, etc. A line item won’t have a body, to/cc/bcc lists, or attachments. // lineitem represents a change of state on the conversation. This could include, but not limited to, the conversation was assigned, the status changed, the conversation was moved from one mailbox to another, etc. A line item won’t have a body, to/cc/bcc lists, or attachments.
self::TYPE_LINEITEM => 'lineitem', self::TYPE_LINEITEM => 'lineitem',
self::TYPE_PHONE => 'phone', self::TYPE_PHONE => 'phone',
// When a conversation is forwarded, a new conversation is created to represent the forwarded conversation. // When a conversation is forwarded, a new conversation is created to represent the forwarded conversation.
// forwardparent is the type set on the thread of the original conversation that initiated the forward event. // forwardparent is the type set on the thread of the original conversation that initiated the forward event.
self::TYPE_FORWARDPARENT => 'forwardparent', self::TYPE_FORWARDPARENT => 'forwardparent',
// forwardchild is the type set on the first thread of the new forwarded conversation. // forwardchild is the type set on the first thread of the new forwarded conversation.
self::TYPE_FORWARDCHILD => 'forwardchild', self::TYPE_FORWARDCHILD => 'forwardchild',
self::TYPE_CHAT => 'chat', self::TYPE_CHAT => 'chat',
]; ];
/** /**
* Statuses * Statuses.
*/ */
const STATUS_ACTIVE = 1; const STATUS_ACTIVE = 1;
const STATUS_CLOSED = 2; const STATUS_CLOSED = 2;
@@ -59,31 +59,31 @@ class Thread extends Model
const STATUS_PENDING = 4; const STATUS_PENDING = 4;
const STATUS_SPAM = 5; const STATUS_SPAM = 5;
public static $statuses = array( public static $statuses = [
self::STATUS_ACTIVE => 'active', self::STATUS_ACTIVE => 'active',
self::STATUS_CLOSED => 'closed', self::STATUS_CLOSED => 'closed',
self::STATUS_NOCHANGE => 'nochange', self::STATUS_NOCHANGE => 'nochange',
self::STATUS_PENDING => 'pending', self::STATUS_PENDING => 'pending',
self::STATUS_SPAM => 'spam', self::STATUS_SPAM => 'spam',
); ];
/** /**
* States * States.
*/ */
const STATE_DRAFT = 1; const STATE_DRAFT = 1;
const STATE_PUBLISHED = 2; const STATE_PUBLISHED = 2;
const STATE_HIDDEN = 3; const STATE_HIDDEN = 3;
const STATE_REVIEW = 4; const STATE_REVIEW = 4;
public static $states = array( public static $states = [
self::STATE_DRAFT => 'draft', self::STATE_DRAFT => 'draft',
self::STATE_PUBLISHED => 'published', self::STATE_PUBLISHED => 'published',
self::STATE_HIDDEN => 'hidden', self::STATE_HIDDEN => 'hidden',
self::STATE_REVIEW => 'review', self::STATE_REVIEW => 'review',
); ];
/** /**
* Action associated with the line item * Action associated with the line item.
*/ */
// The conversation was moved from another mailbox // The conversation was moved from another mailbox
const ACTION_TYPE_MOVED_FROM_MAILBOX = 1; const ACTION_TYPE_MOVED_FROM_MAILBOX = 1;
@@ -106,32 +106,32 @@ class Thread extends Model
// Describes an optional action associated with the line item // Describes an optional action associated with the line item
// todo: values need to be checked via HelpScout API // todo: values need to be checked via HelpScout API
public static $action_types = [ public static $action_types = [
self::ACTION_TYPE_MOVED_FROM_MAILBOX => 'moved-from-mailbox', self::ACTION_TYPE_MOVED_FROM_MAILBOX => 'moved-from-mailbox',
self::ACTION_TYPE_MERGED => 'merged', self::ACTION_TYPE_MERGED => 'merged',
self::ACTION_TYPE_IMPORTED => 'imported', self::ACTION_TYPE_IMPORTED => 'imported',
self::ACTION_TYPE_WORKFLOW_MANUAL => 'manual-workflow', self::ACTION_TYPE_WORKFLOW_MANUAL => 'manual-workflow',
self::ACTION_TYPE_WORKFLOW_AUTO => 'automatic-workflow', self::ACTION_TYPE_WORKFLOW_AUTO => 'automatic-workflow',
self::ACTION_TYPE_IMPORTED_EXTERNAL => 'imported-external', self::ACTION_TYPE_IMPORTED_EXTERNAL => 'imported-external',
self::ACTION_TYPE_CHANGED_TICKET_CUSTOMER => 'changed-ticket-customer', self::ACTION_TYPE_CHANGED_TICKET_CUSTOMER => 'changed-ticket-customer',
self::ACTION_TYPE_DELETED_TICKET => 'deleted-ticket', self::ACTION_TYPE_DELETED_TICKET => 'deleted-ticket',
self::ACTION_TYPE_RESTORE_TICKET => 'restore-ticket', self::ACTION_TYPE_RESTORE_TICKET => 'restore-ticket',
]; ];
/** /**
* Source types (equal to thread source types) * Source types (equal to thread source types).
*/ */
const SOURCE_TYPE_EMAIL = 1; const SOURCE_TYPE_EMAIL = 1;
const SOURCE_TYPE_WEB = 2; const SOURCE_TYPE_WEB = 2;
const SOURCE_TYPE_API = 3; const SOURCE_TYPE_API = 3;
public static $source_types = [ public static $source_types = [
self::SOURCE_TYPE_EMAIL => 'email', self::SOURCE_TYPE_EMAIL => 'email',
self::SOURCE_TYPE_WEB => 'web', self::SOURCE_TYPE_WEB => 'web',
self::SOURCE_TYPE_API => 'api', self::SOURCE_TYPE_API => 'api',
]; ];
/** /**
* Status of the email sent to the customer or user, to whom the thread is assigned * Status of the email sent to the customer or user, to whom the thread is assigned.
*/ */
const SEND_STATUS_TOSEND = 1; const SEND_STATUS_TOSEND = 1;
const SEND_STATUS_SENT = 2; const SEND_STATUS_SENT = 2;
@@ -139,7 +139,7 @@ class Thread extends Model
const SEND_STATUS_DELIVERY_ERROR = 4; const SEND_STATUS_DELIVERY_ERROR = 4;
/** /**
* The user assigned to this thread (assignedTo) * The user assigned to this thread (assignedTo).
*/ */
public function user() public function user()
{ {
@@ -147,7 +147,7 @@ class Thread extends Model
} }
/** /**
* Get the thread customer * Get the thread customer.
*/ */
public function customer() public function customer()
{ {
@@ -155,7 +155,7 @@ class Thread extends Model
} }
/** /**
* Get conversation * Get conversation.
*/ */
public function conversation() public function conversation()
{ {
@@ -163,7 +163,8 @@ class Thread extends Model
} }
/** /**
* Get sanitized body HTML * Get sanitized body HTML.
*
* @return string * @return string
*/ */
public function getCleanBody() public function getCleanBody()
@@ -173,7 +174,7 @@ class Thread extends Model
/** /**
* Get thread recipients. * Get thread recipients.
* *
* @return array * @return array
*/ */
public function getTos() public function getTos()
@@ -187,7 +188,7 @@ class Thread extends Model
/** /**
* Get thread CC recipients. * Get thread CC recipients.
* *
* @return array * @return array
*/ */
public function getCcs() public function getCcs()
@@ -201,7 +202,7 @@ class Thread extends Model
/** /**
* Get thread BCC recipients. * Get thread BCC recipients.
* *
* @return array * @return array
*/ */
public function getBccs() public function getBccs()
@@ -215,31 +216,32 @@ class Thread extends Model
/** /**
* Get status name. Made as a function to allow status names translation. * Get status name. Made as a function to allow status names translation.
* *
* @param integer $status * @param int $status
* @return string *
* @return string
*/ */
public static function getStatusName($status) public static function getStatusName($status)
{ {
switch ($status) { switch ($status) {
case self::STATUS_ACTIVE: case self::STATUS_ACTIVE:
return __("Active"); return __('Active');
break; break;
case self::STATUS_PENDING: case self::STATUS_PENDING:
return __("Pending"); return __('Pending');
break; break;
case self::STATUS_CLOSED: case self::STATUS_CLOSED:
return __("Closed"); return __('Closed');
break; break;
case self::STATUS_SPAM: case self::STATUS_SPAM:
return __("Spam"); return __('Spam');
break; break;
case self::STATUS_NOCHANGE: case self::STATUS_NOCHANGE:
return __("Not changed"); return __('Not changed');
break; break;
default: default:

View File

@@ -3,13 +3,13 @@
* User model class. * User model class.
* Class also responsible for dates conversion and representation. * Class also responsible for dates conversion and representation.
*/ */
namespace App; namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Support\Facades\Hash;
use App\Mailbox;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Hash;
class User extends Authenticatable class User extends Authenticatable
{ {
@@ -19,41 +19,41 @@ class User extends Authenticatable
// const UPDATED_AT = 'modified_at'; // const UPDATED_AT = 'modified_at';
/** /**
* Roles * Roles.
*/ */
const ROLE_USER = 1; const ROLE_USER = 1;
const ROLE_ADMIN = 2; const ROLE_ADMIN = 2;
public static $roles = array( public static $roles = [
self::ROLE_ADMIN => 'admin', self::ROLE_ADMIN => 'admin',
self::ROLE_USER => 'user' self::ROLE_USER => 'user',
); ];
/** /**
* Types * Types.
*/ */
const TYPE_USER = 1; const TYPE_USER = 1;
const TYPE_TEAM = 2; const TYPE_TEAM = 2;
/** /**
* Invite states * Invite states.
*/ */
const INVITE_STATE_ACTIVATED = 0; const INVITE_STATE_ACTIVATED = 0;
const INVITE_STATE_NOT_INVITED = 1; const INVITE_STATE_NOT_INVITED = 1;
const INVITE_STATE_SENT = 2; const INVITE_STATE_SENT = 2;
/** /**
* Time formats * Time formats.
*/ */
const TIME_FORMAT_12 = 1; const TIME_FORMAT_12 = 1;
const TIME_FORMAT_24 = 2; const TIME_FORMAT_24 = 2;
/** /**
* The attributes that are not mass assignable. * The attributes that are not mass assignable.
* *
* @var array * @var array
*/ */
protected $guarded = ['role']; protected $guarded = ['role'];
/** /**
* The attributes that should be hidden for arrays, excluded from the model's JSON form. * The attributes that should be hidden for arrays, excluded from the model's JSON form.
@@ -65,13 +65,14 @@ class User extends Authenticatable
]; ];
/** /**
* Attributes fillable using fill() method * Attributes fillable using fill() method.
*
* @var [type] * @var [type]
*/ */
protected $fillable = ['role', 'first_name', 'last_name', 'email', 'password', 'role', 'timezone', 'photo_url', 'type', 'emails', 'job_title', 'phone', 'time_format', 'enable_kb_shortcuts']; protected $fillable = ['role', 'first_name', 'last_name', 'email', 'password', 'role', 'timezone', 'photo_url', 'type', 'emails', 'job_title', 'phone', 'time_format', 'enable_kb_shortcuts'];
/** /**
* Get mailboxes to which usre has access * Get mailboxes to which usre has access.
*/ */
public function mailboxes() public function mailboxes()
{ {
@@ -79,7 +80,7 @@ class User extends Authenticatable
} }
/** /**
* Get conversations assigned to user * Get conversations assigned to user.
*/ */
public function conversations() public function conversations()
{ {
@@ -87,7 +88,7 @@ class User extends Authenticatable
} }
/** /**
* User's folders * User's folders.
*/ */
public function folders() public function folders()
{ {
@@ -95,8 +96,8 @@ class User extends Authenticatable
} }
/** /**
* Get user role * Get user role.
* *
* @return string * @return string
*/ */
public function getRoleName($ucfirst = false) public function getRoleName($ucfirst = false)
@@ -105,30 +106,32 @@ class User extends Authenticatable
if ($ucfirst) { if ($ucfirst) {
$role_name = ucfirst($role_name); $role_name = ucfirst($role_name);
} }
return $role_name; return $role_name;
} }
/** /**
* Check if user is admin * Check if user is admin.
* *
* @return boolean * @return bool
*/ */
public function isAdmin() public function isAdmin()
{ {
return ($this->role == self::ROLE_ADMIN); return $this->role == self::ROLE_ADMIN;
} }
/** /**
* Get user full name * Get user full name.
*
* @return string * @return string
*/ */
public function getFullName() public function getFullName()
{ {
return $this->first_name . ' ' . $this->last_name; return $this->first_name.' '.$this->last_name;
} }
/** /**
* Get mailboxes to which user has access * Get mailboxes to which user has access.
*/ */
public function mailboxesCanView() public function mailboxesCanView()
{ {
@@ -140,18 +143,22 @@ class User extends Authenticatable
} }
/** /**
* Generate random password for the user * Generate random password for the user.
* @param integer $length *
* @param int $length
*
* @return string * @return string
*/ */
public function generatePassword($length = 8) public function generatePassword($length = 8)
{ {
$this->password = Hash::make(str_random($length)); $this->password = Hash::make(str_random($length));
return $this->password; return $this->password;
} }
/** /**
* Get URL for editing user * Get URL for editing user.
*
* @return string * @return string
*/ */
public function urlEdit() public function urlEdit()
@@ -161,9 +168,9 @@ class User extends Authenticatable
/** /**
* Create personal folders for user mailboxes. * Create personal folders for user mailboxes.
* *
* @param integer $mailbox_id * @param int $mailbox_id
* @param mixed $users * @param mixed $users
*/ */
public function syncPersonalFolders($mailboxes) public function syncPersonalFolders($mailboxes)
{ {
@@ -185,7 +192,7 @@ class User extends Authenticatable
continue; continue;
} }
foreach (Folder::$personal_types as $type) { foreach (Folder::$personal_types as $type) {
$folder = new Folder; $folder = new Folder();
$folder->mailbox_id = $mailbox_id; $folder->mailbox_id = $mailbox_id;
$folder->user_id = $this->id; $folder->user_id = $this->id;
$folder->type = $type; $folder->type = $type;
@@ -196,10 +203,11 @@ class User extends Authenticatable
/** /**
* Format date according to user's timezone and time format. * Format date according to user's timezone and time format.
* *
* @param Carbon $date * @param Carbon $date
* @param string $format * @param string $format
* @return string *
* @return string
*/ */
public static function dateFormat($date, $format) public static function dateFormat($date, $format)
{ {
@@ -207,16 +215,16 @@ class User extends Authenticatable
if ($user) { if ($user) {
if ($user->time_format == self::TIME_FORMAT_12) { if ($user->time_format == self::TIME_FORMAT_12) {
$format = strtr($format, [ $format = strtr($format, [
'H' => 'h', 'H' => 'h',
'G' => 'g', 'G' => 'g',
':i' => ':ia', ':i' => ':ia',
':ia:s' => ':i:sa', ':ia:s' => ':i:sa',
]); ]);
} else { } else {
$format = strtr($format, [ $format = strtr($format, [
'h' => 'H', 'h' => 'H',
'g' => 'G', 'g' => 'G',
':ia' => ':i', ':ia' => ':i',
':i:sa' => ':i:s', ':i:sa' => ':i:s',
]); ]);
} }
@@ -230,8 +238,9 @@ class User extends Authenticatable
/** /**
* Convert date into human readable format. * Convert date into human readable format.
* *
* @param Carbon $date * @param Carbon $date
*
* @return string * @return string
*/ */
public static function dateDiffForHumans($date) public static function dateDiffForHumans($date)
@@ -242,17 +251,18 @@ class User extends Authenticatable
} }
if ($date->diffInSeconds(Carbon::now()) <= 60) { if ($date->diffInSeconds(Carbon::now()) <= 60) {
return __("Just now"); return __('Just now');
} elseif ($date->diffInDays(Carbon::now()) > 7) { } elseif ($date->diffInDays(Carbon::now()) > 7) {
// Exact date // Exact date
if (Carbon::now()->year == $date->year) { if (Carbon::now()->year == $date->year) {
return User::dateFormat($date, "M j"); return self::dateFormat($date, 'M j');
} else { } else {
return User::dateFormat($date, "M j, Y"); return self::dateFormat($date, 'M j, Y');
} }
} else { } else {
$diff_text = $date->diffForHumans(); $diff_text = $date->diffForHumans();
$diff_text = preg_replace("/minutes?/", 'min', $diff_text); $diff_text = preg_replace('/minutes?/', 'min', $diff_text);
return $diff_text; return $diff_text;
} }
} }

View File

@@ -213,40 +213,40 @@ return [
'aliases' => [ 'aliases' => [
'App' => Illuminate\Support\Facades\App::class, 'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class, 'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class, 'Blade' => Illuminate\Support\Facades\Blade::class,
'Broadcast' => Illuminate\Support\Facades\Broadcast::class, 'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
'Bus' => Illuminate\Support\Facades\Bus::class, 'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class, 'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class, 'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class, 'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class, 'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class, 'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class, 'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class, 'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class, 'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class, 'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class, 'Hash' => Illuminate\Support\Facades\Hash::class,
'Lang' => Illuminate\Support\Facades\Lang::class, 'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class, 'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class, 'Mail' => Illuminate\Support\Facades\Mail::class,
'Notification' => Illuminate\Support\Facades\Notification::class, 'Notification' => Illuminate\Support\Facades\Notification::class,
'Password' => Illuminate\Support\Facades\Password::class, 'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class, 'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class, 'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class, 'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class, 'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class, 'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class, 'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class, 'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class, 'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class, 'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class, 'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class, 'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class, 'View' => Illuminate\Support\Facades\View::class,
'Minify' => Devfactory\Minify\Facades\MinifyFacade::class, 'Minify' => Devfactory\Minify\Facades\MinifyFacade::class,
], ],
]; ];

View File

@@ -14,7 +14,7 @@ return [
*/ */
'defaults' => [ 'defaults' => [
'guard' => 'web', 'guard' => 'web',
'passwords' => 'users', 'passwords' => 'users',
], ],
@@ -37,12 +37,12 @@ return [
'guards' => [ 'guards' => [
'web' => [ 'web' => [
'driver' => 'session', 'driver' => 'session',
'provider' => 'users', 'provider' => 'users',
], ],
'api' => [ 'api' => [
'driver' => 'token', 'driver' => 'token',
'provider' => 'users', 'provider' => 'users',
], ],
], ],
@@ -67,7 +67,7 @@ return [
'providers' => [ 'providers' => [
'users' => [ 'users' => [
'driver' => 'eloquent', 'driver' => 'eloquent',
'model' => App\User::class, 'model' => App\User::class,
], ],
// 'users' => [ // 'users' => [
@@ -94,8 +94,8 @@ return [
'passwords' => [ 'passwords' => [
'users' => [ 'users' => [
'provider' => 'users', 'provider' => 'users',
'table' => 'password_resets', 'table' => 'password_resets',
'expire' => 60, 'expire' => 60,
], ],
], ],

View File

@@ -31,18 +31,18 @@ return [
'connections' => [ 'connections' => [
'pusher' => [ 'pusher' => [
'driver' => 'pusher', 'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'), 'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'), 'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'), 'app_id' => env('PUSHER_APP_ID'),
'options' => [ 'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'), 'cluster' => env('PUSHER_APP_CLUSTER'),
'encrypted' => true, 'encrypted' => true,
], ],
], ],
'redis' => [ 'redis' => [
'driver' => 'redis', 'driver' => 'redis',
'connection' => 'default', 'connection' => 'default',
], ],

View File

@@ -39,20 +39,20 @@ return [
], ],
'database' => [ 'database' => [
'driver' => 'database', 'driver' => 'database',
'table' => 'cache', 'table' => 'cache',
'connection' => null, 'connection' => null,
], ],
'file' => [ 'file' => [
'driver' => 'file', 'driver' => 'file',
'path' => storage_path('framework/cache/data'), 'path' => storage_path('framework/cache/data'),
], ],
'memcached' => [ 'memcached' => [
'driver' => 'memcached', 'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [ 'sasl' => [
env('MEMCACHED_USERNAME'), env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'), env('MEMCACHED_PASSWORD'),
], ],
@@ -61,15 +61,15 @@ return [
], ],
'servers' => [ 'servers' => [
[ [
'host' => env('MEMCACHED_HOST', '127.0.0.1'), 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211), 'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100, 'weight' => 100,
], ],
], ],
], ],
'redis' => [ 'redis' => [
'driver' => 'redis', 'driver' => 'redis',
'connection' => 'default', 'connection' => 'default',
], ],

View File

@@ -34,24 +34,24 @@ return [
'connections' => [ 'connections' => [
'sqlite' => [ 'sqlite' => [
'driver' => 'sqlite', 'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')), 'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '', 'prefix' => '',
], ],
'mysql' => [ 'mysql' => [
'driver' => 'mysql', 'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'), 'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'), 'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'), 'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'), 'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''), 'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''), 'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4', 'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci', 'collation' => 'utf8mb4_unicode_ci',
'prefix' => '', 'prefix' => '',
'strict' => true, 'strict' => true,
'engine' => null, 'engine' => null,
], ],
'testing' => [ 'testing' => [
@@ -67,27 +67,27 @@ return [
], ],
'pgsql' => [ 'pgsql' => [
'driver' => 'pgsql', 'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'), 'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'), 'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'), 'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'), 'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''), 'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8', 'charset' => 'utf8',
'prefix' => '', 'prefix' => '',
'schema' => 'public', 'schema' => 'public',
'sslmode' => 'prefer', 'sslmode' => 'prefer',
], ],
'sqlsrv' => [ 'sqlsrv' => [
'driver' => 'sqlsrv', 'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'), 'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'), 'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'), 'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'), 'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''), 'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8', 'charset' => 'utf8',
'prefix' => '', 'prefix' => '',
], ],
], ],
@@ -121,9 +121,9 @@ return [
'client' => 'predis', 'client' => 'predis',
'default' => [ 'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'), 'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null), 'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379), 'port' => env('REDIS_PORT', 6379),
'database' => 0, 'database' => 0,
], ],

View File

@@ -45,19 +45,19 @@ return [
'local' => [ 'local' => [
'driver' => 'local', 'driver' => 'local',
'root' => storage_path('app'), 'root' => storage_path('app'),
], ],
'public' => [ 'public' => [
'driver' => 'local', 'driver' => 'local',
'root' => storage_path('app/public'), 'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage', 'url' => env('APP_URL').'/storage',
'visibility' => 'public', 'visibility' => 'public',
], ],
's3' => [ 's3' => [
'driver' => 's3', 'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'), 'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'), 'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'), 'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'), 'bucket' => env('AWS_BUCKET'),

View File

@@ -57,7 +57,7 @@ return [
'from' => [ 'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'), 'name' => env('MAIL_FROM_NAME', 'Example'),
], ],
/* /*

View File

@@ -1,6 +1,6 @@
<?php <?php
return array( return [
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@@ -24,9 +24,9 @@ return array(
| |
*/ */
'ignore_environments' => array( 'ignore_environments' => [
'local', 'local',
), ],
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@@ -41,7 +41,7 @@ return array(
*/ */
'css_build_path' => '/css/builds/', 'css_build_path' => '/css/builds/',
'css_url_path' => '/css/builds/', 'css_url_path' => '/css/builds/',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@@ -56,22 +56,22 @@ return array(
*/ */
'js_build_path' => '/js/builds/', 'js_build_path' => '/js/builds/',
'js_url_path' => '/js/builds/', 'js_url_path' => '/js/builds/',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Hash modification | Hash modification
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| You can disable usage of modification time (mtime) for hash build and | You can disable usage of modification time (mtime) for hash build and
| add additional salt (exp. commit hash) for hash build | add additional salt (exp. commit hash) for hash build
| |
*/ */
'disable_mtime' => false, 'disable_mtime' => false,
'hash_salt' => '', 'hash_salt' => '',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Base URL | Base URL
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@@ -80,5 +80,5 @@ return array(
| value. By default if empty HTTP_HOST would be used. | value. By default if empty HTTP_HOST would be used.
| |
*/ */
'base_url' => '' 'base_url' => '',
); ];

View File

@@ -35,32 +35,32 @@ return [
], ],
'database' => [ 'database' => [
'driver' => 'database', 'driver' => 'database',
'table' => 'jobs', 'table' => 'jobs',
'queue' => 'default', 'queue' => 'default',
'retry_after' => 90, 'retry_after' => 90,
], ],
'beanstalkd' => [ 'beanstalkd' => [
'driver' => 'beanstalkd', 'driver' => 'beanstalkd',
'host' => 'localhost', 'host' => 'localhost',
'queue' => 'default', 'queue' => 'default',
'retry_after' => 90, 'retry_after' => 90,
], ],
'sqs' => [ 'sqs' => [
'driver' => 'sqs', 'driver' => 'sqs',
'key' => env('SQS_KEY', 'your-public-key'), 'key' => env('SQS_KEY', 'your-public-key'),
'secret' => env('SQS_SECRET', 'your-secret-key'), 'secret' => env('SQS_SECRET', 'your-secret-key'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'your-queue-name'), 'queue' => env('SQS_QUEUE', 'your-queue-name'),
'region' => env('SQS_REGION', 'us-east-1'), 'region' => env('SQS_REGION', 'us-east-1'),
], ],
'redis' => [ 'redis' => [
'driver' => 'redis', 'driver' => 'redis',
'connection' => 'default', 'connection' => 'default',
'queue' => 'default', 'queue' => 'default',
'retry_after' => 90, 'retry_after' => 90,
], ],
@@ -79,7 +79,7 @@ return [
'failed' => [ 'failed' => [
'database' => env('DB_CONNECTION', 'mysql'), 'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs', 'table' => 'failed_jobs',
], ],
]; ];

View File

@@ -20,7 +20,7 @@ return [
], ],
'ses' => [ 'ses' => [
'key' => env('SES_KEY'), 'key' => env('SES_KEY'),
'secret' => env('SES_SECRET'), 'secret' => env('SES_SECRET'),
'region' => 'us-east-1', 'region' => 'us-east-1',
], ],
@@ -30,8 +30,8 @@ return [
], ],
'stripe' => [ 'stripe' => [
'model' => App\User::class, 'model' => App\User::class,
'key' => env('STRIPE_KEY'), 'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'), 'secret' => env('STRIPE_SECRET'),
], ],

View File

@@ -1,40 +1,40 @@
<?php <?php
use Faker\Generator as Faker;
use App\Conversation; use App\Conversation;
use Faker\Generator as Faker;
$factory->define(Conversation::class, function (Faker $faker, $params) { $factory->define(Conversation::class, function (Faker $faker, $params) {
if (!empty($params['created_by'])) {
$created_by = $params['created_by'];
} else {
// Pick random user
$created_by = App\User::inRandomOrder()->first()->id;
}
$folder_id = null;
if (!empty($params['folder_id'])) {
$folder_id = $params['folder_id'];
} elseif (!empty($params['mailbox_id'])) {
// Pick folder
$folder = App\Folder::where(['mailbox_id' => $params['mailbox_id'], 'type' => App\Folder::TYPE_UNASSIGNED])->first();
if ($folder) {
$folder_id = $folder->id;
} else {
$folder_id = factory(App\Folder::class)->create()->id;
}
}
if (!empty($params['created_by'])) {
$created_by = $params['created_by'];
} else {
// Pick random user
$created_by = App\User::inRandomOrder()->first()->id;
}
$folder_id = null;
if (!empty($params['folder_id'])) {
$folder_id = $params['folder_id'];
} elseif (!empty($params['mailbox_id'])) {
// Pick folder
$folder = App\Folder::where(['mailbox_id' => $params['mailbox_id'], 'type' => App\Folder::TYPE_UNASSIGNED])->first();
if ($folder) {
$folder_id = $folder->id;
} else {
$folder_id = factory(App\Folder::class)->create()->id;
}
}
return [ return [
'type' => $faker->randomElement([Conversation::TYPE_EMAIL, Conversation::TYPE_PHONE]), 'type' => $faker->randomElement([Conversation::TYPE_EMAIL, Conversation::TYPE_PHONE]),
'folder_id' => $folder_id, 'folder_id' => $folder_id,
'state' => $faker->randomElement(array_keys(Conversation::$states)), 'state' => $faker->randomElement(array_keys(Conversation::$states)),
'subject' => $faker->sentence(7), 'subject' => $faker->sentence(7),
// todo: cc and bcc must be equal to first (or last?) thread of conversation // todo: cc and bcc must be equal to first (or last?) thread of conversation
'cc' => json_encode([$faker->unique()->safeEmail]), 'cc' => json_encode([$faker->unique()->safeEmail]),
'bcc' => json_encode([$faker->unique()->safeEmail]), 'bcc' => json_encode([$faker->unique()->safeEmail]),
'preview' => $faker->text(Conversation::PREVIEW_MAXLENGTH), 'preview' => $faker->text(Conversation::PREVIEW_MAXLENGTH),
'imported' => true, 'imported' => true,
'created_by' => $created_by, 'created_by' => $created_by,
'source_via' => Conversation::PERSON_CUSTOMER, 'source_via' => Conversation::PERSON_CUSTOMER,
'source_type' => Conversation::SOURCE_TYPE_EMAIL, 'source_type' => Conversation::SOURCE_TYPE_EMAIL,
]; ];
}); });

View File

@@ -1,13 +1,13 @@
<?php <?php
use Faker\Generator as Faker;
use App\Customer; use App\Customer;
use Faker\Generator as Faker;
$factory->define(App\Customer::class, function (Faker $faker) { $factory->define(App\Customer::class, function (Faker $faker) {
return [ return [
'first_name' => $faker->firstName, 'first_name' => $faker->firstName,
'last_name' => $faker->lastName, 'last_name' => $faker->lastName,
'job_title' => $faker->jobTitle, 'job_title' => $faker->jobTitle,
'phones' => Customer::formatPhones([['value' => $faker->phoneNumber, 'type' => Customer::PHONE_TYPE_WORK]]) 'phones' => Customer::formatPhones([['value' => $faker->phoneNumber, 'type' => Customer::PHONE_TYPE_WORK]]),
]; ];
}); });

View File

@@ -1,20 +1,21 @@
<?php <?php
use Faker\Generator as Faker;
use App\Folder; use App\Folder;
use Faker\Generator as Faker;
$factory->define(App\Folder::class, function (Faker $faker, $params) { $factory->define(App\Folder::class, function (Faker $faker, $params) {
$mailbox_id = null; $mailbox_id = null;
if (!empty($params['mailbox_id'])) { if (!empty($params['mailbox_id'])) {
$mailbox_id = $params['mailbox_id']; $mailbox_id = $params['mailbox_id'];
} else { } else {
$mailbox = App\Mailbox::inRandomOrder()->first(); $mailbox = App\Mailbox::inRandomOrder()->first();
if ($mailbox) { if ($mailbox) {
$mailbox_id = $mailbox->id; $mailbox_id = $mailbox->id;
} }
} }
return [ return [
'mailbox_id' => $mailbox_id, 'mailbox_id' => $mailbox_id,
'type' => Folder::TYPE_UNASSIGNED, 'type' => Folder::TYPE_UNASSIGNED,
]; ];
}); });

View File

@@ -3,13 +3,14 @@
use Faker\Generator as Faker; use Faker\Generator as Faker;
$factory->define(App\Mailbox::class, function (Faker $faker) { $factory->define(App\Mailbox::class, function (Faker $faker) {
$name = $faker->company; $name = $faker->company;
$email = $faker->unique()->companyEmail; $email = $faker->unique()->companyEmail;
$domain = explode('@', $email)[1]; $domain = explode('@', $email)[1];
return [ return [
'name' => $name, 'name' => $name,
'email' => $email, 'email' => $email,
'aliases' => 'support@'.$domain.',help@'.$domain.', contact@'.$domain, 'aliases' => 'support@'.$domain.',help@'.$domain.', contact@'.$domain,
'signature' => '--<br/>'.$name, 'signature' => '--<br/>'.$name,
]; ];
}); });

View File

@@ -1,39 +1,39 @@
<?php <?php
use Faker\Generator as Faker;
use App\Thread; use App\Thread;
use Faker\Generator as Faker;
$factory->define(Thread::class, function (Faker $faker, $params) { $factory->define(Thread::class, function (Faker $faker, $params) {
if (!empty($params['customer_id'])) {
$customer_id = $params['customer_id'];
} else {
// Pick random customer
//$customer_id = $faker->randomElement(App\Customer::pluck('id')->toArray());
$customer = User::inRandomOrder()->first();
if (!$customer) {
$customer = factory(App\Customer::class)->create();
}
$customer_id = $customer->id;
}
if (!empty($params['to'])) {
$to = $params['to'];
} elseif ($customer) {
$to = $customer->getMainEmail();
} else {
$to = json_encode([$faker->unique()->safeEmail]);
}
if (!empty($params['customer_id'])) {
$customer_id = $params['customer_id'];
} else {
// Pick random customer
//$customer_id = $faker->randomElement(App\Customer::pluck('id')->toArray());
$customer = User::inRandomOrder()->first();
if (!$customer) {
$customer = factory(App\Customer::class)->create();
}
$customer_id = $customer->id;
}
if (!empty($params['to'])) {
$to = $params['to'];
} elseif ($customer) {
$to = $customer->getMainEmail();
} else {
$to = json_encode([$faker->unique()->safeEmail]);
}
return [ return [
'type' => Thread::TYPE_CUSTOMER, 'type' => Thread::TYPE_CUSTOMER,
//'conversation_id' => , //'conversation_id' => ,
'customer_id' => $customer_id, 'customer_id' => $customer_id,
'state' => Thread::STATE_PUBLISHED, 'state' => Thread::STATE_PUBLISHED,
'body' => $faker->text(500), 'body' => $faker->text(500),
'to' => $to, 'to' => $to,
'cc' => json_encode([$faker->unique()->safeEmail]), 'cc' => json_encode([$faker->unique()->safeEmail]),
'bcc' => json_encode([$faker->unique()->safeEmail]), 'bcc' => json_encode([$faker->unique()->safeEmail]),
'source_via' => Thread::PERSON_CUSTOMER, 'source_via' => Thread::PERSON_CUSTOMER,
'source_type' => Thread::SOURCE_TYPE_EMAIL, 'source_type' => Thread::SOURCE_TYPE_EMAIL,
'created_by' => $customer_id, 'created_by' => $customer_id,
]; ];
}); });

View File

@@ -15,12 +15,12 @@ use Faker\Generator as Faker;
$factory->define(App\User::class, function (Faker $faker) { $factory->define(App\User::class, function (Faker $faker) {
return [ return [
'first_name' => $faker->firstName, 'first_name' => $faker->firstName,
'last_name' => $faker->lastName, 'last_name' => $faker->lastName,
'email' => $faker->unique()->safeEmail, 'email' => $faker->unique()->safeEmail,
'job_title' => $faker->jobTitle, 'job_title' => $faker->jobTitle,
'phone' => $faker->phoneNumber, 'phone' => $faker->phoneNumber,
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret 'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
'remember_token' => str_random(10), 'remember_token' => str_random(10),
]; ];
}); });

View File

@@ -1,9 +1,9 @@
<?php <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\User; use App\User;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration class CreateUsersTable extends Migration
{ {

View File

@@ -1,8 +1,8 @@
<?php <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePasswordResetsTable extends Migration class CreatePasswordResetsTable extends Migration
{ {

View File

@@ -1,9 +1,9 @@
<?php <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Mailbox; use App\Mailbox;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateMailboxesTable extends Migration class CreateMailboxesTable extends Migration
{ {

View File

@@ -1,8 +1,8 @@
<?php <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateMailboxUserTable extends Migration class CreateMailboxUserTable extends Migration
{ {

View File

@@ -1,7 +1,7 @@
<?php <?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateActivityLogTable extends Migration class CreateActivityLogTable extends Migration
{ {

View File

@@ -1,9 +1,9 @@
<?php <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Email; use App\Email;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateEmailsTable extends Migration class CreateEmailsTable extends Migration
{ {

View File

@@ -1,9 +1,8 @@
<?php <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use App\Customer; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCustomersTable extends Migration class CreateCustomersTable extends Migration
{ {

View File

@@ -1,9 +1,9 @@
<?php <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Conversation; use App\Conversation;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateConversationsTable extends Migration class CreateConversationsTable extends Migration
{ {
@@ -29,8 +29,8 @@ class CreateConversationsTable extends Migration
$table->text('cc')->nullable(); // JSON $table->text('cc')->nullable(); // JSON
$table->text('bcc')->nullable(); // JSON $table->text('bcc')->nullable(); // JSON
$table->string('preview', Conversation::PREVIEW_MAXLENGTH); $table->string('preview', Conversation::PREVIEW_MAXLENGTH);
// The imported field enables conversation to be created for historical purposes // The imported field enables conversation to be created for historical purposes
// (i.e. if moving from a different platform, you can import your history). // (i.e. if moving from a different platform, you can import your history).
// When imported is set to true, no outgoing emails or notifications will be generated. // When imported is set to true, no outgoing emails or notifications will be generated.
$table->boolean('imported')->default(false); $table->boolean('imported')->default(false);
$table->boolean('has_attachments')->default(false); $table->boolean('has_attachments')->default(false);

View File

@@ -1,8 +1,8 @@
<?php <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFoldersTable extends Migration class CreateFoldersTable extends Migration
{ {

View File

@@ -1,10 +1,10 @@
<?php <?php
/** /**
* Table stores conversations which user marked as starred * Table stores conversations which user marked as starred.
*/ */
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateConversationFolderTable extends Migration class CreateConversationFolderTable extends Migration
{ {

View File

@@ -1,9 +1,9 @@
<?php <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Thread; use App\Thread;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateThreadsTable extends Migration class CreateThreadsTable extends Migration
{ {

View File

@@ -12,8 +12,8 @@ class CustomersTableSeeder extends Seeder
public function run() public function run()
{ {
factory(App\Customer::class, 5)->create()->each(function ($m) { factory(App\Customer::class, 5)->create()->each(function ($m) {
$m->emails()->save(factory(App\Email::class)->make()); $m->emails()->save(factory(App\Email::class)->make());
$m->emails()->save(factory(App\Email::class)->make()); $m->emails()->save(factory(App\Email::class)->make());
}); });
} }
} }

View File

@@ -1,7 +1,7 @@
<?php <?php
use Illuminate\Database\Seeder;
use App\Conversation; use App\Conversation;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder class DatabaseSeeder extends Seeder
{ {
@@ -17,10 +17,9 @@ class DatabaseSeeder extends Seeder
$user = factory(App\User::class)->create(); $user = factory(App\User::class)->create();
$m->users()->save($user); $m->users()->save($user);
for ($i=0; $i < 7; $i++) { for ($i = 0; $i < 7; $i++) {
$customer = factory(App\Customer::class)->create(); $customer = factory(App\Customer::class)->create();
$customer->emails()->save(factory(App\Email::class)->make()); $customer->emails()->save(factory(App\Email::class)->make());
$conversation = factory(App\Conversation::class)->create(['created_by' => $user->id, 'mailbox_id' => $m->id, 'customer_id' => $customer->id, 'user_id' => $user->id, 'status' => array_rand([Conversation::STATUS_ACTIVE => 1, Conversation::STATUS_PENDING => 1])]); $conversation = factory(App\Conversation::class)->create(['created_by' => $user->id, 'mailbox_id' => $m->id, 'customer_id' => $customer->id, 'user_id' => $user->id, 'status' => array_rand([Conversation::STATUS_ACTIVE => 1, Conversation::STATUS_PENDING => 1])]);

View File

@@ -11,6 +11,6 @@ class MailboxesTableSeeder extends Seeder
*/ */
public function run() public function run()
{ {
factory(App\Mailbox::class, 3)->create(); factory(App\Mailbox::class, 3)->create();
} }
} }

View File

@@ -1,12 +1,10 @@
<?php <?php
/** /**
* Laravel - A PHP Framework For Web Artisans * Laravel - A PHP Framework For Web Artisans.
* *
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com> * @author Taylor Otwell <taylor@laravel.com>
*/ */
define('LARAVEL_START', microtime(true)); define('LARAVEL_START', microtime(true));
/* /*

View File

@@ -13,7 +13,7 @@ return [
| |
*/ */
'failed' => 'These credentials do not match our records.', 'failed' => 'These credentials do not match our records.',
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
]; ];

View File

@@ -14,6 +14,6 @@ return [
*/ */
'previous' => '&laquo; Previous', 'previous' => '&laquo; Previous',
'next' => 'Next &raquo;', 'next' => 'Next &raquo;',
]; ];

View File

@@ -14,9 +14,9 @@ return [
*/ */
'password' => 'Passwords must be at least six characters and match the confirmation.', 'password' => 'Passwords must be at least six characters and match the confirmation.',
'reset' => 'Your password has been reset!', 'reset' => 'Your password has been reset!',
'sent' => 'We have e-mailed your password reset link!', 'sent' => 'We have e-mailed your password reset link!',
'token' => 'This password reset token is invalid.', 'token' => 'This password reset token is invalid.',
'user' => "We can't find a user with that e-mail address.", 'user' => "We can't find a user with that e-mail address.",
]; ];

View File

@@ -13,11 +13,11 @@
Auth::routes(); Auth::routes();
# General routes for logged in users // General routes for logged in users
Route::get('/', 'SecureController@dashboard')->name('dashboard'); Route::get('/', 'SecureController@dashboard')->name('dashboard');
Route::get('/logs/{name?}', 'SecureController@logs')->name('logs'); Route::get('/logs/{name?}', 'SecureController@logs')->name('logs');
# Users // Users
Route::get('/users', 'UsersController@users')->name('users'); Route::get('/users', 'UsersController@users')->name('users');
Route::get('/users/wizard', 'UsersController@create')->name('users.create'); Route::get('/users/wizard', 'UsersController@create')->name('users.create');
Route::post('/users/wizard', 'UsersController@createSave'); Route::post('/users/wizard', 'UsersController@createSave');
@@ -27,7 +27,7 @@ Route::post('/users/permissions/{id}', 'UsersController@permissionsSave');
Route::get('/users/permissions/{id}', 'UsersController@permissions')->name('users.permissions'); Route::get('/users/permissions/{id}', 'UsersController@permissions')->name('users.permissions');
Route::post('/users/permissions/{id}', 'UsersController@permissionsSave'); Route::post('/users/permissions/{id}', 'UsersController@permissionsSave');
# Mailboxes // Mailboxes
Route::get('/settings/mailboxes', 'MailboxesController@mailboxes')->name('mailboxes'); Route::get('/settings/mailboxes', 'MailboxesController@mailboxes')->name('mailboxes');
Route::get('/settings/mailbox-new', 'MailboxesController@create')->name('mailboxes.create'); Route::get('/settings/mailbox-new', 'MailboxesController@create')->name('mailboxes.create');
Route::post('/settings/mailbox-new', 'MailboxesController@createSave'); Route::post('/settings/mailbox-new', 'MailboxesController@createSave');
@@ -42,10 +42,10 @@ Route::post('/settings/connection-settings/{id}/outgoing', 'MailboxesController@
Route::get('/settings/connection-settings/{id}/incoming', 'MailboxesController@connectionIncoming')->name('mailboxes.connection.incoming'); Route::get('/settings/connection-settings/{id}/incoming', 'MailboxesController@connectionIncoming')->name('mailboxes.connection.incoming');
Route::post('/settings/connection-settings/{id}/incoming', 'MailboxesController@connectionIncomingSave'); Route::post('/settings/connection-settings/{id}/incoming', 'MailboxesController@connectionIncomingSave');
# Customers // Customers
Route::get('/customer/{id}/edit', 'CustomersController@update')->name('customers.update'); Route::get('/customer/{id}/edit', 'CustomersController@update')->name('customers.update');
Route::post('/customer/{id}/edit', 'CustomersController@updateSave'); Route::post('/customer/{id}/edit', 'CustomersController@updateSave');
Route::get('/customer/{id}/', 'CustomersController@conversations')->name('customers.conversations'); Route::get('/customer/{id}/', 'CustomersController@conversations')->name('customers.conversations');
# Conversations // Conversations
Route::get('/conversation/{id}', 'ConversationsController@view')->name('conversations.view'); Route::get('/conversation/{id}', 'ConversationsController@view')->name('conversations.view');

View File

@@ -1,12 +1,10 @@
<?php <?php
/** /**
* Laravel - A PHP Framework For Web Artisans * Laravel - A PHP Framework For Web Artisans.
* *
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com> * @author Taylor Otwell <taylor@laravel.com>
*/ */
$uri = urldecode( $uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
); );

View File

@@ -2,8 +2,8 @@
namespace Tests; namespace Tests;
use Illuminate\Support\Facades\Hash;
use Illuminate\Contracts\Console\Kernel; use Illuminate\Contracts\Console\Kernel;
use Illuminate\Support\Facades\Hash;
trait CreatesApplication trait CreatesApplication
{ {

View File

@@ -3,7 +3,6 @@
namespace Tests\Unit; namespace Tests\Unit;
use Tests\TestCase; use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ExampleTest extends TestCase class ExampleTest extends TestCase
{ {