From f5b82add6666754d9e7734cb260b8548409c5fef Mon Sep 17 00:00:00 2001 From: FreeScout Date: Tue, 24 Jul 2018 06:34:28 +0000 Subject: [PATCH] Apply fixes from StyleCI --- app/ActivityLog.php | 2 +- app/Console/Commands/CreateUser.php | 31 +- app/Console/Kernel.php | 3 +- app/Conversation.php | 144 ++-- app/Customer.php | 690 +++++++++--------- app/Email.php | 24 +- app/Events/Event.php | 6 +- app/Exceptions/Handler.php | 8 +- app/Folder.php | 39 +- .../Controllers/Auth/RegisterController.php | 25 +- app/Http/Controllers/Controller.php | 4 +- .../Controllers/ConversationsController.php | 12 +- app/Http/Controllers/CustomersController.php | 35 +- app/Http/Controllers/MailboxesController.php | 105 +-- app/Http/Controllers/SecureController.php | 20 +- app/Http/Controllers/UsersController.php | 58 +- app/Http/Kernel.php | 10 +- .../Middleware/RedirectIfAuthenticated.php | 7 +- app/Http/Middleware/TrustProxies.php | 10 +- app/Listeners/LogFailedLogin.php | 5 +- app/Listeners/LogLockout.php | 5 +- app/Listeners/LogPasswordReset.php | 5 +- app/Listeners/LogRegisteredUser.php | 5 +- app/Listeners/LogSuccessfulLogin.php | 5 +- app/Listeners/LogSuccessfulLogout.php | 5 +- app/Mailbox.php | 56 +- app/MailboxUser.php | 2 +- app/Observers/ConversationObserver.php | 10 +- app/Observers/MailboxObserver.php | 19 +- app/Observers/ThreadObserver.php | 9 +- app/Observers/UserObserver.php | 9 +- app/Policies/ConversationPolicy.php | 7 +- app/Policies/FolderPolicy.php | 7 +- app/Policies/MailboxPolicy.php | 15 +- app/Policies/UserPolicy.php | 18 +- app/Providers/AppServiceProvider.php | 2 +- app/Providers/AuthServiceProvider.php | 7 +- app/Providers/BroadcastServiceProvider.php | 2 +- app/Providers/EventServiceProvider.php | 4 +- app/Providers/RouteServiceProvider.php | 2 +- app/Thread.php | 128 ++-- app/User.php | 110 +-- config/app.php | 66 +- config/auth.php | 12 +- config/broadcasting.php | 12 +- config/cache.php | 16 +- config/database.php | 54 +- config/filesystems.php | 10 +- config/mail.php | 2 +- config/minify.config.php | 24 +- config/queue.php | 24 +- config/services.php | 6 +- database/factories/ConversationFactory.php | 56 +- database/factories/CustomerFactory.php | 8 +- database/factories/FolderFactory.php | 23 +- database/factories/MailboxFactory.php | 13 +- database/factories/ThreadFactory.php | 52 +- database/factories/UserFactory.php | 12 +- .../2018_06_10_000000_create_users_table.php | 6 +- ...10_100000_create_password_resets_table.php | 4 +- ...18_06_25_065719_create_mailboxes_table.php | 6 +- ...06_29_041002_create_mailbox_user_table.php | 4 +- ...07_07_071443_create_activity_log_table.php | 2 +- .../2018_07_09_052314_create_emails_table.php | 6 +- ...18_07_09_053559_create_customers_table.php | 5 +- ...7_11_010333_create_conversations_table.php | 10 +- ...2018_07_11_074558_create_folders_table.php | 4 +- ...81928_create_conversation_folder_table.php | 6 +- ...2018_07_12_003318_create_threads_table.php | 6 +- database/seeds/CustomersTableSeeder.php | 6 +- database/seeds/DatabaseSeeder.php | 7 +- database/seeds/MailboxesTableSeeder.php | 2 +- public/index.php | 4 +- resources/lang/en/auth.php | 2 +- resources/lang/en/pagination.php | 2 +- resources/lang/en/passwords.php | 8 +- routes/web.php | 12 +- server.php | 4 +- tests/CreatesApplication.php | 2 +- tests/Unit/ExampleTest.php | 1 - 80 files changed, 1098 insertions(+), 1071 deletions(-) diff --git a/app/ActivityLog.php b/app/ActivityLog.php index e72da16a6..f00557502 100644 --- a/app/ActivityLog.php +++ b/app/ActivityLog.php @@ -15,7 +15,7 @@ class ActivityLog extends Activity const DESCRIPTION_USER_LOGIN_FAILED = 'login_failed'; const DESCRIPTION_USER_PASSWORD_RESET = 'password_reset'; - function getEventDescription() + public function getEventDescription() { switch ($this->description) { case self::DESCRIPTION_USER_LOGIN: diff --git a/app/Console/Commands/CreateUser.php b/app/Console/Commands/CreateUser.php index 9d4294147..b6fd1f384 100644 --- a/app/Console/Commands/CreateUser.php +++ b/app/Console/Commands/CreateUser.php @@ -2,8 +2,8 @@ namespace App\Console\Commands; -use Illuminate\Console\Command; use App\User; +use Illuminate\Console\Command; class CreateUser extends Command { @@ -39,46 +39,47 @@ public function __construct() public function handle() { $class = config( - 'auth.providers.' . config( - 'auth.guards.' . config( + 'auth.providers.'.config( + 'auth.guards.'.config( 'auth.defaults.guard' - ) . '.provider' - ) . '.model' + ).'.provider' + ).'.model' ); - $user = new $class; + $user = new $class(); $fillables = ['role', 'first_name', 'last_name', 'email', 'password']; - foreach($fillables as $key => $fillable) { + foreach ($fillables as $key => $fillable) { 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') { - $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) { $user->$fillable = 'admin'; } while (!in_array($user->$fillable, User::$roles)) { - $this->error("Incorrect role"); - $user->$fillable = $this->ask("Please enter valid role"); + $this->error('Incorrect role'); + $user->$fillable = $this->ask('Please enter valid role'); } $user->$fillable = array_flip(User::$roles)[$user->$fillable]; } else { - $user->$fillable = $this->ask(($key+1) . "/" . count($fillables) . " User $fillable"); + $user->$fillable = $this->ask(($key + 1).'/'.count($fillables)." User $fillable"); if ($fillable == 'email') { while (!filter_var($user->$fillable, FILTER_VALIDATE_EMAIL)) { - $this->error("Incorrect email address"); - $user->$fillable = $this->ask("Please enter valid email address"); + $this->error('Incorrect 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()) { $user->invite_state = User::INVITE_STATE_ACTIVATED; } $user->save(); $this->info("User created (id: {$user->id})"); } + return true; } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 132dc87b0..bb8bca80e 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -19,7 +19,8 @@ class Kernel extends ConsoleKernel /** * Define the application's command schedule. * - * @param \Illuminate\Console\Scheduling\Schedule $schedule + * @param \Illuminate\Console\Scheduling\Schedule $schedule + * * @return void */ protected function schedule(Schedule $schedule) diff --git a/app/Conversation.php b/app/Conversation.php index 46f5e4565..1eacb32d8 100644 --- a/app/Conversation.php +++ b/app/Conversation.php @@ -6,37 +6,37 @@ 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_USER = 2; - - public static $persons = array( + + public static $persons = [ 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; - /** - * Conversation types - */ + /** + * Conversation types. + */ const TYPE_EMAIL = 1; const TYPE_PHONE = 2; const TYPE_CHAT = 3; // not used - public static $types = array( - self::TYPE_EMAIL => 'email', - self::TYPE_PHONE => 'phone', - self::TYPE_CHAT => 'chat', - ); + public static $types = [ + self::TYPE_EMAIL => 'email', + self::TYPE_PHONE => 'phone', + self::TYPE_CHAT => 'chat', + ]; /** - * Conversation statuses + * Conversation statuses. */ const STATUS_ACTIVE = 1; const STATUS_PENDING = 2; @@ -45,58 +45,58 @@ class Conversation extends Model // Present in the API, but what does it mean? const STATUS_OPEN = 5; - public static $statuses = array( - self::STATUS_ACTIVE => 'active', + public static $statuses = [ + self::STATUS_ACTIVE => 'active', self::STATUS_PENDING => 'pending', - self::STATUS_CLOSED => 'closed', - self::STATUS_SPAM => 'spam', + self::STATUS_CLOSED => 'closed', + self::STATUS_SPAM => 'spam', //self::STATUS_OPEN => 'open', - ); + ]; /** - * https://glyphicons.bootstrapcheatsheets.com/ + * https://glyphicons.bootstrapcheatsheets.com/. */ - public static $status_icons = array( - self::STATUS_ACTIVE => 'ok', + public static $status_icons = [ + self::STATUS_ACTIVE => 'ok', self::STATUS_PENDING => 'hourglass', - self::STATUS_CLOSED => 'lock', - self::STATUS_SPAM => 'ban-circle', + self::STATUS_CLOSED => 'lock', + self::STATUS_SPAM => 'ban-circle', //self::STATUS_OPEN => 'folder-open', - ); + ]; - public static $status_colors = array( - self::STATUS_ACTIVE => 'success', + public static $status_colors = [ + self::STATUS_ACTIVE => 'success', self::STATUS_PENDING => 'warning', - self::STATUS_CLOSED => 'grey', - self::STATUS_SPAM => 'danger', + self::STATUS_CLOSED => 'grey', + self::STATUS_SPAM => 'danger', //self::STATUS_OPEN => 'folder-open', - ); + ]; /** - * Conversation states + * Conversation states. */ const STATE_DRAFT = 1; const STATE_PUBLISHED = 2; const STATE_DELETED = 3; - - public static $states = array( - self::STATE_DRAFT => 'draft', - self::STATE_PUBLISHED => 'published', - self::STATE_DELETED => 'deleted', - ); - /** - * Source types (equal to thread source types) + public static $states = [ + 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_WEB = 2; const SOURCE_TYPE_API = 3; - - public static $source_types = array( - self::SOURCE_TYPE_EMAIL => 'email', - self::SOURCE_TYPE_WEB => 'web', - self::SOURCE_TYPE_API => 'api', - ); + + public static $source_types = [ + self::SOURCE_TYPE_EMAIL => 'email', + self::SOURCE_TYPE_WEB => 'web', + self::SOURCE_TYPE_API => 'api', + ]; /** * Automatically converted into Carbon dates. @@ -104,7 +104,7 @@ class Conversation extends Model 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']; @@ -112,14 +112,13 @@ protected static function boot() { parent::boot(); - self::creating(function (Conversation $model) - { - $model->number = Conversation::where('mailbox_id', $model->mailbox_id)->max('number')+1; + self::creating(function (Conversation $model) { + $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() { @@ -127,7 +126,7 @@ public function user() } /** - * Get the folder to which conversation belongs + * Get the folder to which conversation belongs. */ public function folder() { @@ -135,7 +134,7 @@ public function folder() } /** - * Get the mailbox to which conversation belongs + * Get the mailbox to which conversation belongs. */ public function mailbox() { @@ -143,7 +142,7 @@ public function mailbox() } /** - * Get the customer associated with this conversation (primaryCustomer) + * Get the customer associated with this conversation (primaryCustomer). */ public function customer() { @@ -151,7 +150,7 @@ public function customer() } /** - * Get conversation threads + * Get conversation threads. */ public function threads() { @@ -159,7 +158,7 @@ public function threads() } /** - * Folders containing starred conversations + * Folders containing starred conversations. */ public function extraFolders() { @@ -167,8 +166,8 @@ public function extraFolders() } /** - * Set preview text - * + * Set preview text. + * * @param string $text */ public function setPreview($text = '') @@ -183,22 +182,24 @@ public function setPreview($text = '') $this->preview = mb_substr($first_thread->body, 0, self::PREVIEW_MAXLENGTH); } } + return $this->preview; } /** * Get conversation timestamp title. - * + * * @return string */ public function getDateTitle() { if ($this->threads_count == 1) { - $title = __("Created by :person
:date", ['person' => ucfirst(__( + $title = __('Created by :person
:date', ['person' => ucfirst(__( self::$persons[$this->source_via])), 'date' => User::dateFormat($this->created_at, 'M j, Y H:i')]); } else { - $title = __("Last reply by :person
:date", ['person' => ucfirst(__(self::$persons[$this->source_via])), 'date' => User::dateFormat($this->created_at, 'M j, Y H:i')]); + $title = __('Last reply by :person
:date', ['person' => ucfirst(__(self::$persons[$this->source_via])), 'date' => User::dateFormat($this->created_at, 'M j, Y H:i')]); } + return $title; } @@ -209,31 +210,32 @@ public function isActive() /** * Get status name. - * - * @param integer $status - * @return string + * + * @param int $status + * + * @return string */ public static function getStatusName($status) { switch ($status) { case self::STATUS_ACTIVE: - return __("Active"); + return __('Active'); break; case self::STATUS_PENDING: - return __("Pending"); + return __('Pending'); break; case self::STATUS_CLOSED: - return __("Closed"); + return __('Closed'); break; case self::STATUS_SPAM: - return __("Spam"); + return __('Spam'); break; case self::STATUS_OPEN: - return __("Open"); + return __('Open'); break; default: diff --git a/app/Customer.php b/app/Customer.php index 38efa6871..c5765607e 100644 --- a/app/Customer.php +++ b/app/Customer.php @@ -3,28 +3,27 @@ namespace App; use Illuminate\Database\Eloquent\Model; -use App\Email; class Customer extends Model { - /** - * Genders - */ + /** + * Genders. + */ const GENDER_UNKNOWN = 1; const GENDER_MALE = 2; const GENDER_FEMALE = 3; /** - * For API + * For API. */ public static $genders = [ self::GENDER_UNKNOWN => 'unknown', - self::GENDER_MALE => 'male', - self::GENDER_FEMALE => 'female', + self::GENDER_MALE => 'male', + self::GENDER_FEMALE => 'female', ]; /** - * Phone types + * Phone types. */ const PHONE_TYPE_WORK = 1; const PHONE_TYPE_HOME = 2; @@ -34,19 +33,19 @@ class Customer extends Model const PHONE_TYPE_PAGER = 6; /** - * For API + * For API. */ public static $phone_types = [ - self::PHONE_TYPE_WORK => 'work', - self::PHONE_TYPE_HOME => 'home', - self::PHONE_TYPE_OTHER => 'other', - self::PHONE_TYPE_MOBILE => 'mobile', - self::PHONE_TYPE_FAX => 'Fax', - self::PHONE_TYPE_PAGER => 'pager', + self::PHONE_TYPE_WORK => 'work', + self::PHONE_TYPE_HOME => 'home', + self::PHONE_TYPE_OTHER => 'other', + self::PHONE_TYPE_MOBILE => 'mobile', + self::PHONE_TYPE_FAX => 'Fax', + self::PHONE_TYPE_PAGER => 'pager', ]; /** - * Photo types + * Photo types. */ const PHOTO_TYPE_UKNOWN = 1; const PHOTO_TYPE_GRAVATAR = 2; @@ -58,21 +57,21 @@ class Customer extends Model const PHOTO_TYPE_VK = 8; // Extra /** - * For API + * For API. */ public static $photo_types = [ - self::PHOTO_TYPE_UKNOWN => 'unknown', - self::PHOTO_TYPE_GRAVATAR => 'gravatar', - self::PHOTO_TYPE_TWITTER => 'twitter', - self::PHOTO_TYPE_FACEBOOK => 'facebook', + self::PHOTO_TYPE_UKNOWN => 'unknown', + self::PHOTO_TYPE_GRAVATAR => 'gravatar', + self::PHOTO_TYPE_TWITTER => 'twitter', + self::PHOTO_TYPE_FACEBOOK => 'facebook', self::PHOTO_TYPE_GOOGLEPROFILE => 'googleprofile', - self::PHOTO_TYPE_GOOGLEPLUS => 'googleplus', - self::PHOTO_TYPE_LINKEDIN => 'linkedin', - self::PHOTO_TYPE_VK => 'vk', // Extra + self::PHOTO_TYPE_GOOGLEPLUS => 'googleplus', + self::PHOTO_TYPE_LINKEDIN => 'linkedin', + self::PHOTO_TYPE_VK => 'vk', // Extra ]; /** - * Chat types + * Chat types. */ const CHAT_TYPE_AIM = 1; const CHAT_TYPE_GTALK = 2; @@ -86,36 +85,36 @@ class Customer extends Model const CHAT_TYPE_OTHER = 9; /** - * For API + * For API. */ public static $chat_types = [ - self::CHAT_TYPE_AIM => 'aim', - self::CHAT_TYPE_GTALK => 'gtalk', - self::CHAT_TYPE_ICQ => 'icq', - self::CHAT_TYPE_XMPP => 'xmpp', - self::CHAT_TYPE_MSN => 'msn', - self::CHAT_TYPE_SKYPE => 'skype', - self::CHAT_TYPE_YAHOO => 'yahoo', - self::CHAT_TYPE_QQ => 'qq', + self::CHAT_TYPE_AIM => 'aim', + self::CHAT_TYPE_GTALK => 'gtalk', + self::CHAT_TYPE_ICQ => 'icq', + self::CHAT_TYPE_XMPP => 'xmpp', + self::CHAT_TYPE_MSN => 'msn', + self::CHAT_TYPE_SKYPE => 'skype', + self::CHAT_TYPE_YAHOO => 'yahoo', + self::CHAT_TYPE_QQ => 'qq', self::CHAT_TYPE_WECHAT => 'wechat', // Extra - self::CHAT_TYPE_OTHER => 'other', + self::CHAT_TYPE_OTHER => 'other', ]; public static $chat_type_names = [ - self::CHAT_TYPE_AIM => 'AIM', - self::CHAT_TYPE_GTALK => 'Google+', - self::CHAT_TYPE_ICQ => 'ICQ', - self::CHAT_TYPE_XMPP => 'XMPP', - self::CHAT_TYPE_MSN => 'MSN', - self::CHAT_TYPE_SKYPE => 'Skype', - self::CHAT_TYPE_YAHOO => 'Yahoo', - self::CHAT_TYPE_QQ => 'QQ', + self::CHAT_TYPE_AIM => 'AIM', + self::CHAT_TYPE_GTALK => 'Google+', + self::CHAT_TYPE_ICQ => 'ICQ', + self::CHAT_TYPE_XMPP => 'XMPP', + self::CHAT_TYPE_MSN => 'MSN', + self::CHAT_TYPE_SKYPE => 'Skype', + self::CHAT_TYPE_YAHOO => 'Yahoo', + self::CHAT_TYPE_QQ => 'QQ', 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_FACEBOOK = 2; @@ -132,306 +131,307 @@ class Customer extends Model const SOCIAL_TYPE_OTHER = 12; public static $social_types = [ - self::SOCIAL_TYPE_TWITTER => 'twitter', - self::SOCIAL_TYPE_FACEBOOK => 'facebook', - self::SOCIAL_TYPE_LINKEDIN => 'linkedin', - self::SOCIAL_TYPE_ABOUTME => 'aboutme', - self::SOCIAL_TYPE_GOOGLE => 'google', + self::SOCIAL_TYPE_TWITTER => 'twitter', + self::SOCIAL_TYPE_FACEBOOK => 'facebook', + self::SOCIAL_TYPE_LINKEDIN => 'linkedin', + self::SOCIAL_TYPE_ABOUTME => 'aboutme', + self::SOCIAL_TYPE_GOOGLE => 'google', self::SOCIAL_TYPE_GOOGLEPLUS => 'googleplus', - self::SOCIAL_TYPE_TUNGLEME => 'tungleme', - self::SOCIAL_TYPE_QUORA => 'quora', + self::SOCIAL_TYPE_TUNGLEME => 'tungleme', + self::SOCIAL_TYPE_QUORA => 'quora', self::SOCIAL_TYPE_FOURSQUARE => 'foursquare', - self::SOCIAL_TYPE_YOUTUBE => 'youtube', - self::SOCIAL_TYPE_FLICKR => 'flickr', - self::SOCIAL_TYPE_VK => 'vk', // Extra - self::SOCIAL_TYPE_OTHER => 'other', + self::SOCIAL_TYPE_YOUTUBE => 'youtube', + self::SOCIAL_TYPE_FLICKR => 'flickr', + self::SOCIAL_TYPE_VK => 'vk', // Extra + self::SOCIAL_TYPE_OTHER => 'other', ]; public static $social_type_names = [ - self::SOCIAL_TYPE_TWITTER => 'Twitter', - self::SOCIAL_TYPE_FACEBOOK => 'Facebook', - self::SOCIAL_TYPE_LINKEDIN => 'Linkedin', - self::SOCIAL_TYPE_ABOUTME => 'About.me', - self::SOCIAL_TYPE_GOOGLE => 'Google', + self::SOCIAL_TYPE_TWITTER => 'Twitter', + self::SOCIAL_TYPE_FACEBOOK => 'Facebook', + self::SOCIAL_TYPE_LINKEDIN => 'Linkedin', + self::SOCIAL_TYPE_ABOUTME => 'About.me', + self::SOCIAL_TYPE_GOOGLE => 'Google', self::SOCIAL_TYPE_GOOGLEPLUS => 'Google+', - self::SOCIAL_TYPE_TUNGLEME => 'Tungle.me', - self::SOCIAL_TYPE_QUORA => 'Quora', + self::SOCIAL_TYPE_TUNGLEME => 'Tungle.me', + self::SOCIAL_TYPE_QUORA => 'Quora', self::SOCIAL_TYPE_FOURSQUARE => 'Foursquare', - self::SOCIAL_TYPE_YOUTUBE => 'YouTube', - self::SOCIAL_TYPE_FLICKR => 'Flickr', - self::SOCIAL_TYPE_VK => 'VK', - self::SOCIAL_TYPE_OTHER => 'Other', + self::SOCIAL_TYPE_YOUTUBE => 'YouTube', + self::SOCIAL_TYPE_FLICKR => 'Flickr', + self::SOCIAL_TYPE_VK => 'VK', + self::SOCIAL_TYPE_OTHER => 'Other', ]; /** - * Countries list + * Countries list. */ public static $countries = [ - "US" => "United States", - "AU" => "Australia", - "CA" => "Canada", - "DK" => "Denmark", - "FR" => "France", - "DE" => "Germany", - "IT" => "Italy", - "JP" => "Japan", - "MX" => "Mexico", - "ES" => "Spain", - "SE" => "Sweden", - "GB" => "United Kingdom", - "AF" => "Afghanistan", - "AX" => "Åland Islands", - "AL" => "Albania", - "DZ" => "Algeria", - "AS" => "American Samoa", - "AD" => "Andorra", - "AO" => "Angola", - "AI" => "Anguilla", - "AQ" => "Antarctica", - "AG" => "Antigua and Barbuda", - "AR" => "Argentina", - "AM" => "Armenia", - "AW" => "Aruba", - "AT" => "Austria", - "AZ" => "Azerbaijan", - "BS" => "Bahamas", - "BH" => "Bahrain", - "BD" => "Bangladesh", - "BB" => "Barbados", - "BY" => "Belarus", - "BE" => "Belgium", - "BZ" => "Belize", - "BJ" => "Benin", - "BM" => "Bermuda", - "BT" => "Bhutan", - "BO" => "Bolivia", - "BQ" => "Bonaire", - "BA" => "Bosnia and Herzegowina", - "BW" => "Botswana", - "BV" => "Bouvet Island", - "BR" => "Brazil", - "IO" => "British Indian Ocean Territory", - "BN" => "Brunei Darussalam", - "BG" => "Bulgaria", - "BF" => "Burkina Faso", - "BI" => "Burundi", - "KH" => "Cambodia", - "CM" => "Cameroon", - "CV" => "Cape Verde", - "KY" => "Cayman Islands", - "CF" => "Central African Republic", - "TD" => "Chad", - "CL" => "Chile", - "CN" => "China", - "CX" => "Christmas Island", - "CC" => "Cocos (Keeling) Islands", - "CO" => "Colombia", - "KM" => "Comoros", - "CG" => "Congo", - "CD" => "Congo, DR", - "CK" => "Cook Islands", - "CR" => "Costa Rica", - "CI" => "Cote D'Ivoire", - "HR" => "Croatia", - "CU" => "Cuba", - "CW" => "Curacao", - "CY" => "Cyprus", - "CZ" => "Czech Republic", - "DJ" => "Djibouti", - "DM" => "Dominica", - "DO" => "Dominican Republic", - "EC" => "Ecuador", - "EG" => "Egypt", - "SV" => "El Salvador", - "GQ" => "Equatorial Guinea", - "ER" => "Eritrea", - "EE" => "Estonia", - "ET" => "Ethiopia", - "FK" => "Falkland Islands (Malvinas)", - "FO" => "Faroe Islands", - "FJ" => "Fiji", - "FI" => "Finland", - "GF" => "French Guiana", - "PF" => "French Polynesia", - "TF" => "French Southern Territories", - "GA" => "Gabon", - "GM" => "Gambia", - "GE" => "Georgia", - "GH" => "Ghana", - "GI" => "Gibraltar", - "GR" => "Greece", - "GL" => "Greenland", - "GD" => "Grenada", - "GP" => "Guadeloupe", - "GU" => "Guam", - "GT" => "Guatemala", - "GG" => "Guernsey", - "GN" => "Guinea", - "GW" => "Guinea-bissau", - "GY" => "Guyana", - "HT" => "Haiti", - "HM" => "Heard and Mc Donald Islands", - "HN" => "Honduras", - "HK" => "Hong Kong", - "HU" => "Hungary", - "IS" => "Iceland", - "IN" => "India", - "ID" => "Indonesia", - "IR" => "Iran (Islamic Republic of)", - "IQ" => "Iraq", - "IE" => "Ireland", - "IM" => "Isle of Man", - "IL" => "Israel", - "JM" => "Jamaica", - "JE" => "Jersey", - "JO" => "Jordan", - "KZ" => "Kazakhstan", - "KE" => "Kenya", - "KI" => "Kiribati", - "KP" => "Korea, Democratic People's Republic of", - "KR" => "Korea, Republic of", - "KW" => "Kuwait", - "KG" => "Kyrgyzstan", - "LA" => "Lao People's Democratic Republic", - "LV" => "Latvia", - "LB" => "Lebanon", - "LS" => "Lesotho", - "LR" => "Liberia", - "LY" => "Libya", - "LI" => "Liechtenstein", - "LT" => "Lithuania", - "LU" => "Luxembourg", - "MO" => "Macao", - "MK" => "Macedonia, The Former Yugoslav Republic of", - "MG" => "Madagascar", - "MW" => "Malawi", - "MY" => "Malaysia", - "MV" => "Maldives", - "ML" => "Mali", - "MT" => "Malta", - "MH" => "Marshall Islands", - "MQ" => "Martinique", - "MR" => "Mauritania", - "MU" => "Mauritius", - "YT" => "Mayotte", - "FM" => "Micronesia, Federated States of", - "MD" => "Moldova, Republic of", - "MC" => "Monaco", - "MN" => "Mongolia", - "ME" => "Montenegro", - "MS" => "Montserrat", - "MA" => "Morocco", - "MZ" => "Mozambique", - "MM" => "Myanmar", - "NA" => "Namibia", - "NR" => "Nauru", - "NP" => "Nepal", - "NL" => "Netherlands", - "NC" => "New Caledonia", - "NZ" => "New Zealand", - "NI" => "Nicaragua", - "NE" => "Niger", - "NG" => "Nigeria", - "NU" => "Niue", - "00" => "None Available", - "NF" => "Norfolk Island", - "MP" => "Northern Mariana Islands", - "NO" => "Norway", - "OM" => "Oman", - "PK" => "Pakistan", - "PW" => "Palau", - "PS" => "Palestine, State of", - "PA" => "Panama", - "PG" => "Papua New Guinea", - "PY" => "Paraguay", - "PE" => "Peru", - "PH" => "Philippines", - "PN" => "Pitcairn", - "PL" => "Poland", - "PT" => "Portugal", - "PR" => "Puerto Rico", - "QA" => "Qatar", - "RE" => "Reunion", - "RO" => "Romania", - "RU" => "Russia", - "RW" => "Rwanda", - "BL" => "Saint Barthelemy", - "KN" => "Saint Kitts and Nevis", - "LC" => "Saint Lucia", - "MF" => "Saint Martin (French part)", - "VC" => "Saint Vincent and the Grenadines", - "WS" => "Samoa", - "SM" => "San Marino", - "ST" => "Sao Tome and Principe", - "SA" => "Saudi Arabia", - "SN" => "Senegal", - "RS" => "Serbia", - "SC" => "Seychelles", - "SL" => "Sierra Leone", - "SG" => "Singapore", - "SX" => "Sint Maarten (Dutch part)", - "SK" => "Slovakia", - "SI" => "Slovenia", - "SB" => "Solomon Islands", - "SO" => "Somalia", - "ZA" => "South Africa", - "GS" => "South Georgia and the South Sandwich Islands", - "SS" => "South Sudan", - "LK" => "Sri Lanka", - "SH" => "St. Helena", - "PM" => "St. Pierre and Miquelon", - "SD" => "Sudan", - "SR" => "Suriname", - "SJ" => "Svalbard and Jan Mayen", - "SZ" => "Swaziland", - "CH" => "Switzerland", - "SY" => "Syrian Arab Republic", - "TW" => "Taiwan, Province of China", - "TJ" => "Tajikistan", - "TZ" => "Tanzania, United Republic of", - "TH" => "Thailand", - "TL" => "Timor-Leste", - "TG" => "Togo", - "TK" => "Tokelau", - "TO" => "Tonga", - "TT" => "Trinidad and Tobago", - "TN" => "Tunisia", - "TR" => "Turkey", - "TM" => "Turkmenistan", - "TC" => "Turks and Caicos Islands", - "TV" => "Tuvalu", - "UG" => "Uganda", - "UA" => "Ukraine", - "AE" => "United Arab Emirates", - "UM" => "United States Minor Outlying Islands", - "UY" => "Uruguay", - "UZ" => "Uzbekistan", - "VU" => "Vanuatu", - "VA" => "Vatican City State (Holy See)", - "VE" => "Venezuela", - "VN" => "Vietnam", - "VG" => "Virgin Islands (British)", - "VI" => "Virgin Islands (U.S.)", - "WF" => "Wallis and Futuna Islands", - "EH" => "Western Sahara", - "YE" => "Yemen", - "ZM" => "Zambia", - "ZW" => "Zimbabwe", + 'US' => 'United States', + 'AU' => 'Australia', + 'CA' => 'Canada', + 'DK' => 'Denmark', + 'FR' => 'France', + 'DE' => 'Germany', + 'IT' => 'Italy', + 'JP' => 'Japan', + 'MX' => 'Mexico', + 'ES' => 'Spain', + 'SE' => 'Sweden', + 'GB' => 'United Kingdom', + 'AF' => 'Afghanistan', + 'AX' => 'Åland Islands', + 'AL' => 'Albania', + 'DZ' => 'Algeria', + 'AS' => 'American Samoa', + 'AD' => 'Andorra', + 'AO' => 'Angola', + 'AI' => 'Anguilla', + 'AQ' => 'Antarctica', + 'AG' => 'Antigua and Barbuda', + 'AR' => 'Argentina', + 'AM' => 'Armenia', + 'AW' => 'Aruba', + 'AT' => 'Austria', + 'AZ' => 'Azerbaijan', + 'BS' => 'Bahamas', + 'BH' => 'Bahrain', + 'BD' => 'Bangladesh', + 'BB' => 'Barbados', + 'BY' => 'Belarus', + 'BE' => 'Belgium', + 'BZ' => 'Belize', + 'BJ' => 'Benin', + 'BM' => 'Bermuda', + 'BT' => 'Bhutan', + 'BO' => 'Bolivia', + 'BQ' => 'Bonaire', + 'BA' => 'Bosnia and Herzegowina', + 'BW' => 'Botswana', + 'BV' => 'Bouvet Island', + 'BR' => 'Brazil', + 'IO' => 'British Indian Ocean Territory', + 'BN' => 'Brunei Darussalam', + 'BG' => 'Bulgaria', + 'BF' => 'Burkina Faso', + 'BI' => 'Burundi', + 'KH' => 'Cambodia', + 'CM' => 'Cameroon', + 'CV' => 'Cape Verde', + 'KY' => 'Cayman Islands', + 'CF' => 'Central African Republic', + 'TD' => 'Chad', + 'CL' => 'Chile', + 'CN' => 'China', + 'CX' => 'Christmas Island', + 'CC' => 'Cocos (Keeling) Islands', + 'CO' => 'Colombia', + 'KM' => 'Comoros', + 'CG' => 'Congo', + 'CD' => 'Congo, DR', + 'CK' => 'Cook Islands', + 'CR' => 'Costa Rica', + 'CI' => "Cote D'Ivoire", + 'HR' => 'Croatia', + 'CU' => 'Cuba', + 'CW' => 'Curacao', + 'CY' => 'Cyprus', + 'CZ' => 'Czech Republic', + 'DJ' => 'Djibouti', + 'DM' => 'Dominica', + 'DO' => 'Dominican Republic', + 'EC' => 'Ecuador', + 'EG' => 'Egypt', + 'SV' => 'El Salvador', + 'GQ' => 'Equatorial Guinea', + 'ER' => 'Eritrea', + 'EE' => 'Estonia', + 'ET' => 'Ethiopia', + 'FK' => 'Falkland Islands (Malvinas)', + 'FO' => 'Faroe Islands', + 'FJ' => 'Fiji', + 'FI' => 'Finland', + 'GF' => 'French Guiana', + 'PF' => 'French Polynesia', + 'TF' => 'French Southern Territories', + 'GA' => 'Gabon', + 'GM' => 'Gambia', + 'GE' => 'Georgia', + 'GH' => 'Ghana', + 'GI' => 'Gibraltar', + 'GR' => 'Greece', + 'GL' => 'Greenland', + 'GD' => 'Grenada', + 'GP' => 'Guadeloupe', + 'GU' => 'Guam', + 'GT' => 'Guatemala', + 'GG' => 'Guernsey', + 'GN' => 'Guinea', + 'GW' => 'Guinea-bissau', + 'GY' => 'Guyana', + 'HT' => 'Haiti', + 'HM' => 'Heard and Mc Donald Islands', + 'HN' => 'Honduras', + 'HK' => 'Hong Kong', + 'HU' => 'Hungary', + 'IS' => 'Iceland', + 'IN' => 'India', + 'ID' => 'Indonesia', + 'IR' => 'Iran (Islamic Republic of)', + 'IQ' => 'Iraq', + 'IE' => 'Ireland', + 'IM' => 'Isle of Man', + 'IL' => 'Israel', + 'JM' => 'Jamaica', + 'JE' => 'Jersey', + 'JO' => 'Jordan', + 'KZ' => 'Kazakhstan', + 'KE' => 'Kenya', + 'KI' => 'Kiribati', + 'KP' => "Korea, Democratic People's Republic of", + 'KR' => 'Korea, Republic of', + 'KW' => 'Kuwait', + 'KG' => 'Kyrgyzstan', + 'LA' => "Lao People's Democratic Republic", + 'LV' => 'Latvia', + 'LB' => 'Lebanon', + 'LS' => 'Lesotho', + 'LR' => 'Liberia', + 'LY' => 'Libya', + 'LI' => 'Liechtenstein', + 'LT' => 'Lithuania', + 'LU' => 'Luxembourg', + 'MO' => 'Macao', + 'MK' => 'Macedonia, The Former Yugoslav Republic of', + 'MG' => 'Madagascar', + 'MW' => 'Malawi', + 'MY' => 'Malaysia', + 'MV' => 'Maldives', + 'ML' => 'Mali', + 'MT' => 'Malta', + 'MH' => 'Marshall Islands', + 'MQ' => 'Martinique', + 'MR' => 'Mauritania', + 'MU' => 'Mauritius', + 'YT' => 'Mayotte', + 'FM' => 'Micronesia, Federated States of', + 'MD' => 'Moldova, Republic of', + 'MC' => 'Monaco', + 'MN' => 'Mongolia', + 'ME' => 'Montenegro', + 'MS' => 'Montserrat', + 'MA' => 'Morocco', + 'MZ' => 'Mozambique', + 'MM' => 'Myanmar', + 'NA' => 'Namibia', + 'NR' => 'Nauru', + 'NP' => 'Nepal', + 'NL' => 'Netherlands', + 'NC' => 'New Caledonia', + 'NZ' => 'New Zealand', + 'NI' => 'Nicaragua', + 'NE' => 'Niger', + 'NG' => 'Nigeria', + 'NU' => 'Niue', + '00' => 'None Available', + 'NF' => 'Norfolk Island', + 'MP' => 'Northern Mariana Islands', + 'NO' => 'Norway', + 'OM' => 'Oman', + 'PK' => 'Pakistan', + 'PW' => 'Palau', + 'PS' => 'Palestine, State of', + 'PA' => 'Panama', + 'PG' => 'Papua New Guinea', + 'PY' => 'Paraguay', + 'PE' => 'Peru', + 'PH' => 'Philippines', + 'PN' => 'Pitcairn', + 'PL' => 'Poland', + 'PT' => 'Portugal', + 'PR' => 'Puerto Rico', + 'QA' => 'Qatar', + 'RE' => 'Reunion', + 'RO' => 'Romania', + 'RU' => 'Russia', + 'RW' => 'Rwanda', + 'BL' => 'Saint Barthelemy', + 'KN' => 'Saint Kitts and Nevis', + 'LC' => 'Saint Lucia', + 'MF' => 'Saint Martin (French part)', + 'VC' => 'Saint Vincent and the Grenadines', + 'WS' => 'Samoa', + 'SM' => 'San Marino', + 'ST' => 'Sao Tome and Principe', + 'SA' => 'Saudi Arabia', + 'SN' => 'Senegal', + 'RS' => 'Serbia', + 'SC' => 'Seychelles', + 'SL' => 'Sierra Leone', + 'SG' => 'Singapore', + 'SX' => 'Sint Maarten (Dutch part)', + 'SK' => 'Slovakia', + 'SI' => 'Slovenia', + 'SB' => 'Solomon Islands', + 'SO' => 'Somalia', + 'ZA' => 'South Africa', + 'GS' => 'South Georgia and the South Sandwich Islands', + 'SS' => 'South Sudan', + 'LK' => 'Sri Lanka', + 'SH' => 'St. Helena', + 'PM' => 'St. Pierre and Miquelon', + 'SD' => 'Sudan', + 'SR' => 'Suriname', + 'SJ' => 'Svalbard and Jan Mayen', + 'SZ' => 'Swaziland', + 'CH' => 'Switzerland', + 'SY' => 'Syrian Arab Republic', + 'TW' => 'Taiwan, Province of China', + 'TJ' => 'Tajikistan', + 'TZ' => 'Tanzania, United Republic of', + 'TH' => 'Thailand', + 'TL' => 'Timor-Leste', + 'TG' => 'Togo', + 'TK' => 'Tokelau', + 'TO' => 'Tonga', + 'TT' => 'Trinidad and Tobago', + 'TN' => 'Tunisia', + 'TR' => 'Turkey', + 'TM' => 'Turkmenistan', + 'TC' => 'Turks and Caicos Islands', + 'TV' => 'Tuvalu', + 'UG' => 'Uganda', + 'UA' => 'Ukraine', + 'AE' => 'United Arab Emirates', + 'UM' => 'United States Minor Outlying Islands', + 'UY' => 'Uruguay', + 'UZ' => 'Uzbekistan', + 'VU' => 'Vanuatu', + 'VA' => 'Vatican City State (Holy See)', + 'VE' => 'Venezuela', + 'VN' => 'Vietnam', + 'VG' => 'Virgin Islands (British)', + 'VI' => 'Virgin Islands (U.S.)', + 'WF' => 'Wallis and Futuna Islands', + 'EH' => 'Western Sahara', + 'YE' => 'Yemen', + 'ZM' => 'Zambia', + 'ZW' => 'Zimbabwe', ]; /** - * Attributes which are not fillable using fill() method + * Attributes which are not fillable using fill() method. */ protected $guarded = ['id']; /** - * Attributes fillable using fill() method + * Attributes fillable using fill() method. + * * @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() { @@ -439,7 +439,7 @@ public function emails() } /** - * Get customer conversations + * Get customer conversations. */ public function conversations() { @@ -447,7 +447,7 @@ public function conversations() } /** - * Get main email + * Get main email. */ public function getMainEmail() { @@ -456,23 +456,24 @@ public function getMainEmail() /** * Get customer full name. - * + * * @return string */ public function getFullName() { if ($this->first_name || $this->last_name) { - return $this->first_name . ' ' . $this->last_name; + return $this->first_name.' '.$this->last_name; } elseif ($this->emails) { return explode('@', $this->emails[0]->email)[0]; } else { return $this->id; } - } + } /** - * Set customer emails - * @param array $emails + * Set customer emails. + * + * @param array $emails */ public function syncEmails($emails) { @@ -508,7 +509,7 @@ public function syncEmails($emails) } // Create customers for deleted emails foreach ($deleted_emails as $email) { - $customer = new Customer(); + $customer = new self(); $customer->save(); $email->customer()->associate($customer); $email->save(); @@ -518,7 +519,7 @@ public function syncEmails($emails) /** * Get customers phones as array. - * + * * @return array */ public function getPhones() @@ -532,7 +533,7 @@ public function getPhones() /** * Set phones as JSON. - * + * * @param array $phones_array */ public function setPhones(array $phones_array) @@ -541,10 +542,11 @@ public function setPhones(array $phones_array) } /** - * Sanitize phones array - * - * @param array $phones_array [description] - * @return array [description] + * Sanitize phones array. + * + * @param array $phones_array [description] + * + * @return array [description] */ public static function formatPhones(array $phones_array) { @@ -552,17 +554,18 @@ public static function formatPhones(array $phones_array) foreach ($phones_array as $phone) { if (!empty($phone['value']) && !empty($phone['type']) && in_array($phone['type'], array_keys(self::$phone_types))) { $phones[] = [ - 'value' => (string)$phone['value'], - 'type' => (int)$phone['type'], + 'value' => (string) $phone['value'], + 'type' => (int) $phone['type'], ]; } } + return json_encode($phones); } /** * Get customers social profiles as array. - * + * * @return array */ public function getSocialProfiles() @@ -576,7 +579,7 @@ public function getSocialProfiles() /** * Get customers social profiles as array. - * + * * @return array */ public function getWebsites($dummy_if_empty = false) @@ -591,18 +594,19 @@ public function getWebsites($dummy_if_empty = false) } /** - * Set websites as JSON + * Set websites as JSON. + * * @param array $websites_array */ public function setWebsites(array $websites_array) { $websites = []; 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)) { $value = 'http://'.$value; } - $websites[] = (string)$value; + $websites[] = (string) $value; } $this->websites = json_encode($websites); } diff --git a/app/Email.php b/app/Email.php index b0fc886d7..f8fa2d5a4 100644 --- a/app/Email.php +++ b/app/Email.php @@ -6,22 +6,22 @@ class Email extends Model { - /** - * Email types - */ - const TYPE_WORK = 'work'; - const TYPE_HOME = 'home'; - const TYPE_OTHER = 'other'; + /** + * Email types. + */ + const TYPE_WORK = 'work'; + const TYPE_HOME = 'home'; + const TYPE_OTHER = 'other'; public $timestamps = false; /** - * Attributes which are not fillable using fill() method + * Attributes which are not fillable using fill() method. */ protected $guarded = ['id', 'customer_id']; /** - * Get email's customer + * Get email's customer. */ public function customer() { @@ -29,9 +29,11 @@ public function customer() } /** - * Sanatize email address - * @param string $email - * @return string + * Sanatize email address. + * + * @param string $email + * + * @return string */ public static function sanatizeEmail($email) { diff --git a/app/Events/Event.php b/app/Events/Event.php index aa872ece8..ae8f6e99c 100644 --- a/app/Events/Event.php +++ b/app/Events/Event.php @@ -3,12 +3,10 @@ namespace App\Events; use Illuminate\Broadcasting\Channel; -use Illuminate\Queue\SerializesModels; +use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PrivateChannel; -use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Foundation\Events\Dispatchable; -use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Contracts\Broadcasting\ShouldBroadcast; +use Illuminate\Queue\SerializesModels; class Event { diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 7e2563a8c..7d3f5c726 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -31,7 +31,8 @@ class Handler extends ExceptionHandler * * This is a great spot to send exceptions to Sentry, Bugsnag, etc. * - * @param \Exception $exception + * @param \Exception $exception + * * @return void */ public function report(Exception $exception) @@ -42,8 +43,9 @@ public function report(Exception $exception) /** * Render an exception into an HTTP response. * - * @param \Illuminate\Http\Request $request - * @param \Exception $exception + * @param \Illuminate\Http\Request $request + * @param \Exception $exception + * * @return \Illuminate\Http\Response */ public function render($request, Exception $exception) diff --git a/app/Folder.php b/app/Folder.php index 1c90f9254..ef9c74e34 100644 --- a/app/Folder.php +++ b/app/Folder.php @@ -3,12 +3,11 @@ namespace App; use Illuminate\Database\Eloquent\Model; -use App\MailboxUser; class Folder extends Model { /** - * Folders types (ids from HelpScout interface) + * Folders types (ids from HelpScout interface). */ const TYPE_UNASSIGNED = 1; // User specific @@ -23,27 +22,27 @@ class Folder extends Model public static $types = [ self::TYPE_UNASSIGNED => 'Unassigned', - self::TYPE_MINE => 'Mine', - self::TYPE_DRAFTS => 'Drafts', - self::TYPE_ASSIGNED => 'Assigned', - self::TYPE_CLOSED => 'Closed', - self::TYPE_SPAM => 'Spam', - self::TYPE_DELETED => 'Deleted', - self::TYPE_STARRED => 'Starred', + self::TYPE_MINE => 'Mine', + self::TYPE_DRAFTS => 'Drafts', + self::TYPE_ASSIGNED => 'Assigned', + self::TYPE_CLOSED => 'Closed', + self::TYPE_SPAM => 'Spam', + self::TYPE_DELETED => 'Deleted', + self::TYPE_STARRED => 'Starred', ]; /** - * https://glyphicons.bootstrapcheatsheets.com/ + * https://glyphicons.bootstrapcheatsheets.com/. */ public static $type_icons = [ self::TYPE_UNASSIGNED => 'folder-open', - self::TYPE_MINE => 'hand-right', - self::TYPE_DRAFTS => 'duplicate', - self::TYPE_ASSIGNED => 'user', - self::TYPE_CLOSED => 'lock', // lock - self::TYPE_SPAM => 'ban-circle', - self::TYPE_DELETED => 'trash', - self::TYPE_STARRED => 'star', + self::TYPE_MINE => 'hand-right', + self::TYPE_DRAFTS => 'duplicate', + self::TYPE_ASSIGNED => 'user', + self::TYPE_CLOSED => 'lock', // lock + self::TYPE_SPAM => 'ban-circle', + self::TYPE_DELETED => 'trash', + self::TYPE_STARRED => 'star', ]; // Public non-user specific mailbox types @@ -65,7 +64,7 @@ class Folder extends Model public $timestamps = false; /** - * Get the mailbox to which folder belongs + * Get the mailbox to which folder belongs. */ public function mailbox() { @@ -73,7 +72,7 @@ public function mailbox() } /** - * Get the user to which folder belongs + * Get the user to which folder belongs. */ public function user() { @@ -81,7 +80,7 @@ public function user() } /** - * Get starred conversations + * Get starred conversations. */ public function conversations() { diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 38dca5d42..395a00736 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -2,10 +2,10 @@ namespace App\Http\Controllers\Auth; -use App\User; use App\Http\Controllers\Controller; -use Illuminate\Support\Facades\Validator; +use App\User; use Illuminate\Foundation\Auth\RegistersUsers; +use Illuminate\Support\Facades\Validator; class RegisterController extends Controller { @@ -42,37 +42,39 @@ public function __construct() /** * Get a validator for an incoming registration request. * - * @param array $data + * @param array $data + * * @return \Illuminate\Contracts\Validation\Validator */ protected function validator(array $data) { return Validator::make($data, [ 'first_name' => 'required|string|max:255', - 'last_name' => 'required|string|max:255', - 'email' => 'required|string|email|max:191|unique:users', - 'password' => 'required|string|min:8|confirmed', + 'last_name' => 'required|string|max:255', + 'email' => 'required|string|email|max:191|unique:users', + 'password' => 'required|string|min:8|confirmed', ]); } /** * Create a new user instance after a valid registration. * - * @param array $data + * @param array $data + * * @return \App\User */ protected function create(array $data) { return User::create([ 'first_name' => $data['first_name'], - 'last_name' => $data['last_name'], - 'email' => $data['email'], - 'password' => bcrypt($data['password']), + 'last_name' => $data['last_name'], + 'email' => $data['email'], + 'password' => bcrypt($data['password']), ]); } /** - * Registration is disabled + * Registration is disabled. */ public function showRegistrationForm() { @@ -81,6 +83,5 @@ public function showRegistrationForm() public function register() { - } } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 03e02a23e..a0a2a8a34 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -2,10 +2,10 @@ namespace App\Http\Controllers; +use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Bus\DispatchesJobs; -use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; -use Illuminate\Foundation\Auth\Access\AuthorizesRequests; +use Illuminate\Routing\Controller as BaseController; class Controller extends BaseController { diff --git a/app/Http/Controllers/ConversationsController.php b/app/Http/Controllers/ConversationsController.php index 4a7d5e856..8edb2e6dc 100644 --- a/app/Http/Controllers/ConversationsController.php +++ b/app/Http/Controllers/ConversationsController.php @@ -2,8 +2,6 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; -use Validator; use App\Conversation; class ConversationsController extends Controller @@ -29,11 +27,11 @@ public function view($id) return view('conversations/view', [ 'conversation' => $conversation, - 'mailbox' => $conversation->mailbox, - 'customer' => $conversation->customer, - 'threads' => $conversation->threads, - 'folder' => $conversation->folder, - 'folders' => $conversation->mailbox->getAssesibleFolders() + 'mailbox' => $conversation->mailbox, + 'customer' => $conversation->customer, + 'threads' => $conversation->threads, + 'folder' => $conversation->folder, + 'folders' => $conversation->mailbox->getAssesibleFolders(), ]); } } diff --git a/app/Http/Controllers/CustomersController.php b/app/Http/Controllers/CustomersController.php index 0b2068b26..9f49df4ca 100644 --- a/app/Http/Controllers/CustomersController.php +++ b/app/Http/Controllers/CustomersController.php @@ -2,11 +2,9 @@ namespace App\Http\Controllers; +use App\Customer; use Illuminate\Http\Request; use Validator; -use Illuminate\Validation\Rule; -use App\Customer; -use App\Email; class CustomersController extends Controller { @@ -21,7 +19,7 @@ public function __construct() } /** - * Edit customer + * Edit customer. */ public function update($id) { @@ -42,7 +40,8 @@ public function update($id) /** * Save customer. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return \Illuminate\Http\Response */ public function updateSave($id, Request $request) @@ -51,11 +50,11 @@ public function updateSave($id, Request $request) $validator = Validator::make($request->all(), [ 'first_name' => 'nullable|string|max:255', - 'last_name' => 'nullable|string|max:255', - 'city' => 'nullable|string|max:255', - 'state' => 'nullable|string|max:255', - 'zip' => 'nullable|string|max:12', - 'country' => 'nullable|string|max:2', + 'last_name' => 'nullable|string|max:255', + 'city' => 'nullable|string|max:255', + 'state' => 'nullable|string|max:255', + 'zip' => 'nullable|string|max:12', + 'country' => 'nullable|string|max:2', ]); if ($validator->fails()) { @@ -74,11 +73,12 @@ public function updateSave($id, Request $request) $customer->syncEmails($request->emails); \Session::flash('flash_success', __('Customer saved successfully')); + return redirect()->route('customers.update', ['id' => $id]); } /** - * User mailboxes + * User mailboxes. */ public function permissions($id) { @@ -91,10 +91,10 @@ public function permissions($id) } /** - * Save user permissions - * - * @param int $id - * @param \Illuminate\Http\Request $request + * Save user permissions. + * + * @param int $id + * @param \Illuminate\Http\Request $request */ public function permissionsSave($id, Request $request) { @@ -104,13 +104,14 @@ public function permissionsSave($id, Request $request) $user->mailboxes()->sync($request->mailboxes); \Session::flash('flash_success', __('Permissions saved successfully')); + return redirect()->route('users.permissions', ['id' => $id]); } /** * View customer conversations. - * - * @param intg $id + * + * @param intg $id */ public function conversations($id) { diff --git a/app/Http/Controllers/MailboxesController.php b/app/Http/Controllers/MailboxesController.php index 1f2895c36..ea819f2ed 100644 --- a/app/Http/Controllers/MailboxesController.php +++ b/app/Http/Controllers/MailboxesController.php @@ -2,12 +2,12 @@ namespace App\Http\Controllers; +use App\Folder; +use App\Mailbox; +use App\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; use Validator; -use App\Mailbox; -use App\User; -use App\Folder; class MailboxesController extends Controller { @@ -22,7 +22,7 @@ public function __construct() } /** - * Mailboxes list + * Mailboxes list. */ public function mailboxes() { @@ -32,21 +32,21 @@ public function mailboxes() } /** - * New mailbox + * New mailbox. */ public function create() { $this->authorize('create', 'App\Mailbox'); - + $users = User::where('role', '!=', User::ROLE_ADMIN)->get(); 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) { @@ -54,7 +54,7 @@ public function createSave(Request $request) $validator = Validator::make($request->all(), [ '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()))); @@ -65,7 +65,7 @@ public function createSave(Request $request) ->withInput(); } - $mailbox = new Mailbox; + $mailbox = new Mailbox(); $mailbox->fill($request->all()); $mailbox->save(); @@ -73,11 +73,12 @@ public function createSave(Request $request) $mailbox->syncPersonalFolders($request->users); \Session::flash('flash_success', __('Mailbox created successfully')); + return redirect()->route('mailboxes.update', ['id' => $mailbox->id]); } /** - * Edit mailbox + * Edit mailbox. */ public function update($id) { @@ -90,10 +91,10 @@ public function update($id) } /** - * Save mailbox - * - * @param int $id - * @param \Illuminate\Http\Request $request + * Save mailbox. + * + * @param int $id + * @param \Illuminate\Http\Request $request */ public function updateSave($id, Request $request) { @@ -102,15 +103,15 @@ public function updateSave($id, Request $request) $this->authorize('update', $mailbox); $validator = Validator::make($request->all(), [ - 'name' => 'required|string|max:40', - 'email' => 'required|string|email|max:128|unique:mailboxes,email,'.$id, - 'aliases' => 'string|max:128', - 'from_name' => 'required|integer', + 'name' => 'required|string|max:40', + 'email' => 'required|string|email|max:128|unique:mailboxes,email,'.$id, + 'aliases' => 'string|max:128', + 'from_name' => 'required|integer', 'from_name_custom' => 'nullable|string|max:128', - 'ticket_status' => 'required|integer', - 'template' => 'required|integer', - 'ticket_assignee' => 'required|integer', - 'signature' => 'nullable|string', + 'ticket_status' => 'required|integer', + 'template' => 'required|integer', + 'ticket_assignee' => 'required|integer', + 'signature' => 'nullable|string', ]); //event(new Registered($user = $this->create($request->all()))); @@ -126,16 +127,17 @@ public function updateSave($id, Request $request) $mailbox->save(); \Session::flash('flash_success', __('Mailbox settings saved')); + return redirect()->route('mailboxes.update', ['id' => $id]); } /** - * Mailbox permissions + * Mailbox permissions. */ public function permissions($id) { $mailbox = Mailbox::findOrFail($id); - + $this->authorize('update', $mailbox); $users = User::where('role', '!=', User::ROLE_ADMIN)->get(); @@ -144,10 +146,10 @@ public function permissions($id) } /** - * Save mailbox permissions - * - * @param int $id - * @param \Illuminate\Http\Request $request + * Save mailbox permissions. + * + * @param int $id + * @param \Illuminate\Http\Request $request */ public function permissionsSave($id, Request $request) { @@ -158,11 +160,12 @@ public function permissionsSave($id, Request $request) $mailbox->syncPersonalFolders($request->users); \Session::flash('flash_success', __('Mailbox permissions saved!')); + return redirect()->route('mailboxes.permissions', ['id' => $id]); } /** - * Mailbox connection settings + * Mailbox connection settings. */ public function connectionOutgoing($id) { @@ -173,7 +176,7 @@ public function connectionOutgoing($id) } /** - * Save mailbox connection settings + * Save mailbox connection settings. */ public function connectionOutgoingSave($id, Request $request) { @@ -182,11 +185,11 @@ public function connectionOutgoingSave($id, Request $request) if ($request->out_method == Mailbox::OUT_METHOD_SMTP) { $validator = Validator::make($request->all(), [ - 'out_server' => 'required|string|max:255', - 'out_port' => 'required|integer', + 'out_server' => 'required|string|max:255', + 'out_port' => 'required|integer', 'out_username' => 'required|string|max:100', 'out_password' => 'required|string|max:255', - 'out_ssl' => 'required|integer', + 'out_ssl' => 'required|integer', ]); if ($validator->fails()) { @@ -200,11 +203,12 @@ public function connectionOutgoingSave($id, Request $request) $mailbox->save(); \Session::flash('flash_success', __('Connection settings saved!')); + return redirect()->route('mailboxes.connection', ['id' => $id]); } /** - * Mailbox incoming settings + * Mailbox incoming settings. */ public function connectionIncoming($id) { @@ -215,7 +219,7 @@ public function connectionIncoming($id) } /** - * Save mailbox connection settings + * Save mailbox connection settings. */ public function connectionIncomingSave($id, Request $request) { @@ -223,8 +227,8 @@ public function connectionIncomingSave($id, Request $request) $this->authorize('update', $mailbox); $validator = Validator::make($request->all(), [ - 'in_server' => 'required|string|max:255', - 'in_port' => 'required|integer', + 'in_server' => 'required|string|max:255', + 'in_port' => 'required|integer', 'in_username' => 'required|string|max:100', 'in_password' => 'required|string|max:255', ]); @@ -239,11 +243,12 @@ public function connectionIncomingSave($id, Request $request) $mailbox->save(); \Session::flash('flash_success', __('Connection settings saved!')); + return redirect()->route('mailboxes.connection.incoming', ['id' => $id]); } /** - * View mailbox + * View mailbox. */ public function view($id, $folder_id = null) { @@ -253,13 +258,13 @@ public function view($id, $folder_id = null) $folder = null; 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; })->first(); } // By default we display Unassigned folder if (empty($folder)) { - $folder = $folders->filter(function($item) { + $folder = $folders->filter(function ($item) { return $item->type == Folder::TYPE_UNASSIGNED; })->first(); } @@ -267,9 +272,9 @@ public function view($id, $folder_id = null) $this->authorize('view', $folder); return view('mailboxes/view', [ - 'mailbox' => $mailbox, - 'folders' => $folders, - 'folder' => $folder, + 'mailbox' => $mailbox, + 'folders' => $folders, + 'folder' => $folder, 'conversations' => $folder->conversations()->orderBy('status', 'asc')->orderBy('last_reply_at', 'desc')->get(), ]); } @@ -281,16 +286,16 @@ private function mailboxActiveWarning($mailbox) if ($mailbox) { if (Route::currentRouteName() != 'mailboxes.connection' && !$mailbox->isOutActive()) { $flashes[] = [ - 'type' => 'warning', - 'text' => __('Sending emails need to be configured for the mailbox in order to send emails to customers and support agents').' ('.__("Connection Settings » Sending Emails").')', - 'unescaped' => true + 'type' => 'warning', + 'text' => __('Sending emails need to be configured for the mailbox in order to send emails to customers and support agents').' ('.__('Connection Settings » Sending Emails').')', + 'unescaped' => true, ]; } if (Route::currentRouteName() != 'mailboxes.connection.incoming' && !$mailbox->isInActive()) { $flashes[] = [ - 'type' => 'warning', - 'text' => __('Receiving emails need to be configured for the mailbox in order to fetch emails from your support email address').' ('.__("Connection Settings » Receiving Emails").')', - 'unescaped' => true + 'type' => 'warning', + 'text' => __('Receiving emails need to be configured for the mailbox in order to fetch emails from your support email address').' ('.__('Connection Settings » Receiving Emails').')', + 'unescaped' => true, ]; } } diff --git a/app/Http/Controllers/SecureController.php b/app/Http/Controllers/SecureController.php index e20190934..b8163ff8c 100644 --- a/app/Http/Controllers/SecureController.php +++ b/app/Http/Controllers/SecureController.php @@ -2,8 +2,8 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; use App\ActivityLog; +use Illuminate\Http\Request; class SecureController extends Controller { @@ -30,16 +30,16 @@ public function dashboard() } /** - * Logs + * Logs. * * @return \Illuminate\Http\Response */ public function logs(Request $request) { - //->where('preferences->dining->meal', 'salad') - //->get(); + //->where('preferences->dining->meal', 'salad') + //->get(); $names = ActivityLog::select('log_name')->distinct()->get()->pluck('log_name'); - + $activities = []; $cols = []; $current_name = ''; @@ -53,12 +53,12 @@ public function logs(Request $request) $logs = []; foreach ($activities as $activity) { - $log = array( - 'date' => $activity->created_at, - 'user' => $activity->causer, + $log = [ + 'date' => $activity->created_at, + 'user' => $activity->causer, 'event' => $activity->getEventDescription(), - ); - $cols = array('date', 'user', 'event'); + ]; + $cols = ['date', 'user', 'event']; foreach ($activity->properties as $property_name => $property_value) { if (!is_string($property_value)) { diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index 7f4deb1de..4b5f3b363 100644 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -2,11 +2,11 @@ namespace App\Http\Controllers; +use App\Mailbox; +use App\User; use Illuminate\Http\Request; -use Validator; use Illuminate\Validation\Rule; -use App\User; -use App\Mailbox; +use Validator; class UsersController extends Controller { @@ -21,7 +21,7 @@ public function __construct() } /** - * Users list + * Users list. */ public function users() { @@ -31,7 +31,7 @@ public function users() } /** - * New user + * New user. */ public function create() { @@ -42,20 +42,20 @@ public function create() } /** - * Create new mailbox + * Create new mailbox. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request */ public function createSave(Request $request) { $this->authorize('create', 'App\User'); $rules = [ - 'role' => 'integer', + 'role' => 'integer', 'first_name' => 'required|string|max:20', - 'last_name' => 'required|string|max:30', - 'email' => 'required|string|email|max:100|unique:users', - 'role' => [ 'required', Rule::in(array_keys(User::$roles))] + 'last_name' => 'required|string|max:30', + 'email' => 'required|string|email|max:100|unique:users', + 'role' => ['required', Rule::in(array_keys(User::$roles))], ]; if (empty($request->send_invite)) { $rules['password'] = 'required|string|max:255'; @@ -68,7 +68,7 @@ public function createSave(Request $request) ->withInput(); } - $user = new User; + $user = new User(); $user->fill($request->all()); if (!empty($request->send_invite)) { @@ -86,11 +86,12 @@ public function createSave(Request $request) } \Session::flash('flash_success', __('User created successfully')); + return redirect()->route('users.profile', ['id' => $user->id]); } /** - * User profile + * User profile. */ public function profile($id) { @@ -106,7 +107,8 @@ public function profile($id) /** * Handle a registration request for the application. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return \Illuminate\Http\Response */ public function profileSave($id, Request $request) @@ -115,15 +117,15 @@ public function profileSave($id, Request $request) $this->authorize('update', $user); $validator = Validator::make($request->all(), [ - 'first_name' => 'required|string|max:20', - 'last_name' => 'required|string|max:30', - 'email' => 'required|string|email|max:100|unique:users,email,'.$id, - 'emails' => 'max:100', - 'job_title' => 'max:100', - 'phone' => 'max:60', - 'timezone' => 'required|string|max:255', + 'first_name' => 'required|string|max:20', + 'last_name' => 'required|string|max:30', + 'email' => 'required|string|email|max:100|unique:users,email,'.$id, + 'emails' => 'max:100', + 'job_title' => 'max:100', + 'phone' => 'max:60', + 'timezone' => 'required|string|max:255', '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()))); @@ -143,11 +145,12 @@ public function profileSave($id, Request $request) $user->save(); \Session::flash('flash_success', __('Profile saved successfully')); + return redirect()->route('users.profile', ['id' => $id]); } /** - * User mailboxes + * User mailboxes. */ public function permissions($id) { @@ -160,10 +163,10 @@ public function permissions($id) } /** - * Save user permissions - * - * @param int $id - * @param \Illuminate\Http\Request $request + * Save user permissions. + * + * @param int $id + * @param \Illuminate\Http\Request $request */ public function permissionsSave($id, Request $request) { @@ -174,6 +177,7 @@ public function permissionsSave($id, Request $request) $user->syncPersonalFolders($request->mailboxes); \Session::flash('flash_success', __('Permissions saved successfully')); + return redirect()->route('users.permissions', ['id' => $id]); } } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 93bf68bfe..52c70b7b4 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -51,11 +51,11 @@ class Kernel extends HttpKernel * @var array */ protected $routeMiddleware = [ - 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, + 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, - 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, - 'can' => \Illuminate\Auth\Middleware\Authorize::class, - 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, - 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, + 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, + 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, ]; } diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index e4cec9c8b..afe1c26c6 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -10,9 +10,10 @@ class RedirectIfAuthenticated /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @param string|null $guard + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @param string|null $guard + * * @return mixed */ public function handle($request, Closure $next, $guard = null) diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php index ef1c00d10..28212e060 100644 --- a/app/Http/Middleware/TrustProxies.php +++ b/app/Http/Middleware/TrustProxies.php @@ -2,8 +2,8 @@ namespace App\Http\Middleware; -use Illuminate\Http\Request; use Fideloper\Proxy\TrustProxies as Middleware; +use Illuminate\Http\Request; class TrustProxies extends Middleware { @@ -20,10 +20,10 @@ class TrustProxies extends Middleware * @var array */ protected $headers = [ - Request::HEADER_FORWARDED => 'FORWARDED', - Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR', - Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST', - Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT', + Request::HEADER_FORWARDED => 'FORWARDED', + Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR', + Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST', + Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT', Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO', ]; } diff --git a/app/Listeners/LogFailedLogin.php b/app/Listeners/LogFailedLogin.php index d3f39a7a9..27e0be536 100644 --- a/app/Listeners/LogFailedLogin.php +++ b/app/Listeners/LogFailedLogin.php @@ -3,8 +3,6 @@ namespace App\Listeners; use Illuminate\Auth\Events\Failed; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Contracts\Queue\ShouldQueue; class LogFailedLogin { @@ -21,7 +19,8 @@ public function __construct() /** * Handle the event. * - * @param Failed $event + * @param Failed $event + * * @return void */ public function handle(Failed $event) diff --git a/app/Listeners/LogLockout.php b/app/Listeners/LogLockout.php index 83420d803..6cec156ba 100644 --- a/app/Listeners/LogLockout.php +++ b/app/Listeners/LogLockout.php @@ -3,8 +3,6 @@ namespace App\Listeners; use Illuminate\Auth\Events\Lockout; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Contracts\Queue\ShouldQueue; class LogLockout { @@ -21,7 +19,8 @@ public function __construct() /** * Handle the event. * - * @param Lockout $event + * @param Lockout $event + * * @return void */ public function handle(Lockout $event) diff --git a/app/Listeners/LogPasswordReset.php b/app/Listeners/LogPasswordReset.php index 8c8790ce8..9cb72c2d5 100644 --- a/app/Listeners/LogPasswordReset.php +++ b/app/Listeners/LogPasswordReset.php @@ -3,8 +3,6 @@ namespace App\Listeners; use Illuminate\Auth\Events\PasswordReset; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Contracts\Queue\ShouldQueue; class LogPasswordReset { @@ -21,7 +19,8 @@ public function __construct() /** * Handle the event. * - * @param PasswordReset $event + * @param PasswordReset $event + * * @return void */ public function handle(PasswordReset $event) diff --git a/app/Listeners/LogRegisteredUser.php b/app/Listeners/LogRegisteredUser.php index 6e3ad022c..253a7dd5b 100644 --- a/app/Listeners/LogRegisteredUser.php +++ b/app/Listeners/LogRegisteredUser.php @@ -3,8 +3,6 @@ namespace App\Listeners; use Illuminate\Auth\Events\Registered; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Contracts\Queue\ShouldQueue; class LogRegisteredUser { @@ -21,7 +19,8 @@ public function __construct() /** * Handle the event. * - * @param Registered $event + * @param Registered $event + * * @return void */ public function handle(Registered $event) diff --git a/app/Listeners/LogSuccessfulLogin.php b/app/Listeners/LogSuccessfulLogin.php index 15615d502..f1e8cd5a0 100644 --- a/app/Listeners/LogSuccessfulLogin.php +++ b/app/Listeners/LogSuccessfulLogin.php @@ -3,8 +3,6 @@ namespace App\Listeners; use Illuminate\Auth\Events\Login; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Contracts\Queue\ShouldQueue; class LogSuccessfulLogin { @@ -21,7 +19,8 @@ public function __construct() /** * Handle the event. * - * @param Login $event + * @param Login $event + * * @return void */ public function handle(Login $event) diff --git a/app/Listeners/LogSuccessfulLogout.php b/app/Listeners/LogSuccessfulLogout.php index d2216f981..7672d663c 100644 --- a/app/Listeners/LogSuccessfulLogout.php +++ b/app/Listeners/LogSuccessfulLogout.php @@ -3,8 +3,6 @@ namespace App\Listeners; use Illuminate\Auth\Events\Logout; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Contracts\Queue\ShouldQueue; class LogSuccessfulLogout { @@ -21,7 +19,8 @@ public function __construct() /** * Handle the event. * - * @param Logout $event + * @param Logout $event + * * @return void */ public function handle(Logout $event) diff --git a/app/Mailbox.php b/app/Mailbox.php index b9686f347..323656ca0 100644 --- a/app/Mailbox.php +++ b/app/Mailbox.php @@ -7,10 +7,9 @@ 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_USER = 2; const FROM_NAME_CUSTOM = 3; @@ -23,29 +22,29 @@ class Mailbox extends Model const TICKET_STATUS_CLOSED = 3; /** - * Default Assignee + * Default Assignee. */ const TICKET_ASSIGNEE_ANYONE = 1; const TICKET_ASSIGNEE_REPLYING_UNASSIGNED = 2; const TICKET_ASSIGNEE_REPLYING = 3; /** - * Email Template + * Email Template. */ const TEMPLATE_FANCY = 1; const TEMPLATE_PLAIN = 2; /** - * Sending Emails + * Sending Emails. */ const OUT_METHOD_PHP_MAIL = 1; const OUT_METHOD_SENDMAIL = 2; const OUT_METHOD_SMTP = 3; //const OUT_METHOD_GMAIL = 3; // todo // todo: mailgun, sendgrid, mandrill, etc - + /** - * Secure Connection + * Secure Connection. */ const OUT_SSL_NONE = 1; const OUT_SSL_SSL = 2; @@ -58,23 +57,23 @@ class Mailbox extends Model const RATINGS_PLACEMENT_BELOW = 2; /** - * Attributes fillable using fill() method + * Attributes fillable using fill() method. + * * @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() { parent::boot(); - self::created(function (Mailbox $model) - { + self::created(function (Mailbox $model) { $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() { @@ -82,7 +81,7 @@ public function users() } /** - * Get mailbox conversations + * Get mailbox conversations. */ public function conversations() { @@ -90,7 +89,7 @@ public function conversations() } /** - * Get mailbox folders + * Get mailbox folders. */ public function folders() { @@ -99,8 +98,8 @@ public function folders() /** * Create personal folders for users. - * - * @param mixed $users + * + * @param mixed $users */ public function syncPersonalFolders($users) { @@ -130,7 +129,7 @@ public function syncPersonalFolders($users) continue; } foreach (Folder::$personal_types as $type) { - $folder = new Folder; + $folder = new Folder(); $folder->mailbox_id = $this->id; $folder->user_id = $user_id; $folder->type = $type; @@ -155,7 +154,7 @@ public function createAdminPersonalFolders() continue; } foreach (Folder::$personal_types as $type) { - $folder = new Folder; + $folder = new Folder(); $folder->mailbox_id = $this->id; $folder->user_id = $user_id; $folder->type = $type; @@ -205,11 +204,10 @@ public function updateFoldersCounters() { $folders = $this->folders; foreach ($folders as $folder) { - $folder->active_count = $folder->conversations() ->where('status', Conversation::STATUS_ACTIVE) ->count(); - + $folder->total_count = $folder->conversations()->count(); $folder->save(); @@ -218,18 +216,18 @@ public function updateFoldersCounters() /** * Is mailbox available for using. - * - * @return boolean + * + * @return bool */ public function isActive() { - return ($this->isInActive() && $this->isOutActive()); + return $this->isInActive() && $this->isOutActive(); } /** * Is receiving emails configured for the mailbox. - * - * @return boolean + * + * @return bool */ public function isInActive() { @@ -242,8 +240,8 @@ public function isInActive() /** * Is sending emails configured for the mailbox. - * - * @return boolean + * + * @return bool */ public function isOutActive() { diff --git a/app/MailboxUser.php b/app/MailboxUser.php index 81ef476e9..7ee9fe8bc 100644 --- a/app/MailboxUser.php +++ b/app/MailboxUser.php @@ -6,5 +6,5 @@ class MailboxUser extends Model { - protected $table = 'mailbox_user'; + protected $table = 'mailbox_user'; } diff --git a/app/Observers/ConversationObserver.php b/app/Observers/ConversationObserver.php index 630ae2e97..e87b1b95a 100644 --- a/app/Observers/ConversationObserver.php +++ b/app/Observers/ConversationObserver.php @@ -8,8 +8,8 @@ class ConversationObserver { /** * On create. - * - * @param Conversation $conversation + * + * @param Conversation $conversation */ public function created(Conversation $conversation) { @@ -18,11 +18,11 @@ public function created(Conversation $conversation) /** * On conversation delete. - * - * @param Conversation $conversation + * + * @param Conversation $conversation */ public function deleting(Conversation $conversation) { $conversation->threads()->delete(); } -} \ No newline at end of file +} diff --git a/app/Observers/MailboxObserver.php b/app/Observers/MailboxObserver.php index cc6756598..c0aa27507 100644 --- a/app/Observers/MailboxObserver.php +++ b/app/Observers/MailboxObserver.php @@ -2,22 +2,22 @@ namespace App\Observers; -use App\Mailbox; use App\Folder; -use App\Conversation; +use App\Mailbox; class MailboxObserver { /** * Listen to the Mailbox created event. * - * @param \App\Mailbox $mailbox + * @param \App\Mailbox $mailbox + * * @return void */ public function created(Mailbox $mailbox) { foreach (Folder::$public_types as $type) { - $folder = new Folder; + $folder = new Folder(); $folder->mailbox_id = $mailbox->id; $folder->type = $type; $folder->save(); @@ -29,10 +29,11 @@ public function created(Mailbox $mailbox) * Delete the following on mailbox delete: * - folders * - conversations - * - user permissions - * - * @param Mailbox $mailbox - * @return [type] [description] + * - user permissions. + * + * @param Mailbox $mailbox + * + * @return [type] [description] */ public function deleting(Mailbox $mailbox) { @@ -40,4 +41,4 @@ public function deleting(Mailbox $mailbox) $mailbox->conversations()->delete(); $mailbox->folders()->delete(); } -} \ No newline at end of file +} diff --git a/app/Observers/ThreadObserver.php b/app/Observers/ThreadObserver.php index 4752865aa..770405f67 100644 --- a/app/Observers/ThreadObserver.php +++ b/app/Observers/ThreadObserver.php @@ -8,15 +8,15 @@ class ThreadObserver { /** * Thread created. - * - * @param Thread $thread + * + * @param Thread $thread */ public function created(Thread $thread) { // Update data in 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])) { $conversation->threads_count++; } @@ -26,5 +26,4 @@ public function created(Thread $thread) $conversation->last_reply_at = $now; $conversation->save(); } - -} \ No newline at end of file +} diff --git a/app/Observers/UserObserver.php b/app/Observers/UserObserver.php index e8b883341..c313573c1 100644 --- a/app/Observers/UserObserver.php +++ b/app/Observers/UserObserver.php @@ -8,12 +8,13 @@ class UserObserver { /** * On user delete. - * - * @param Conversation $mailbox - * @return [type] [description] + * + * @param Conversation $mailbox + * + * @return [type] [description] */ public function deleting(User $user) { $user->folders()->delete(); } -} \ No newline at end of file +} diff --git a/app/Policies/ConversationPolicy.php b/app/Policies/ConversationPolicy.php index e5abde796..f16383da4 100644 --- a/app/Policies/ConversationPolicy.php +++ b/app/Policies/ConversationPolicy.php @@ -2,8 +2,8 @@ namespace App\Policies; -use App\User; use App\Conversation; +use App\User; use Illuminate\Auth\Access\HandlesAuthorization; class ConversationPolicy @@ -13,8 +13,9 @@ class ConversationPolicy /** * Determine whether the user can view the conversation. * - * @param \App\User $user - * @param \App\Conversation $conversation + * @param \App\User $user + * @param \App\Conversation $conversation + * * @return bool */ public function view(User $user, Conversation $conversation) diff --git a/app/Policies/FolderPolicy.php b/app/Policies/FolderPolicy.php index 0d03450b1..4ec194e33 100644 --- a/app/Policies/FolderPolicy.php +++ b/app/Policies/FolderPolicy.php @@ -2,8 +2,8 @@ namespace App\Policies; -use App\User; use App\Folder; +use App\User; use Illuminate\Auth\Access\HandlesAuthorization; class FolderPolicy @@ -13,8 +13,9 @@ class FolderPolicy /** * Determine whether the user can view the folder. * - * @param \App\User $user - * @param \App\Folder $folder + * @param \App\User $user + * @param \App\Folder $folder + * * @return bool */ public function view(User $user, Folder $folder) diff --git a/app/Policies/MailboxPolicy.php b/app/Policies/MailboxPolicy.php index 159584743..0d6076123 100644 --- a/app/Policies/MailboxPolicy.php +++ b/app/Policies/MailboxPolicy.php @@ -2,8 +2,8 @@ namespace App\Policies; -use App\User; use App\Mailbox; +use App\User; use Illuminate\Auth\Access\HandlesAuthorization; class MailboxPolicy @@ -13,7 +13,8 @@ class MailboxPolicy /** * Determine whether the user can create mailboxes. * - * @param \App\User $user + * @param \App\User $user + * * @return mixed */ public function create(User $user) @@ -28,8 +29,9 @@ public function create(User $user) /** * Determine whether the user can update the mailbox. * - * @param \App\User $user - * @param \App\Mailbox $mailbox + * @param \App\User $user + * @param \App\Mailbox $mailbox + * * @return mixed */ public function update(User $user, Mailbox $mailbox) @@ -44,8 +46,9 @@ public function update(User $user, Mailbox $mailbox) /** * Determine whether the user can delete the mailbox. * - * @param \App\User $user - * @param \App\Mailbox $mailbox + * @param \App\User $user + * @param \App\Mailbox $mailbox + * * @return mixed */ public function delete(User $user, Mailbox $mailbox) diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php index 766764840..a2223f9dc 100644 --- a/app/Policies/UserPolicy.php +++ b/app/Policies/UserPolicy.php @@ -12,8 +12,9 @@ class UserPolicy /** * Determine whether the user can view the model. * - * @param \App\User $user - * @param \App\User $model + * @param \App\User $user + * @param \App\User $model + * * @return mixed */ public function view(User $user, User $model) @@ -28,7 +29,8 @@ public function view(User $user, User $model) /** * Determine whether the user can create models. * - * @param \App\User $user + * @param \App\User $user + * * @return mixed */ public function create(User $user) @@ -43,8 +45,9 @@ public function create(User $user) /** * Determine whether the user can update the model. * - * @param \App\User $user - * @param \App\User $model + * @param \App\User $user + * @param \App\User $model + * * @return mixed */ public function update(User $user, User $model) @@ -59,8 +62,9 @@ public function update(User $user, User $model) /** * Determine whether the user can delete the model. * - * @param \App\User $user - * @param \App\User $model + * @param \App\User $user + * @param \App\User $model + * * @return mixed */ public function delete(User $user, User $model) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index b1cb29eac..40f1e5744 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,8 +2,8 @@ namespace App\Providers; -use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Schema; +use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 720dbb81c..091a30a39 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -2,7 +2,6 @@ namespace App\Providers; -use Illuminate\Support\Facades\Gate; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; class AuthServiceProvider extends ServiceProvider @@ -13,9 +12,9 @@ class AuthServiceProvider extends ServiceProvider * @var array */ protected $policies = [ - 'App\User' => 'App\Policies\UserPolicy', - 'App\Mailbox' => 'App\Policies\MailboxPolicy', - 'App\Folder' => 'App\Policies\FolderPolicy', + 'App\User' => 'App\Policies\UserPolicy', + 'App\Mailbox' => 'App\Policies\MailboxPolicy', + 'App\Folder' => 'App\Policies\FolderPolicy', 'App\Conversation' => 'App\Policies\ConversationPolicy', ]; diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index 352cce44a..395c518bc 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -2,8 +2,8 @@ namespace App\Providers; -use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Broadcast; +use Illuminate\Support\ServiceProvider; class BroadcastServiceProvider extends ServiceProvider { diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 99ab883ae..7178f5d33 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -2,8 +2,8 @@ namespace App\Providers; -use Illuminate\Support\Facades\Event; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Event; class EventServiceProvider extends ServiceProvider { @@ -16,7 +16,7 @@ class EventServiceProvider extends ServiceProvider 'Illuminate\Auth\Events\Registered' => [ 'App\Listeners\LogRegisteredUser', ], - + 'Illuminate\Auth\Events\Login' => [ 'App\Listeners\LogSuccessfulLogin', ], diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 129dca87f..e24262ea0 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -2,8 +2,8 @@ namespace App\Providers; -use Illuminate\Support\Facades\Route; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider { diff --git a/app/Thread.php b/app/Thread.php index efc16a945..bf4e0792a 100644 --- a/app/Thread.php +++ b/app/Thread.php @@ -7,18 +7,18 @@ class Thread extends Model { /** - * By whom action performed (source_via) + * By whom action performed (source_via). */ const PERSON_CUSTOMER = 1; const PERSON_USER = 2; - - public static $persons = array( + + public static $persons = [ self::PERSON_CUSTOMER => 'customer', - self::PERSON_USER => 'user', - ); + self::PERSON_USER => 'user', + ]; /** - * Thread types + * Thread types. */ // Email from customer const TYPE_CUSTOMER = 1; @@ -35,23 +35,23 @@ class Thread extends Model public static $types = [ // Thread by customer - self::TYPE_CUSTOMER => 'customer', + self::TYPE_CUSTOMER => 'customer', // Thread by user - self::TYPE_MESSAGE => 'message', - self::TYPE_NOTE => 'note', + self::TYPE_MESSAGE => 'message', + 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. - self::TYPE_LINEITEM => 'lineitem', - self::TYPE_PHONE => 'phone', + self::TYPE_LINEITEM => 'lineitem', + self::TYPE_PHONE => 'phone', // 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. - self::TYPE_FORWARDPARENT => 'forwardparent', + self::TYPE_FORWARDPARENT => 'forwardparent', // forwardchild is the type set on the first thread of the new forwarded conversation. - self::TYPE_FORWARDCHILD => 'forwardchild', - self::TYPE_CHAT => 'chat', + self::TYPE_FORWARDCHILD => 'forwardchild', + self::TYPE_CHAT => 'chat', ]; /** - * Statuses + * Statuses. */ const STATUS_ACTIVE = 1; const STATUS_CLOSED = 2; @@ -59,31 +59,31 @@ class Thread extends Model const STATUS_PENDING = 4; const STATUS_SPAM = 5; - public static $statuses = array( - self::STATUS_ACTIVE => 'active', - self::STATUS_CLOSED => 'closed', - self::STATUS_NOCHANGE => 'nochange', - self::STATUS_PENDING => 'pending', - self::STATUS_SPAM => 'spam', - ); + public static $statuses = [ + self::STATUS_ACTIVE => 'active', + self::STATUS_CLOSED => 'closed', + self::STATUS_NOCHANGE => 'nochange', + self::STATUS_PENDING => 'pending', + self::STATUS_SPAM => 'spam', + ]; /** - * States + * States. */ const STATE_DRAFT = 1; const STATE_PUBLISHED = 2; const STATE_HIDDEN = 3; const STATE_REVIEW = 4; - - public static $states = array( - self::STATE_DRAFT => 'draft', - self::STATE_PUBLISHED => 'published', - self::STATE_HIDDEN => 'hidden', - self::STATE_REVIEW => 'review', - ); + + public static $states = [ + self::STATE_DRAFT => 'draft', + self::STATE_PUBLISHED => 'published', + self::STATE_HIDDEN => 'hidden', + self::STATE_REVIEW => 'review', + ]; /** - * Action associated with the line item + * Action associated with the line item. */ // The conversation was moved from another mailbox const ACTION_TYPE_MOVED_FROM_MAILBOX = 1; @@ -106,32 +106,32 @@ class Thread extends Model // Describes an optional action associated with the line item // todo: values need to be checked via HelpScout API public static $action_types = [ - self::ACTION_TYPE_MOVED_FROM_MAILBOX => 'moved-from-mailbox', - self::ACTION_TYPE_MERGED => 'merged', - self::ACTION_TYPE_IMPORTED => 'imported', - self::ACTION_TYPE_WORKFLOW_MANUAL => 'manual-workflow', - self::ACTION_TYPE_WORKFLOW_AUTO => 'automatic-workflow', - self::ACTION_TYPE_IMPORTED_EXTERNAL => 'imported-external', - self::ACTION_TYPE_CHANGED_TICKET_CUSTOMER => 'changed-ticket-customer', - self::ACTION_TYPE_DELETED_TICKET => 'deleted-ticket', - self::ACTION_TYPE_RESTORE_TICKET => 'restore-ticket', + self::ACTION_TYPE_MOVED_FROM_MAILBOX => 'moved-from-mailbox', + self::ACTION_TYPE_MERGED => 'merged', + self::ACTION_TYPE_IMPORTED => 'imported', + self::ACTION_TYPE_WORKFLOW_MANUAL => 'manual-workflow', + self::ACTION_TYPE_WORKFLOW_AUTO => 'automatic-workflow', + self::ACTION_TYPE_IMPORTED_EXTERNAL => 'imported-external', + self::ACTION_TYPE_CHANGED_TICKET_CUSTOMER => 'changed-ticket-customer', + self::ACTION_TYPE_DELETED_TICKET => 'deleted-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_WEB = 2; const SOURCE_TYPE_API = 3; - + public static $source_types = [ - self::SOURCE_TYPE_EMAIL => 'email', - self::SOURCE_TYPE_WEB => 'web', - self::SOURCE_TYPE_API => 'api', + self::SOURCE_TYPE_EMAIL => 'email', + self::SOURCE_TYPE_WEB => 'web', + 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_SENT = 2; @@ -139,7 +139,7 @@ class Thread extends Model const SEND_STATUS_DELIVERY_ERROR = 4; /** - * The user assigned to this thread (assignedTo) + * The user assigned to this thread (assignedTo). */ public function user() { @@ -147,7 +147,7 @@ public function user() } /** - * Get the thread customer + * Get the thread customer. */ public function customer() { @@ -155,7 +155,7 @@ public function customer() } /** - * Get conversation + * Get conversation. */ public function conversation() { @@ -163,7 +163,8 @@ public function conversation() } /** - * Get sanitized body HTML + * Get sanitized body HTML. + * * @return string */ public function getCleanBody() @@ -173,7 +174,7 @@ public function getCleanBody() /** * Get thread recipients. - * + * * @return array */ public function getTos() @@ -187,7 +188,7 @@ public function getTos() /** * Get thread CC recipients. - * + * * @return array */ public function getCcs() @@ -201,7 +202,7 @@ public function getCcs() /** * Get thread BCC recipients. - * + * * @return array */ public function getBccs() @@ -215,31 +216,32 @@ public function getBccs() /** * Get status name. Made as a function to allow status names translation. - * - * @param integer $status - * @return string + * + * @param int $status + * + * @return string */ public static function getStatusName($status) { switch ($status) { case self::STATUS_ACTIVE: - return __("Active"); + return __('Active'); break; case self::STATUS_PENDING: - return __("Pending"); + return __('Pending'); break; case self::STATUS_CLOSED: - return __("Closed"); + return __('Closed'); break; case self::STATUS_SPAM: - return __("Spam"); + return __('Spam'); break; case self::STATUS_NOCHANGE: - return __("Not changed"); + return __('Not changed'); break; default: diff --git a/app/User.php b/app/User.php index cc2d434fc..644f5397f 100644 --- a/app/User.php +++ b/app/User.php @@ -3,13 +3,13 @@ * User model class. * Class also responsible for dates conversion and representation. */ + namespace App; -use Illuminate\Notifications\Notifiable; +use Carbon\Carbon; use Illuminate\Foundation\Auth\User as Authenticatable; +use Illuminate\Notifications\Notifiable; use Illuminate\Support\Facades\Hash; -use App\Mailbox; -use Carbon\Carbon; class User extends Authenticatable { @@ -19,41 +19,41 @@ class User extends Authenticatable // const UPDATED_AT = 'modified_at'; /** - * Roles + * Roles. */ const ROLE_USER = 1; const ROLE_ADMIN = 2; - public static $roles = array( + public static $roles = [ self::ROLE_ADMIN => 'admin', - self::ROLE_USER => 'user' - ); + self::ROLE_USER => 'user', + ]; /** - * Types + * Types. */ const TYPE_USER = 1; const TYPE_TEAM = 2; - + /** - * Invite states + * Invite states. */ const INVITE_STATE_ACTIVATED = 0; const INVITE_STATE_NOT_INVITED = 1; const INVITE_STATE_SENT = 2; /** - * Time formats + * Time formats. */ const TIME_FORMAT_12 = 1; const TIME_FORMAT_24 = 2; - + /** * The attributes that are not mass assignable. * * @var array */ - protected $guarded = ['role']; + protected $guarded = ['role']; /** * 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] */ - 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() { @@ -79,7 +80,7 @@ public function mailboxes() } /** - * Get conversations assigned to user + * Get conversations assigned to user. */ public function conversations() { @@ -87,7 +88,7 @@ public function conversations() } /** - * User's folders + * User's folders. */ public function folders() { @@ -95,8 +96,8 @@ public function folders() } /** - * Get user role - * + * Get user role. + * * @return string */ public function getRoleName($ucfirst = false) @@ -105,30 +106,32 @@ public function getRoleName($ucfirst = false) if ($ucfirst) { $role_name = ucfirst($role_name); } + return $role_name; } /** - * Check if user is admin - * - * @return boolean + * Check if user is admin. + * + * @return bool */ 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 */ 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() { @@ -140,18 +143,22 @@ public function mailboxesCanView() } /** - * Generate random password for the user - * @param integer $length + * Generate random password for the user. + * + * @param int $length + * * @return string */ public function generatePassword($length = 8) { $this->password = Hash::make(str_random($length)); + return $this->password; } /** - * Get URL for editing user + * Get URL for editing user. + * * @return string */ public function urlEdit() @@ -161,9 +168,9 @@ public function urlEdit() /** * Create personal folders for user mailboxes. - * - * @param integer $mailbox_id - * @param mixed $users + * + * @param int $mailbox_id + * @param mixed $users */ public function syncPersonalFolders($mailboxes) { @@ -185,7 +192,7 @@ public function syncPersonalFolders($mailboxes) continue; } foreach (Folder::$personal_types as $type) { - $folder = new Folder; + $folder = new Folder(); $folder->mailbox_id = $mailbox_id; $folder->user_id = $this->id; $folder->type = $type; @@ -196,10 +203,11 @@ public function syncPersonalFolders($mailboxes) /** * Format date according to user's timezone and time format. - * - * @param Carbon $date - * @param string $format - * @return string + * + * @param Carbon $date + * @param string $format + * + * @return string */ public static function dateFormat($date, $format) { @@ -207,16 +215,16 @@ public static function dateFormat($date, $format) if ($user) { if ($user->time_format == self::TIME_FORMAT_12) { $format = strtr($format, [ - 'H' => 'h', - 'G' => 'g', - ':i' => ':ia', + 'H' => 'h', + 'G' => 'g', + ':i' => ':ia', ':ia:s' => ':i:sa', ]); } else { $format = strtr($format, [ - 'h' => 'H', - 'g' => 'G', - ':ia' => ':i', + 'h' => 'H', + 'g' => 'G', + ':ia' => ':i', ':i:sa' => ':i:s', ]); } @@ -230,8 +238,9 @@ public static function dateFormat($date, $format) /** * Convert date into human readable format. - * - * @param Carbon $date + * + * @param Carbon $date + * * @return string */ public static function dateDiffForHumans($date) @@ -242,17 +251,18 @@ public static function dateDiffForHumans($date) } if ($date->diffInSeconds(Carbon::now()) <= 60) { - return __("Just now"); + return __('Just now'); } elseif ($date->diffInDays(Carbon::now()) > 7) { // Exact date if (Carbon::now()->year == $date->year) { - return User::dateFormat($date, "M j"); + return self::dateFormat($date, 'M j'); } else { - return User::dateFormat($date, "M j, Y"); + return self::dateFormat($date, 'M j, Y'); } } else { $diff_text = $date->diffForHumans(); - $diff_text = preg_replace("/minutes?/", 'min', $diff_text); + $diff_text = preg_replace('/minutes?/', 'min', $diff_text); + return $diff_text; } } diff --git a/config/app.php b/config/app.php index e3e68bf41..98112e770 100644 --- a/config/app.php +++ b/config/app.php @@ -213,40 +213,40 @@ 'aliases' => [ - 'App' => Illuminate\Support\Facades\App::class, - 'Artisan' => Illuminate\Support\Facades\Artisan::class, - 'Auth' => Illuminate\Support\Facades\Auth::class, - 'Blade' => Illuminate\Support\Facades\Blade::class, - 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, - 'Bus' => Illuminate\Support\Facades\Bus::class, - 'Cache' => Illuminate\Support\Facades\Cache::class, - 'Config' => Illuminate\Support\Facades\Config::class, - 'Cookie' => Illuminate\Support\Facades\Cookie::class, - 'Crypt' => Illuminate\Support\Facades\Crypt::class, - 'DB' => Illuminate\Support\Facades\DB::class, - 'Eloquent' => Illuminate\Database\Eloquent\Model::class, - 'Event' => Illuminate\Support\Facades\Event::class, - 'File' => Illuminate\Support\Facades\File::class, - 'Gate' => Illuminate\Support\Facades\Gate::class, - 'Hash' => Illuminate\Support\Facades\Hash::class, - 'Lang' => Illuminate\Support\Facades\Lang::class, - 'Log' => Illuminate\Support\Facades\Log::class, - 'Mail' => Illuminate\Support\Facades\Mail::class, + 'App' => Illuminate\Support\Facades\App::class, + 'Artisan' => Illuminate\Support\Facades\Artisan::class, + 'Auth' => Illuminate\Support\Facades\Auth::class, + 'Blade' => Illuminate\Support\Facades\Blade::class, + 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, + 'Bus' => Illuminate\Support\Facades\Bus::class, + 'Cache' => Illuminate\Support\Facades\Cache::class, + 'Config' => Illuminate\Support\Facades\Config::class, + 'Cookie' => Illuminate\Support\Facades\Cookie::class, + 'Crypt' => Illuminate\Support\Facades\Crypt::class, + 'DB' => Illuminate\Support\Facades\DB::class, + 'Eloquent' => Illuminate\Database\Eloquent\Model::class, + 'Event' => Illuminate\Support\Facades\Event::class, + 'File' => Illuminate\Support\Facades\File::class, + 'Gate' => Illuminate\Support\Facades\Gate::class, + 'Hash' => Illuminate\Support\Facades\Hash::class, + 'Lang' => Illuminate\Support\Facades\Lang::class, + 'Log' => Illuminate\Support\Facades\Log::class, + 'Mail' => Illuminate\Support\Facades\Mail::class, 'Notification' => Illuminate\Support\Facades\Notification::class, - 'Password' => Illuminate\Support\Facades\Password::class, - 'Queue' => Illuminate\Support\Facades\Queue::class, - 'Redirect' => Illuminate\Support\Facades\Redirect::class, - 'Redis' => Illuminate\Support\Facades\Redis::class, - 'Request' => Illuminate\Support\Facades\Request::class, - 'Response' => Illuminate\Support\Facades\Response::class, - 'Route' => Illuminate\Support\Facades\Route::class, - 'Schema' => Illuminate\Support\Facades\Schema::class, - 'Session' => Illuminate\Support\Facades\Session::class, - 'Storage' => Illuminate\Support\Facades\Storage::class, - 'URL' => Illuminate\Support\Facades\URL::class, - 'Validator' => Illuminate\Support\Facades\Validator::class, - 'View' => Illuminate\Support\Facades\View::class, - 'Minify' => Devfactory\Minify\Facades\MinifyFacade::class, + 'Password' => Illuminate\Support\Facades\Password::class, + 'Queue' => Illuminate\Support\Facades\Queue::class, + 'Redirect' => Illuminate\Support\Facades\Redirect::class, + 'Redis' => Illuminate\Support\Facades\Redis::class, + 'Request' => Illuminate\Support\Facades\Request::class, + 'Response' => Illuminate\Support\Facades\Response::class, + 'Route' => Illuminate\Support\Facades\Route::class, + 'Schema' => Illuminate\Support\Facades\Schema::class, + 'Session' => Illuminate\Support\Facades\Session::class, + 'Storage' => Illuminate\Support\Facades\Storage::class, + 'URL' => Illuminate\Support\Facades\URL::class, + 'Validator' => Illuminate\Support\Facades\Validator::class, + 'View' => Illuminate\Support\Facades\View::class, + 'Minify' => Devfactory\Minify\Facades\MinifyFacade::class, ], ]; diff --git a/config/auth.php b/config/auth.php index 781750102..a9264b4a2 100644 --- a/config/auth.php +++ b/config/auth.php @@ -14,7 +14,7 @@ */ 'defaults' => [ - 'guard' => 'web', + 'guard' => 'web', 'passwords' => 'users', ], @@ -37,12 +37,12 @@ 'guards' => [ 'web' => [ - 'driver' => 'session', + 'driver' => 'session', 'provider' => 'users', ], 'api' => [ - 'driver' => 'token', + 'driver' => 'token', 'provider' => 'users', ], ], @@ -67,7 +67,7 @@ 'providers' => [ 'users' => [ 'driver' => 'eloquent', - 'model' => App\User::class, + 'model' => App\User::class, ], // 'users' => [ @@ -94,8 +94,8 @@ 'passwords' => [ 'users' => [ 'provider' => 'users', - 'table' => 'password_resets', - 'expire' => 60, + 'table' => 'password_resets', + 'expire' => 60, ], ], diff --git a/config/broadcasting.php b/config/broadcasting.php index 3ca45eaa8..1e0044fed 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -31,18 +31,18 @@ 'connections' => [ 'pusher' => [ - 'driver' => 'pusher', - 'key' => env('PUSHER_APP_KEY'), - 'secret' => env('PUSHER_APP_SECRET'), - 'app_id' => env('PUSHER_APP_ID'), + 'driver' => 'pusher', + 'key' => env('PUSHER_APP_KEY'), + 'secret' => env('PUSHER_APP_SECRET'), + 'app_id' => env('PUSHER_APP_ID'), 'options' => [ - 'cluster' => env('PUSHER_APP_CLUSTER'), + 'cluster' => env('PUSHER_APP_CLUSTER'), 'encrypted' => true, ], ], 'redis' => [ - 'driver' => 'redis', + 'driver' => 'redis', 'connection' => 'default', ], diff --git a/config/cache.php b/config/cache.php index fa12e5e4f..236e29532 100644 --- a/config/cache.php +++ b/config/cache.php @@ -39,20 +39,20 @@ ], 'database' => [ - 'driver' => 'database', - 'table' => 'cache', + 'driver' => 'database', + 'table' => 'cache', 'connection' => null, ], 'file' => [ 'driver' => 'file', - 'path' => storage_path('framework/cache/data'), + 'path' => storage_path('framework/cache/data'), ], 'memcached' => [ - 'driver' => 'memcached', + 'driver' => 'memcached', 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), - 'sasl' => [ + 'sasl' => [ env('MEMCACHED_USERNAME'), env('MEMCACHED_PASSWORD'), ], @@ -61,15 +61,15 @@ ], 'servers' => [ [ - 'host' => env('MEMCACHED_HOST', '127.0.0.1'), - 'port' => env('MEMCACHED_PORT', 11211), + 'host' => env('MEMCACHED_HOST', '127.0.0.1'), + 'port' => env('MEMCACHED_PORT', 11211), 'weight' => 100, ], ], ], 'redis' => [ - 'driver' => 'redis', + 'driver' => 'redis', 'connection' => 'default', ], diff --git a/config/database.php b/config/database.php index a0dcaea2f..a60b4eb0a 100644 --- a/config/database.php +++ b/config/database.php @@ -34,24 +34,24 @@ 'connections' => [ 'sqlite' => [ - 'driver' => 'sqlite', + 'driver' => 'sqlite', 'database' => env('DB_DATABASE', database_path('database.sqlite')), - 'prefix' => '', + 'prefix' => '', ], 'mysql' => [ - 'driver' => 'mysql', - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '3306'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), + 'driver' => 'mysql', + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => '', - 'strict' => true, - 'engine' => null, + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', + 'strict' => true, + 'engine' => null, ], 'testing' => [ @@ -67,27 +67,27 @@ ], 'pgsql' => [ - 'driver' => 'pgsql', - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '5432'), + 'driver' => 'pgsql', + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '5432'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', - 'schema' => 'public', - 'sslmode' => 'prefer', + 'charset' => 'utf8', + 'prefix' => '', + 'schema' => 'public', + 'sslmode' => 'prefer', ], 'sqlsrv' => [ - 'driver' => 'sqlsrv', - 'host' => env('DB_HOST', 'localhost'), - 'port' => env('DB_PORT', '1433'), + 'driver' => 'sqlsrv', + 'host' => env('DB_HOST', 'localhost'), + 'port' => env('DB_PORT', '1433'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', + 'charset' => 'utf8', + 'prefix' => '', ], ], @@ -121,9 +121,9 @@ 'client' => 'predis', 'default' => [ - 'host' => env('REDIS_HOST', '127.0.0.1'), + 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), - 'port' => env('REDIS_PORT', 6379), + 'port' => env('REDIS_PORT', 6379), 'database' => 0, ], diff --git a/config/filesystems.php b/config/filesystems.php index 9568e02f0..6b70115c1 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -45,19 +45,19 @@ 'local' => [ 'driver' => 'local', - 'root' => storage_path('app'), + 'root' => storage_path('app'), ], 'public' => [ - 'driver' => 'local', - 'root' => storage_path('app/public'), - 'url' => env('APP_URL').'/storage', + 'driver' => 'local', + 'root' => storage_path('app/public'), + 'url' => env('APP_URL').'/storage', 'visibility' => 'public', ], 's3' => [ 'driver' => 's3', - 'key' => env('AWS_ACCESS_KEY_ID'), + 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION'), 'bucket' => env('AWS_BUCKET'), diff --git a/config/mail.php b/config/mail.php index bb92224c5..0951a33fd 100644 --- a/config/mail.php +++ b/config/mail.php @@ -57,7 +57,7 @@ 'from' => [ 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), - 'name' => env('MAIL_FROM_NAME', 'Example'), + 'name' => env('MAIL_FROM_NAME', 'Example'), ], /* diff --git a/config/minify.config.php b/config/minify.config.php index e7faa7f1f..696db34b3 100644 --- a/config/minify.config.php +++ b/config/minify.config.php @@ -1,6 +1,6 @@ array( - 'local', - ), + 'ignore_environments' => [ + 'local', + ], /* |-------------------------------------------------------------------------- @@ -41,7 +41,7 @@ */ 'css_build_path' => '/css/builds/', - 'css_url_path' => '/css/builds/', + 'css_url_path' => '/css/builds/', /* |-------------------------------------------------------------------------- @@ -56,22 +56,22 @@ */ 'js_build_path' => '/js/builds/', - 'js_url_path' => '/js/builds/', + 'js_url_path' => '/js/builds/', - /* + /* |-------------------------------------------------------------------------- | Hash modification |-------------------------------------------------------------------------- | | 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, - 'hash_salt' => '', + 'hash_salt' => '', - /* + /* |-------------------------------------------------------------------------- | Base URL |-------------------------------------------------------------------------- @@ -80,5 +80,5 @@ | value. By default if empty HTTP_HOST would be used. | */ - 'base_url' => '' -); + 'base_url' => '', +]; diff --git a/config/queue.php b/config/queue.php index 8c06fcc57..81c05467b 100644 --- a/config/queue.php +++ b/config/queue.php @@ -35,32 +35,32 @@ ], 'database' => [ - 'driver' => 'database', - 'table' => 'jobs', - 'queue' => 'default', + 'driver' => 'database', + 'table' => 'jobs', + 'queue' => 'default', 'retry_after' => 90, ], 'beanstalkd' => [ - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', 'retry_after' => 90, ], 'sqs' => [ 'driver' => 'sqs', - 'key' => env('SQS_KEY', 'your-public-key'), + 'key' => env('SQS_KEY', 'your-public-key'), 'secret' => env('SQS_SECRET', 'your-secret-key'), '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'), ], 'redis' => [ - 'driver' => 'redis', - 'connection' => 'default', - 'queue' => 'default', + 'driver' => 'redis', + 'connection' => 'default', + 'queue' => 'default', 'retry_after' => 90, ], @@ -79,7 +79,7 @@ 'failed' => [ 'database' => env('DB_CONNECTION', 'mysql'), - 'table' => 'failed_jobs', + 'table' => 'failed_jobs', ], ]; diff --git a/config/services.php b/config/services.php index 4460f0ec2..6bb095242 100644 --- a/config/services.php +++ b/config/services.php @@ -20,7 +20,7 @@ ], 'ses' => [ - 'key' => env('SES_KEY'), + 'key' => env('SES_KEY'), 'secret' => env('SES_SECRET'), 'region' => 'us-east-1', ], @@ -30,8 +30,8 @@ ], 'stripe' => [ - 'model' => App\User::class, - 'key' => env('STRIPE_KEY'), + 'model' => App\User::class, + 'key' => env('STRIPE_KEY'), 'secret' => env('STRIPE_SECRET'), ], diff --git a/database/factories/ConversationFactory.php b/database/factories/ConversationFactory.php index 0b163ee49..327e04a56 100644 --- a/database/factories/ConversationFactory.php +++ b/database/factories/ConversationFactory.php @@ -1,40 +1,40 @@ 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 [ - 'type' => $faker->randomElement([Conversation::TYPE_EMAIL, Conversation::TYPE_PHONE]), + 'type' => $faker->randomElement([Conversation::TYPE_EMAIL, Conversation::TYPE_PHONE]), 'folder_id' => $folder_id, - 'state' => $faker->randomElement(array_keys(Conversation::$states)), - 'subject' => $faker->sentence(7), + 'state' => $faker->randomElement(array_keys(Conversation::$states)), + 'subject' => $faker->sentence(7), // todo: cc and bcc must be equal to first (or last?) thread of conversation - 'cc' => json_encode([$faker->unique()->safeEmail]), - 'bcc' => json_encode([$faker->unique()->safeEmail]), - 'preview' => $faker->text(Conversation::PREVIEW_MAXLENGTH), - 'imported' => true, - 'created_by' => $created_by, - 'source_via' => Conversation::PERSON_CUSTOMER, + 'cc' => json_encode([$faker->unique()->safeEmail]), + 'bcc' => json_encode([$faker->unique()->safeEmail]), + 'preview' => $faker->text(Conversation::PREVIEW_MAXLENGTH), + 'imported' => true, + 'created_by' => $created_by, + 'source_via' => Conversation::PERSON_CUSTOMER, 'source_type' => Conversation::SOURCE_TYPE_EMAIL, ]; }); diff --git a/database/factories/CustomerFactory.php b/database/factories/CustomerFactory.php index 3c223069e..ba2aca567 100644 --- a/database/factories/CustomerFactory.php +++ b/database/factories/CustomerFactory.php @@ -1,13 +1,13 @@ define(App\Customer::class, function (Faker $faker) { return [ 'first_name' => $faker->firstName, - 'last_name' => $faker->lastName, - 'job_title' => $faker->jobTitle, - 'phones' => Customer::formatPhones([['value' => $faker->phoneNumber, 'type' => Customer::PHONE_TYPE_WORK]]) + 'last_name' => $faker->lastName, + 'job_title' => $faker->jobTitle, + 'phones' => Customer::formatPhones([['value' => $faker->phoneNumber, 'type' => Customer::PHONE_TYPE_WORK]]), ]; }); diff --git a/database/factories/FolderFactory.php b/database/factories/FolderFactory.php index c950f9c3f..ac9ca32b4 100644 --- a/database/factories/FolderFactory.php +++ b/database/factories/FolderFactory.php @@ -1,20 +1,21 @@ define(App\Folder::class, function (Faker $faker, $params) { - $mailbox_id = null; - if (!empty($params['mailbox_id'])) { - $mailbox_id = $params['mailbox_id']; - } else { - $mailbox = App\Mailbox::inRandomOrder()->first(); - if ($mailbox) { - $mailbox_id = $mailbox->id; - } - } + $mailbox_id = null; + if (!empty($params['mailbox_id'])) { + $mailbox_id = $params['mailbox_id']; + } else { + $mailbox = App\Mailbox::inRandomOrder()->first(); + if ($mailbox) { + $mailbox_id = $mailbox->id; + } + } + return [ 'mailbox_id' => $mailbox_id, - 'type' => Folder::TYPE_UNASSIGNED, + 'type' => Folder::TYPE_UNASSIGNED, ]; }); diff --git a/database/factories/MailboxFactory.php b/database/factories/MailboxFactory.php index 6762d29ff..0fed66a25 100644 --- a/database/factories/MailboxFactory.php +++ b/database/factories/MailboxFactory.php @@ -3,13 +3,14 @@ use Faker\Generator as Faker; $factory->define(App\Mailbox::class, function (Faker $faker) { - $name = $faker->company; - $email = $faker->unique()->companyEmail; - $domain = explode('@', $email)[1]; + $name = $faker->company; + $email = $faker->unique()->companyEmail; + $domain = explode('@', $email)[1]; + return [ - 'name' => $name, - 'email' => $email, - 'aliases' => 'support@'.$domain.',help@'.$domain.', contact@'.$domain, + 'name' => $name, + 'email' => $email, + 'aliases' => 'support@'.$domain.',help@'.$domain.', contact@'.$domain, 'signature' => '--
'.$name, ]; }); diff --git a/database/factories/ThreadFactory.php b/database/factories/ThreadFactory.php index 0d77d42f2..ecc180cc4 100644 --- a/database/factories/ThreadFactory.php +++ b/database/factories/ThreadFactory.php @@ -1,39 +1,39 @@ 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 [ 'type' => Thread::TYPE_CUSTOMER, //'conversation_id' => , 'customer_id' => $customer_id, - 'state' => Thread::STATE_PUBLISHED, - 'body' => $faker->text(500), - 'to' => $to, - 'cc' => json_encode([$faker->unique()->safeEmail]), - 'bcc' => json_encode([$faker->unique()->safeEmail]), - 'source_via' => Thread::PERSON_CUSTOMER, + 'state' => Thread::STATE_PUBLISHED, + 'body' => $faker->text(500), + 'to' => $to, + 'cc' => json_encode([$faker->unique()->safeEmail]), + 'bcc' => json_encode([$faker->unique()->safeEmail]), + 'source_via' => Thread::PERSON_CUSTOMER, 'source_type' => Thread::SOURCE_TYPE_EMAIL, - 'created_by' => $customer_id, + 'created_by' => $customer_id, ]; }); diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index d30b301d3..2c3aaf878 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -15,12 +15,12 @@ $factory->define(App\User::class, function (Faker $faker) { return [ - 'first_name' => $faker->firstName, - 'last_name' => $faker->lastName, - 'email' => $faker->unique()->safeEmail, - 'job_title' => $faker->jobTitle, - 'phone' => $faker->phoneNumber, - 'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret + 'first_name' => $faker->firstName, + 'last_name' => $faker->lastName, + 'email' => $faker->unique()->safeEmail, + 'job_title' => $faker->jobTitle, + 'phone' => $faker->phoneNumber, + 'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret 'remember_token' => str_random(10), ]; }); diff --git a/database/migrations/2018_06_10_000000_create_users_table.php b/database/migrations/2018_06_10_000000_create_users_table.php index e6d22d1b2..56ad27942 100644 --- a/database/migrations/2018_06_10_000000_create_users_table.php +++ b/database/migrations/2018_06_10_000000_create_users_table.php @@ -1,9 +1,9 @@ text('cc')->nullable(); // JSON $table->text('bcc')->nullable(); // JSON $table->string('preview', Conversation::PREVIEW_MAXLENGTH); - // The imported field enables conversation to be created for historical purposes - // (i.e. if moving from a different platform, you can import your history). + // The imported field enables conversation to be created for historical purposes + // (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. $table->boolean('imported')->default(false); $table->boolean('has_attachments')->default(false); diff --git a/database/migrations/2018_07_11_074558_create_folders_table.php b/database/migrations/2018_07_11_074558_create_folders_table.php index 58e1d90f7..6de6e7b57 100644 --- a/database/migrations/2018_07_11_074558_create_folders_table.php +++ b/database/migrations/2018_07_11_074558_create_folders_table.php @@ -1,8 +1,8 @@ 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()); + }); } } diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 4a51d0bbf..57389fb28 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -1,7 +1,7 @@ create(); $m->users()->save($user); - for ($i=0; $i < 7; $i++) { - + for ($i = 0; $i < 7; $i++) { $customer = factory(App\Customer::class)->create(); - + $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])]); diff --git a/database/seeds/MailboxesTableSeeder.php b/database/seeds/MailboxesTableSeeder.php index db2dc821c..f2a5f8c25 100644 --- a/database/seeds/MailboxesTableSeeder.php +++ b/database/seeds/MailboxesTableSeeder.php @@ -11,6 +11,6 @@ class MailboxesTableSeeder extends Seeder */ public function run() { - factory(App\Mailbox::class, 3)->create(); + factory(App\Mailbox::class, 3)->create(); } } diff --git a/public/index.php b/public/index.php index 4584cbcd6..2b5641b4c 100644 --- a/public/index.php +++ b/public/index.php @@ -1,12 +1,10 @@ */ - define('LARAVEL_START', microtime(true)); /* diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php index e5506df29..6ef1a7330 100644 --- a/resources/lang/en/auth.php +++ b/resources/lang/en/auth.php @@ -13,7 +13,7 @@ | */ - '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.', ]; diff --git a/resources/lang/en/pagination.php b/resources/lang/en/pagination.php index d48141187..fcab34b25 100644 --- a/resources/lang/en/pagination.php +++ b/resources/lang/en/pagination.php @@ -14,6 +14,6 @@ */ 'previous' => '« Previous', - 'next' => 'Next »', + 'next' => 'Next »', ]; diff --git a/resources/lang/en/passwords.php b/resources/lang/en/passwords.php index e5544d201..ffa19ba40 100644 --- a/resources/lang/en/passwords.php +++ b/resources/lang/en/passwords.php @@ -14,9 +14,9 @@ */ 'password' => 'Passwords must be at least six characters and match the confirmation.', - 'reset' => 'Your password has been reset!', - 'sent' => 'We have e-mailed your password reset link!', - 'token' => 'This password reset token is invalid.', - 'user' => "We can't find a user with that e-mail address.", + 'reset' => 'Your password has been reset!', + 'sent' => 'We have e-mailed your password reset link!', + 'token' => 'This password reset token is invalid.', + 'user' => "We can't find a user with that e-mail address.", ]; diff --git a/routes/web.php b/routes/web.php index 2842843f2..d7b45cf1b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -13,11 +13,11 @@ Auth::routes(); -# General routes for logged in users +// General routes for logged in users Route::get('/', 'SecureController@dashboard')->name('dashboard'); Route::get('/logs/{name?}', 'SecureController@logs')->name('logs'); -# Users +// Users Route::get('/users', 'UsersController@users')->name('users'); Route::get('/users/wizard', 'UsersController@create')->name('users.create'); Route::post('/users/wizard', 'UsersController@createSave'); @@ -27,7 +27,7 @@ Route::get('/users/permissions/{id}', 'UsersController@permissions')->name('users.permissions'); Route::post('/users/permissions/{id}', 'UsersController@permissionsSave'); -# Mailboxes +// Mailboxes Route::get('/settings/mailboxes', 'MailboxesController@mailboxes')->name('mailboxes'); Route::get('/settings/mailbox-new', 'MailboxesController@create')->name('mailboxes.create'); Route::post('/settings/mailbox-new', 'MailboxesController@createSave'); @@ -42,10 +42,10 @@ Route::get('/settings/connection-settings/{id}/incoming', 'MailboxesController@connectionIncoming')->name('mailboxes.connection.incoming'); Route::post('/settings/connection-settings/{id}/incoming', 'MailboxesController@connectionIncomingSave'); -# Customers +// Customers Route::get('/customer/{id}/edit', 'CustomersController@update')->name('customers.update'); Route::post('/customer/{id}/edit', 'CustomersController@updateSave'); Route::get('/customer/{id}/', 'CustomersController@conversations')->name('customers.conversations'); -# Conversations -Route::get('/conversation/{id}', 'ConversationsController@view')->name('conversations.view'); \ No newline at end of file +// Conversations +Route::get('/conversation/{id}', 'ConversationsController@view')->name('conversations.view'); diff --git a/server.php b/server.php index 5fb6379e7..20bc389f0 100644 --- a/server.php +++ b/server.php @@ -1,12 +1,10 @@ */ - $uri = urldecode( parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ); diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php index df7814bb3..4a7b288da 100644 --- a/tests/CreatesApplication.php +++ b/tests/CreatesApplication.php @@ -2,8 +2,8 @@ namespace Tests; -use Illuminate\Support\Facades\Hash; use Illuminate\Contracts\Console\Kernel; +use Illuminate\Support\Facades\Hash; trait CreatesApplication { diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php index e9fe19c66..06ece2c2c 100644 --- a/tests/Unit/ExampleTest.php +++ b/tests/Unit/ExampleTest.php @@ -3,7 +3,6 @@ namespace Tests\Unit; use Tests\TestCase; -use Illuminate\Foundation\Testing\RefreshDatabase; class ExampleTest extends TestCase {