From a2172f08518cb27bb2c3dd3855e5abc2a26e8501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Freyd?= Date: Wed, 26 Jul 2017 21:02:55 -0400 Subject: [PATCH] Add style CI (#503) Hopefully this will result in slightly better code. --- .styleci.yml | 1 + app/Account.php | 22 ++-- app/Activity.php | 4 +- app/ActivityType.php | 1 - app/Call.php | 1 - app/Console/Commands/ImportCSV.php | 34 +++--- app/Console/Commands/ImportVCards.php | 33 +++--- app/Console/Commands/PingVersionServer.php | 13 +- app/Console/Commands/ResetTestDB.php | 2 +- app/Console/Commands/SendNotifications.php | 2 - app/Console/Commands/SetupProduction.php | 4 +- app/Console/Kernel.php | 2 +- app/Contact.php | 111 ++++++++---------- app/Debt.php | 6 +- app/Entry.php | 4 +- app/Event.php | 7 +- app/Exceptions/Handler.php | 2 +- app/Gift.php | 12 +- app/Helpers/DateHelper.php | 4 +- app/Helpers/MoneyHelper.php | 2 +- .../Controllers/Auth/RegisterController.php | 1 - .../Auth/ResetPasswordController.php | 2 +- app/Http/Controllers/Controller.php | 1 - app/Http/Controllers/DashboardController.php | 10 +- app/Http/Controllers/HomeController.php | 3 - app/Http/Controllers/JournalController.php | 6 +- .../People/ActivitiesController.php | 6 +- .../Controllers/People/CallsController.php | 11 +- .../Controllers/People/DebtController.php | 10 +- .../Controllers/People/GiftsController.php | 15 ++- .../Controllers/People/KidsController.php | 15 ++- .../Controllers/People/NotesController.php | 6 +- .../People/RemindersController.php | 10 +- .../People/SignificantOthersController.php | 12 +- .../Controllers/People/TagsController.php | 19 ++- .../Controllers/People/TasksController.php | 14 +-- app/Http/Controllers/PeopleController.php | 33 +++--- .../Settings/SubscriptionsController.php | 7 +- app/Http/Controllers/SettingsController.php | 42 +++---- app/Http/Middleware/CheckLocale.php | 2 +- app/Http/Requests/ImportsRequest.php | 2 +- .../Requests/People/ActivitiesRequest.php | 3 +- app/Http/Requests/People/CallsRequest.php | 2 +- app/Http/Requests/People/GiftsRequest.php | 2 +- app/Http/Requests/People/NotesRequest.php | 2 +- app/Http/Requests/People/RemindersRequest.php | 2 +- .../People/SignificantOthersRequest.php | 2 +- .../CountrySelectViewComposer.php | 8 +- .../CurrencySelectViewComposer.php | 8 +- app/Http/routes.php | 1 - app/ImportJob.php | 1 - app/ImportJobReport.php | 1 - app/Instance.php | 1 - app/Invitation.php | 3 - app/Jobs/AddContactFromVCard.php | 34 +++--- app/Jobs/ExportAccountAsSQL.php | 44 ++++--- app/Jobs/ResizeAvatars.php | 1 - app/Jobs/SendReminderEmail.php | 1 - app/Jobs/SetNextReminderDate.php | 1 - app/Kid.php | 11 +- app/Mail/InvitationSent.php | 1 - app/Mail/NewUserAlert.php | 1 - app/Mail/UserReminded.php | 1 - app/Note.php | 4 +- app/Providers/AppServiceProvider.php | 10 +- app/Providers/EventServiceProvider.php | 1 - app/Providers/RouteServiceProvider.php | 26 ++-- app/Reminder.php | 14 +-- app/SignificantOther.php | 14 +-- app/Statistic.php | 1 - app/Tag.php | 1 - app/Task.php | 11 +- app/Traits/Searchable.php | 10 +- app/User.php | 12 +- config/app.php | 1 + config/database.php | 14 +-- config/image.php | 6 +- config/monica.php | 2 +- database/factories/ModelFactory.php | 4 +- .../2016_08_28_122938_create_kids_table.php | 1 - ...16_08_28_215159_create_relations_table.php | 1 - ...9_06_213550_create_activity_type_table.php | 1 - .../2016_11_01_015957_add_icon_column.php | 1 - ...16_12_08_011555_remove_type_from_notes.php | 1 - .../2016_12_28_150831_change_title_column.php | 1 - .../2017_01_16_220335_migrate_old_content.php | 1 - .../2017_02_10_221525_remove_temp_fields.php | 1 - ...2017_02_10_224355_calculate_statistics.php | 3 - ..._03_162215_fix_significant_other_field.php | 2 - .../2017_05_04_002725_migrate_kids_table.php | 2 - ...05_04_164723_remove_contact_encryption.php | 14 +-- ...7_05_04_193252_alter_activity_nullable.php | 2 +- ...7_05_08_164514_remove_encryption_tasks.php | 8 +- ..._30_002239_remove_predefined_reminders.php | 4 +- .../2017_05_30_023116_create_money_table.php | 1 - ...07_173437_add_multiple_genders_choices.php | 14 +-- ...17_06_10_155349_create_currencies_data.php | 31 +++-- ...06_11_025227_remove_encryption_journal.php | 6 +- ...7_06_13_035059_remove_gifts_encryption.php | 8 +- ...2017_06_14_131803_remove_bern_timezone.php | 2 - ...1_add_zar_currency_to_currencies_table.php | 4 +- .../2017_06_17_010900_fix_contacts_table.php | 2 - .../2017_06_17_153814_refactor_user_table.php | 2 +- ...6_19_105842_add_stripe_fields_to_users.php | 1 - ...6_20_121345_add_invitations_statistics.php | 1 - ...29_211725_add_import_job_to_statistics.php | 1 - ...17_07_04_132743_add_tags_to_statistics.php | 1 - ...7_09_164312_update_bad_translation_key.php | 2 - ..._add_danish_kroner_to_currencies_table.php | 4 +- ...8_add_indian_rupee_to_currencies_table.php | 4 +- database/seeds/ActivityTypesTableSeeder.php | 1 - database/seeds/CountriesSeederTable.php | 1 - database/seeds/FakeContentTableSeeder.php | 26 ++-- public/index.php | 3 +- resources/lang/cz/passwords.php | 2 +- resources/lang/pt-br/validation.php | 2 +- resources/lang/ru/journal.php | 2 +- resources/lang/ru/mail.php | 2 +- resources/lang/ru/pagination.php | 2 +- resources/lang/ru/passwords.php | 2 +- resources/lang/ru/reminder.php | 2 +- resources/lang/ru/validation.php | 2 +- server.php | 4 +- tests/Browser/ExampleTest.php | 2 - tests/Browser/Feature/UploadVCardTest.php | 2 - tests/DuskTestCase.php | 4 +- tests/Feature/ActivityTest.php | 8 +- tests/Feature/CallTest.php | 6 +- tests/Feature/ContactTest.php | 13 +- tests/Feature/InstanceTest.php | 4 +- tests/Feature/NoteTest.php | 8 +- tests/Feature/VersionCheckTest.php | 2 +- tests/FeatureTestCase.php | 7 +- tests/Helper/DateHelperTest.php | 4 - tests/Helper/MoneyHelperTest.php | 8 +- tests/Helper/RandomHelperTest.php | 3 - tests/Unit/ActivityTest.php | 4 +- tests/Unit/ContactTest.php | 3 - tests/Unit/EntryTest.php | 2 - tests/Unit/GiftTest.php | 2 - tests/Unit/ImportVCardsTest.php | 11 +- tests/Unit/KidTest.php | 2 - tests/Unit/NoteTest.php | 3 - tests/Unit/ReminderTest.php | 2 - tests/Unit/SearchTest.php | 16 +-- tests/Unit/SignificantOtherTest.php | 2 - tests/Unit/TaskTest.php | 5 +- tests/Unit/UserTest.php | 3 - 148 files changed, 442 insertions(+), 618 deletions(-) create mode 100644 .styleci.yml diff --git a/.styleci.yml b/.styleci.yml new file mode 100644 index 00000000000..c3bb259c55f --- /dev/null +++ b/.styleci.yml @@ -0,0 +1 @@ +preset: laravel \ No newline at end of file diff --git a/app/Account.php b/app/Account.php index f6c6d8b81f8..a59705fe9bd 100644 --- a/app/Account.php +++ b/app/Account.php @@ -4,10 +4,9 @@ use DB; use Laravel\Cashier\Billable; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Relations\HasMany; -use Illuminate\Database\Eloquent\Relations\HasOne; /** * @property User $user @@ -27,7 +26,6 @@ */ class Account extends Model { - use Billable; /** @@ -36,7 +34,7 @@ class Account extends Model * @var array */ protected $fillable = [ - 'number_of_invitations_sent', 'api_key' + 'number_of_invitations_sent', 'api_key', ]; /** @@ -210,7 +208,7 @@ public function tags() } /** - * Check if the account can be downgraded, based on a set of rules + * Check if the account can be downgraded, based on a set of rules. * * @return this */ @@ -234,9 +232,9 @@ public function canDowngrade() } /** - * Check if the account is currently subscribed to a plan + * Check if the account is currently subscribed to a plan. * - * @return boolean $isSubscribed + * @return bool $isSubscribed */ public function isSubscribed() { @@ -254,7 +252,7 @@ public function isSubscribed() * This was created because Laravel Cashier doesn't know how to properly * handled the case when a user doesn't have invoices yet. This sucks balls. * - * @return boolean + * @return bool */ public function hasInvoices() { @@ -267,16 +265,16 @@ public function hasInvoices() } /** - * Get the next billing date for the account + * Get the next billing date for the account. * - * @return String $timestamp + * @return string $timestamp */ public function getNextBillingDate() { // Weird method to get the next billing date from Laravel Cashier // see https://stackoverflow.com/questions/41576568/get-next-billing-date-from-laravel-cashier - $timestamp = $this->asStripeCustomer()["subscriptions"] - ->data[0]["current_period_end"]; + $timestamp = $this->asStripeCustomer()['subscriptions'] + ->data[0]['current_period_end']; return \App\Helpers\DateHelper::getShortDate($timestamp); } diff --git a/app/Activity.php b/app/Activity.php index 354a88a0d0d..50e5acb8b11 100644 --- a/app/Activity.php +++ b/app/Activity.php @@ -2,8 +2,6 @@ namespace App; -use App\ActivityType; -use App\Helpers\DateHelper; use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -74,7 +72,7 @@ public function type() } /** - * Get the date_it_happened field according to user's timezone + * Get the date_it_happened field according to user's timezone. * * @param string $value * @return string diff --git a/app/ActivityType.php b/app/ActivityType.php index 3929a34859f..bc6d4d92047 100644 --- a/app/ActivityType.php +++ b/app/ActivityType.php @@ -2,7 +2,6 @@ namespace App; -use App\ActivityTypeGroup; use Illuminate\Database\Eloquent\Model; class ActivityType extends Model diff --git a/app/Call.php b/app/Call.php index 22823937f00..4608c8494ac 100644 --- a/app/Call.php +++ b/app/Call.php @@ -2,7 +2,6 @@ namespace App; -use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; diff --git a/app/Console/Commands/ImportCSV.php b/app/Console/Commands/ImportCSV.php index 80980718b95..5777f308c04 100644 --- a/app/Console/Commands/ImportCSV.php +++ b/app/Console/Commands/ImportCSV.php @@ -47,13 +47,15 @@ public function handle() $user = User::where('email', $this->argument('user'))->first(); } - if (!file_exists($file)) { + if (! file_exists($file)) { $this->error('You need to provide a valid file path.'); + return -1; } - if (!$user) { + if (! $user) { $this->error('You need to provide a valid User ID or email address!'); + return -1; } @@ -61,8 +63,8 @@ public function handle() $row = 0; $imported = 0; - if (($handle = fopen($file, "r")) !== FALSE) { - while (($data = fgetcsv($handle)) !== FALSE) { + if (($handle = fopen($file, 'r')) !== false) { + while (($data = fgetcsv($handle)) !== false) { $row++; // don't import the columns @@ -78,51 +80,51 @@ public function handle() continue; } - if (!empty($data[1])) { + if (! empty($data[1])) { $contact->first_name = $data[1]; // Given Name } - if (!empty($data[2])) { + if (! empty($data[2])) { $contact->middle_name = $data[2]; // Additional Name } - if (!empty($data[3])) { + if (! empty($data[3])) { $contact->last_name = $data[3]; // Family Name } - if (!empty($data[14])) { + if (! empty($data[14])) { $contact->birthdate = date('Y-m-d', strtotime($data[14])); } - if (!empty($data[28])) { + if (! empty($data[28])) { $contact->email = $data[28]; // Email 1 Value } - if (!empty($data[42])) { + if (! empty($data[42])) { $contact->phone_number = $data[42]; // Phone 1 Value } - if (!empty($data[49])) { + if (! empty($data[49])) { $contact->street = $data[49]; // address 1 street } - if (!empty($data[50])) { + if (! empty($data[50])) { $contact->city = $data[50]; // address 1 city } - if (!empty($data[52])) { + if (! empty($data[52])) { $contact->province = $data[52]; // address 1 region (state) } - if (!empty($data[53])) { + if (! empty($data[53])) { $contact->postal_code = $data[53]; // address 1 postal code (zip) 53 } - if (!empty($data[66])) { + if (! empty($data[66])) { $contact->job = $data[66]; // organization 1 name 66 } // can't have empty email if (empty($contact->email)) { - $contact->email = NULL; + $contact->email = null; } $contact->save(); diff --git a/app/Console/Commands/ImportVCards.php b/app/Console/Commands/ImportVCards.php index 95a5958b210..1f4fa6f0013 100644 --- a/app/Console/Commands/ImportVCards.php +++ b/app/Console/Commands/ImportVCards.php @@ -2,14 +2,13 @@ namespace App\Console\Commands; +use App\User; use App\Contact; use App\Country; -use App\User; +use Sabre\VObject\Reader; use Illuminate\Console\Command; -use Illuminate\Filesystem\Filesystem; use Sabre\VObject\Component\VCard; -use Sabre\VObject\Property\ICalendar\DateTime; -use Sabre\VObject\Reader; +use Illuminate\Filesystem\Filesystem; class ImportVCards extends Command { @@ -45,16 +44,17 @@ public function __construct() */ public function handle(Filesystem $filesystem) { - $path = './' . $this->argument('path'); + $path = './'.$this->argument('path'); $user = User::where('email', $this->argument('user'))->first(); - if (!$user) { + if (! $user) { $this->error('You need to provide a valid user email!'); + return; } - if (!$filesystem->exists($path) || $filesystem->extension($path) !== 'vcf') { + if (! $filesystem->exists($path) || $filesystem->extension($path) !== 'vcf') { $this->error('The provided vcard file was not found or is not valid!'); return; @@ -65,7 +65,6 @@ public function handle(Filesystem $filesystem) $this->info("We found {$matchCount} contacts in {$path}."); if ($this->confirm('Would you like to import them?', true)) { - $this->info("Importing contacts from {$path}"); $this->output->progressStart($matchCount); @@ -75,7 +74,6 @@ public function handle(Filesystem $filesystem) collect($matches[0])->map(function ($vcard) { return Reader::read($vcard); })->each(function (VCard $vcard) use ($user, $skippedContacts) { - if ($this->contactExists($vcard, $user)) { $this->output->progressAdvance(); $skippedContacts++; @@ -94,7 +92,7 @@ public function handle(Filesystem $filesystem) $contact = new Contact(); $contact->account_id = $user->account_id; - if($vcard->N && ! empty($vcard->N->getParts()[1])) { + if ($vcard->N && ! empty($vcard->N->getParts()[1])) { $contact->first_name = $this->formatValue($vcard->N->getParts()[1]); $contact->middle_name = $this->formatValue($vcard->N->getParts()[2]); $contact->last_name = $this->formatValue($vcard->N->getParts()[0]); @@ -105,14 +103,14 @@ public function handle(Filesystem $filesystem) $contact->gender = 'none'; $contact->is_birthdate_approximate = 'unknown'; - if ($vcard->BDAY && !empty((string) $vcard->BDAY)) { + if ($vcard->BDAY && ! empty((string) $vcard->BDAY)) { $contact->birthdate = new \DateTime((string) $vcard->BDAY); } $contact->email = $this->formatValue($vcard->EMAIL); $contact->phone_number = $this->formatValue($vcard->TEL); - if($vcard->ADR) { + if ($vcard->ADR) { $contact->street = $this->formatValue($vcard->ADR->getParts()[2]); $contact->city = $this->formatValue($vcard->ADR->getParts()[3]); $contact->province = $this->formatValue($vcard->ADR->getParts()[4]); @@ -142,22 +140,21 @@ public function handle(Filesystem $filesystem) $this->info("Successfully imported {$matchCount} contacts and skipped {$skippedContacts}."); } - } /** - * Formats and returns a string for the contact + * Formats and returns a string for the contact. * * @param null|string $value * @return null|string */ private function formatValue($value) { - return !empty((string) $value) ? (string) $value : null; + return ! empty((string) $value) ? (string) $value : null; } /** - * Checks whether a contact already exists for a given account + * Checks whether a contact already exists for a given account. * * @param VCard $vcard * @param User $user @@ -169,7 +166,7 @@ private function contactExists(VCard $vcard, User $user) $contact = Contact::where([ ['account_id', $user->account_id], - ['email', $email] + ['email', $email], ])->first(); return $email && $contact; @@ -182,7 +179,7 @@ private function contactExists(VCard $vcard, User $user) * @param VCard $vcard * @return bool */ - function contactHasName(VCard $vcard): bool + public function contactHasName(VCard $vcard): bool { return ! empty($vcard->N->getParts()[1]) || ! empty((string) $vcard->NICKNAME); } diff --git a/app/Console/Commands/PingVersionServer.php b/app/Console/Commands/PingVersionServer.php index 146b28f2bd1..b486205754e 100644 --- a/app/Console/Commands/PingVersionServer.php +++ b/app/Console/Commands/PingVersionServer.php @@ -2,11 +2,10 @@ namespace App\Console\Commands; -use Log; use App\Contact; use App\Instance; -use Illuminate\Console\Command; use GuzzleHttp\Client; +use Illuminate\Console\Command; class PingVersionServer extends Command { @@ -55,18 +54,18 @@ public function handle() $json = [ 'uuid' => $instance->uuid, 'version' => $instance->current_version, - 'contacts' => Contact::count() + 'contacts' => Contact::count(), ]; - $data["uuid"] = $instance->uuid; - $data["version"] = $instance->current_version; - $data["contacts"] = Contact::all()->count(); + $data['uuid'] = $instance->uuid; + $data['version'] = $instance->current_version; + $data['contacts'] = Contact::all()->count(); // Send the JSON try { $client = new Client(); $response = $client->post(config('monica.weekly_ping_server_url'), [ - 'json' => $data + 'json' => $data, ]); } catch (\GuzzleHttp\Exception\ConnectException $e) { return; diff --git a/app/Console/Commands/ResetTestDB.php b/app/Console/Commands/ResetTestDB.php index ad49469208b..b86db5be666 100644 --- a/app/Console/Commands/ResetTestDB.php +++ b/app/Console/Commands/ResetTestDB.php @@ -39,7 +39,7 @@ public function __construct() public function handle() { if (config('app.env') == 'local') { - foreach(\DB::select('SHOW TABLES') as $table) { + foreach (\DB::select('SHOW TABLES') as $table) { $table_array = get_object_vars($table); \Schema::drop($table_array[key($table_array)]); } diff --git a/app/Console/Commands/SendNotifications.php b/app/Console/Commands/SendNotifications.php index c1aabc6f3e3..c785e1dc95d 100644 --- a/app/Console/Commands/SendNotifications.php +++ b/app/Console/Commands/SendNotifications.php @@ -2,10 +2,8 @@ namespace App\Console\Commands; -use Log; use App\User; use App\Account; -use App\Contact; use App\Reminder; use Carbon\Carbon; use App\Jobs\SendReminderEmail; diff --git a/app/Console/Commands/SetupProduction.php b/app/Console/Commands/SetupProduction.php index 38fc1b54f5d..7db38621d29 100644 --- a/app/Console/Commands/SetupProduction.php +++ b/app/Console/Commands/SetupProduction.php @@ -7,7 +7,6 @@ class SetupProduction extends Command { - use ConfirmableTrait; /** @@ -47,8 +46,7 @@ public function handle() * If the .env file does not exist, then key generation * will fail. So we create one if it does not already exist. */ - if( ! file_exists('.env') ) - { + if (! file_exists('.env')) { touch('.env'); } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 914659b384f..6e596a37c38 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -20,7 +20,7 @@ class Kernel extends ConsoleKernel 'App\Console\Commands\ImportCSV', 'App\Console\Commands\SetupProduction', 'App\Console\Commands\ImportVCards', - 'App\Console\Commands\PingVersionServer' + 'App\Console\Commands\PingVersionServer', ]; /** diff --git a/app/Contact.php b/app/Contact.php index 625a025503c..2b01be77b22 100644 --- a/app/Contact.php +++ b/app/Contact.php @@ -2,17 +2,15 @@ namespace App; -use Auth; -use App\Call; use Carbon\Carbon; +use App\Traits\Searchable; use App\Helpers\DateHelper; -use Illuminate\Database\Eloquent\Relations\BelongsTo; -use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Support\Collection; +use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Storage; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Model; -use App\Traits\Searchable; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\BelongsTo; class Contact extends Model { @@ -20,7 +18,7 @@ class Contact extends Model protected $dates = [ 'birthdate', - 'last_talked_to' + 'last_talked_to', ]; // The list of columns we want the Searchable trait to use. @@ -35,7 +33,7 @@ class Contact extends Model 'province', 'food_preferencies', 'job', - 'company' + 'company', ]; // The list of columns we want the Searchable trait to select. @@ -47,7 +45,7 @@ class Contact extends Model 'has_avatar', 'avatar_file_name', 'gravatar_url', - 'default_avatar_color' + 'default_avatar_color', ]; /** @@ -215,7 +213,7 @@ public function calls() } /** - * Sort the contacts according a given criteria + * Sort the contacts according a given criteria. * @param Builder $builder * @param string $criteria * @return Builder @@ -234,11 +232,10 @@ public function scopeSortedBy(Builder $builder, $criteria) default: return $builder->orderBy('first_name', 'asc'); } - } /** - * Get user's initials + * Get user's initials. * * @return string */ @@ -261,23 +258,23 @@ public function getCompleteName($nameOrder = 'firstname_first') if ($nameOrder == 'firstname_first') { $completeName = $this->first_name; - if (!is_null($this->middle_name)) { - $completeName = $completeName . ' ' . $this->middle_name; + if (! is_null($this->middle_name)) { + $completeName = $completeName.' '.$this->middle_name; } - if (!is_null($this->last_name)) { - $completeName = $completeName . ' ' . $this->last_name; + if (! is_null($this->last_name)) { + $completeName = $completeName.' '.$this->last_name; } } else { - if (!is_null($this->last_name)) { + if (! is_null($this->last_name)) { $completeName = $this->last_name; } - if (!is_null($this->middle_name)) { - $completeName = $completeName . ' ' . $this->middle_name; + if (! is_null($this->middle_name)) { + $completeName = $completeName.' '.$this->middle_name; } - $completeName = $completeName . ' ' . $this->first_name; + $completeName = $completeName.' '.$this->first_name; } return $completeName; @@ -331,7 +328,7 @@ public function getInitials() public function getLastActivityDate($timezone) { if ($this->activities->count() === 0) { - return null; + return; } $lastActivity = $this->activities->sortByDesc('date_it_happened')->first(); @@ -349,7 +346,7 @@ public function getLastActivityDate($timezone) public function getLastCalled($timezone) { if (is_null($this->last_talked_to)) { - return null; + return; } return DateHelper::getShortDate( @@ -365,7 +362,7 @@ public function getLastCalled($timezone) public function getBirthdate() { if (is_null($this->birthdate)) { - return null; + return; } return $this->birthdate; @@ -380,7 +377,7 @@ public function getBirthdate() public function getAge() { if (is_null($this->birthdate)) { - return null; + return; } return $this->birthdate->diffInYears(Carbon::now()); @@ -394,7 +391,7 @@ public function getAge() public function getPhone() { if (is_null($this->phone_number)) { - return null; + return; } return $this->phone_number; @@ -408,7 +405,7 @@ public function getPhone() public function getJob() { if (is_null($this->job)) { - return null; + return; } return $this->job; @@ -422,14 +419,14 @@ public function getJob() public function getCompany() { if (is_null($this->company)) { - return null; + return; } return $this->company; } /** - * Returns 'true' if the birthdate is an approximation + * Returns 'true' if the birthdate is an approximation. * * @return string */ @@ -456,11 +453,11 @@ public function getPartialAddress() $address = $this->getCity(); if (is_null($address)) { - return null; + return; } - if (!is_null($this->getProvince())) { - $address = $address . ', ' . $this->getProvince(); + if (! is_null($this->getProvince())) { + $address = $address.', '.$this->getProvince(); } return $address; @@ -474,7 +471,7 @@ public function getPartialAddress() public function getStreet() { if (is_null($this->street)) { - return null; + return; } return $this->street; @@ -488,7 +485,7 @@ public function getStreet() public function getProvince() { if (is_null($this->province)) { - return null; + return; } return $this->province; @@ -502,7 +499,7 @@ public function getProvince() public function getPostalCode() { if (is_null($this->postal_code)) { - return null; + return; } return $this->postal_code; @@ -518,8 +515,6 @@ public function getCountryName() if ($this->country) { return $this->country->country; } - - return null; } /** @@ -530,7 +525,7 @@ public function getCountryName() public function getCity() { if (is_null($this->city)) { - return null; + return; } return $this->city; @@ -556,8 +551,6 @@ public function getCountryISO() if ($this->country) { return $this->country->iso; } - - return null; } /** @@ -621,7 +614,7 @@ public function getNumberOfGifts() public function getEmail() { if (is_null($this->email)) { - return null; + return; } return $this->email; @@ -635,7 +628,7 @@ public function getEmail() public function getTwitter() { if (is_null($this->twitter_profile_url)) { - return null; + return; } return $this->twitter_profile_url; @@ -649,7 +642,7 @@ public function getTwitter() public function getFacebook() { if (is_null($this->facebook_profile_url)) { - return null; + return; } return $this->facebook_profile_url; @@ -663,7 +656,7 @@ public function getFacebook() public function getLinkedin() { if (is_null($this->linkedin_profile_url)) { - return null; + return; } return $this->linkedin_profile_url; @@ -717,7 +710,7 @@ public function getKids() public function getFoodPreferencies() { if (is_null($this->food_preferencies)) { - return null; + return; } return $this->food_preferencies; @@ -793,11 +786,11 @@ public function updateName($firstName, $middleName, $lastName) $this->first_name = $firstName; - if (!is_null($middleName)) { + if (! is_null($middleName)) { $this->middle_name = $middleName; } - if (!is_null($lastName)) { + if (! is_null($lastName)) { $this->last_name = $lastName; } @@ -850,7 +843,7 @@ public function calculateActivitiesStatistics() $activityStatistic = $this->activityStatistics()->create([]); $activityStatistic->account_id = $this->account_id; $activityStatistic->year = $year; - $activityStatistic->count = $activities->count();; + $activityStatistic->count = $activities->count(); $activityStatistic->save(); }); } @@ -925,7 +918,7 @@ public function getCompletedTasks() } /** - * Returns the URL of the avatar with the given size + * Returns the URL of the avatar with the given size. * * @param int $size * @return string @@ -935,7 +928,7 @@ public function getAvatarURL($size) $original_avatar_url = Storage::disk('public')->url($this->avatar_file_name); $avatar_filename = pathinfo($original_avatar_url, PATHINFO_FILENAME); $avatar_extension = pathinfo($original_avatar_url, PATHINFO_EXTENSION); - $resized_avatar = 'avatars/' . $avatar_filename . '_' . $size . '.' . $avatar_extension; + $resized_avatar = 'avatars/'.$avatar_filename.'_'.$size.'.'.$avatar_extension; return Storage::disk('public')->url($resized_avatar); } @@ -943,28 +936,28 @@ public function getAvatarURL($size) /** * Get the gravatar, if it exits. * - * @param integer $size - * @return string|boolean + * @param int $size + * @return string|bool */ public function getGravatar($size) { if (empty($this->email)) { return false; } - $gravatar_url = "https://www.gravatar.com/avatar/" . md5(strtolower(trim($this->email))); + $gravatar_url = 'https://www.gravatar.com/avatar/'.md5(strtolower(trim($this->email))); // check if gravatar exists by appending ?d=404, returns 404 response if does not exist - $gravatarHeaders = get_headers($gravatar_url . "?d=404"); - if ($gravatarHeaders[0] == "HTTP/1.1 404 Not Found") { + $gravatarHeaders = get_headers($gravatar_url.'?d=404'); + if ($gravatarHeaders[0] == 'HTTP/1.1 404 Not Found') { return false; } - return $gravatar_url . "?s=" . $size; + return $gravatar_url.'?s='.$size; } /** - * Check if the contact has debt (by the contact or the user for this contact) + * Check if the contact has debt (by the contact or the user for this contact). * - * @return boolean + * @return bool */ public function hasDebt() { @@ -980,11 +973,11 @@ public function getDebts() } /** - * Get the list of tags as a string to populate the tags form + * Get the list of tags as a string to populate the tags form. */ public function getTagsAsString() { - $tags = array(); + $tags = []; foreach ($this->tags as $tag) { array_push($tags, $tag->name); diff --git a/app/Debt.php b/app/Debt.php index 61ccf0f85f6..d440ef89fe4 100644 --- a/app/Debt.php +++ b/app/Debt.php @@ -38,7 +38,7 @@ public function contact() } /** - * Limit results to unpaid/unreceived debt + * Limit results to unpaid/unreceived debt. * * @param Builder $query * @return Builder @@ -49,7 +49,7 @@ public function scopeInProgress(Builder $query) } /** - * Limit results to due debt + * Limit results to due debt. * * @param Builder $query * @return Builder @@ -60,7 +60,7 @@ public function scopeDue(Builder $query) } /** - * Limit results to owed debt + * Limit results to owed debt. * * @param Builder $query * @return Builder diff --git a/app/Entry.php b/app/Entry.php index 8578ff1bc24..dbb1a2d32ae 100644 --- a/app/Entry.php +++ b/app/Entry.php @@ -19,7 +19,7 @@ public function account() public function getPost() { if (is_null($this->post)) { - return null; + return; } return $this->post; @@ -28,7 +28,7 @@ public function getPost() public function getTitle() { if (is_null($this->title)) { - return null; + return; } return $this->title; diff --git a/app/Event.php b/app/Event.php index a96f80955ad..dfe40c4dee5 100644 --- a/app/Event.php +++ b/app/Event.php @@ -2,9 +2,8 @@ namespace App; -use Auth; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsTo; /** @@ -35,7 +34,7 @@ public function contact() } /** - * Limits the results to a specific object + * Limits the results to a specific object. * * @param Builder $query * @param Model $object @@ -44,7 +43,7 @@ public function contact() */ public function scopeForObject(Builder $query, Model $object, string $key = null) { - if (!$key) { + if (! $key) { $key = strtolower(class_basename($object)); } diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index ce29cc6453d..e1d5aa6c5dc 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -47,7 +47,7 @@ public function render($request, Exception $e) { // hopefully catches those pesky token expiries // and send them back to login. - if ( $e instanceof TokenMismatchException ){ + if ($e instanceof TokenMismatchException) { return redirect('login'); } diff --git a/app/Gift.php b/app/Gift.php index 193a2107a20..2b7b443e7d1 100644 --- a/app/Gift.php +++ b/app/Gift.php @@ -2,8 +2,8 @@ namespace App; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsTo; /** @@ -67,7 +67,7 @@ public function recipient() } /** - * Limit results to already offered gifts + * Limit results to already offered gifts. * * @param Builder $query * @return Builder @@ -78,7 +78,7 @@ public function scopeOffered(Builder $query) } /** - * Limit results to gifts at the idea stage + * Limit results to gifts at the idea stage. * * @param Builder $query * @return Builder @@ -90,7 +90,7 @@ public function scopeIsIdea(Builder $query) /** * Check whether the gift is meant for a particular member - * of the contact's family + * of the contact's family. * * @return bool */ @@ -100,7 +100,7 @@ public function hasParticularRecipient() } /** - * Set the recipient for the gift + * Set the recipient for the gift. * * @param SignificantOther|Kid|string $recipient * @return static @@ -123,8 +123,6 @@ public function getRecipientNameAttribute() if ($this->hasParticularRecipient()) { return $this->recipient->first_name; } - - return null; } public function getName() diff --git a/app/Helpers/DateHelper.php b/app/Helpers/DateHelper.php index 72a1d2cc9ab..f94dc958987 100644 --- a/app/Helpers/DateHelper.php +++ b/app/Helpers/DateHelper.php @@ -97,10 +97,10 @@ public static function getLocale($locale = null) } /** - * Add a given number of week/month/year to a date + * Add a given number of week/month/year to a date. * @param Carbon $date the start date * @param string $frequency week/month/year - * @param integer $number the number of week/month/year to increment to + * @param int $number the number of week/month/year to increment to */ public static function addTimeAccordingToFrequencyType(Carbon $date, $frequency, $number) { diff --git a/app/Helpers/MoneyHelper.php b/app/Helpers/MoneyHelper.php index b7c27adb2bd..76e023eecdc 100644 --- a/app/Helpers/MoneyHelper.php +++ b/app/Helpers/MoneyHelper.php @@ -34,7 +34,7 @@ public static function format($amount, Currency $currency = null) break; } - $amount = $currency->symbol . $amount; + $amount = $currency->symbol.$amount; } return (string) $amount; diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 38efe550d7e..dbb39734f0d 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -4,7 +4,6 @@ use Auth; use App\User; -use Socialite; use Validator; use App\Account; use Carbon\Carbon; diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index c1216cd10b5..637d3644d63 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -21,7 +21,7 @@ class ResetPasswordController extends Controller use ResetsPasswords; protected $redirectTo = '/dashboard'; - + /** * Create a new controller instance. * diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 50dd1583b38..03e02a23e29 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -6,7 +6,6 @@ use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; -use Illuminate\Foundation\Auth\Access\AuthorizesResources; class Controller extends BaseController { diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 8f7279458dc..7c2e267a294 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -3,16 +3,11 @@ namespace App\Http\Controllers; use Auth; -use App\Event; -use App\Task; use App\Debt; -use Validator; +use App\Event; use App\Contact; -use App\Reminder; use Carbon\Carbon; -use App\Http\Requests; use App\Helpers\DateHelper; -use Illuminate\Http\Request; class DashboardController extends Controller { @@ -54,7 +49,6 @@ public function index() return $event->contact === null; }) ->map(function (Event $event) use ($account) { - if ($event->object_type === 'significantother') { $object = $event->contact->significantOthers->where('id', $event->object_id)->first(); } elseif ($event->object_type === 'kid') { @@ -99,7 +93,7 @@ public function index() 'debt_owed' => $debt_owed, 'tasks' => $tasks, 'debts' => $debt, - 'user' => auth()->user() + 'user' => auth()->user(), ]; return view('dashboard.index', $data); diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index cb060b6f113..26d463559a7 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -2,9 +2,6 @@ namespace App\Http\Controllers; -use App\Http\Requests; -use Illuminate\Http\Request; - class HomeController extends Controller { /** diff --git a/app/Http/Controllers/JournalController.php b/app/Http/Controllers/JournalController.php index 6ae7cd1d006..c68582735b3 100644 --- a/app/Http/Controllers/JournalController.php +++ b/app/Http/Controllers/JournalController.php @@ -5,8 +5,6 @@ use Auth; use App\Entry; use Validator; -use Carbon\Carbon; -use App\Http\Requests; use Illuminate\Http\Request; class JournalController extends Controller @@ -35,7 +33,7 @@ public function add() } /** - * Saves the journal entry + * Saves the journal entry. * * @param Request $request * @return Response @@ -57,7 +55,7 @@ public function save(Request $request) $entry->post = $request->input('entry'); if ($request->input('title') != '') { - $entry->title = $request->input('title'); + $entry->title = $request->input('title'); } $entry->save(); diff --git a/app/Http/Controllers/People/ActivitiesController.php b/app/Http/Controllers/People/ActivitiesController.php index 54341d4031e..638de414493 100644 --- a/app/Http/Controllers/People/ActivitiesController.php +++ b/app/Http/Controllers/People/ActivitiesController.php @@ -56,7 +56,7 @@ public function store(ActivitiesRequest $request, Contact $contact) $contact->logEvent('activity', $activity->id, 'create'); $contact->calculateActivitiesStatistics(); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.activities_add_success')); } @@ -109,7 +109,7 @@ public function update(ActivitiesRequest $request, Contact $contact, Activity $a $contact->logEvent('activity', $activity->id, 'update'); $contact->calculateActivitiesStatistics(); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.activities_update_success')); } @@ -128,7 +128,7 @@ public function destroy(Contact $contact, Activity $activity) $contact->calculateActivitiesStatistics(); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.activities_delete_success')); } } diff --git a/app/Http/Controllers/People/CallsController.php b/app/Http/Controllers/People/CallsController.php index 3455f235ff7..f89e5084f0f 100644 --- a/app/Http/Controllers/People/CallsController.php +++ b/app/Http/Controllers/People/CallsController.php @@ -4,9 +4,8 @@ use App\Call; use App\Contact; -use Illuminate\Http\Request; -use App\Http\Requests\People\CallsRequest; use App\Http\Controllers\Controller; +use App\Http\Requests\People\CallsRequest; class CallsController extends Controller { @@ -21,11 +20,11 @@ public function store(CallsRequest $request, Contact $contact) { $call = $contact->calls()->create( $request->only([ - 'called_at' + 'called_at', ]) + [ 'content' => ($request->get('content') == '' ? null : $request->get('content')), - 'account_id' => $contact->account_id + 'account_id' => $contact->account_id, ] ); @@ -33,7 +32,7 @@ public function store(CallsRequest $request, Contact $contact) $contact->updateLastCalledInfo($call); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.calls_add_success')); } @@ -59,7 +58,7 @@ public function destroy(Contact $contact, Call $call) $contact->save(); } - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.call_delete_success')); } } diff --git a/app/Http/Controllers/People/DebtController.php b/app/Http/Controllers/People/DebtController.php index e1cc4392d54..b03c9c5f341 100644 --- a/app/Http/Controllers/People/DebtController.php +++ b/app/Http/Controllers/People/DebtController.php @@ -51,13 +51,13 @@ public function store(DebtRequest $request, Contact $contact) ]) + [ 'account_id' => $contact->account_id, - 'status' => 'inprogress' + 'status' => 'inprogress', ] ); $contact->logEvent('debt', $debt->id, 'create'); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.debt_add_success')); } @@ -105,13 +105,13 @@ public function update(DebtRequest $request, Contact $contact, Debt $debt) ]) + [ 'account_id' => $contact->account_id, - 'status' => 'inprogress' + 'status' => 'inprogress', ] ); $contact->logEvent('debt', $debt->id, 'update'); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.debt_edit_success')); } @@ -128,7 +128,7 @@ public function destroy(Contact $contact, Debt $debt) $contact->events()->forObject($debt)->get()->each->delete(); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.debt_delete_success')); } } diff --git a/app/Http/Controllers/People/GiftsController.php b/app/Http/Controllers/People/GiftsController.php index 3ec495cfd67..8a7078e7f49 100644 --- a/app/Http/Controllers/People/GiftsController.php +++ b/app/Http/Controllers/People/GiftsController.php @@ -2,11 +2,10 @@ namespace App\Http\Controllers\People; -use App\Contact; use App\Gift; -use App\Http\Requests\People\GiftsRequest; -use Illuminate\Http\Request; +use App\Contact; use App\Http\Controllers\Controller; +use App\Http\Requests\People\GiftsRequest; class GiftsController extends Controller { @@ -58,13 +57,13 @@ public function store(GiftsRequest $request, Contact $contact) ] ); - if($request->get('has_recipient')) { + if ($request->get('has_recipient')) { $gift->forRecipient($request->get('recipient'))->save(); } $contact->logEvent('gift', $gift->id, 'create'); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.gifts_add_success')); } @@ -118,13 +117,13 @@ public function update(GiftsRequest $request, Contact $contact, Gift $gift) ] ); - if($request->get('has_recipient')) { + if ($request->get('has_recipient')) { $gift->forRecipient($request->get('recipient'))->save(); } $contact->logEvent('gift', $gift->id, 'update'); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.gifts_update_success')); } @@ -141,7 +140,7 @@ public function destroy(Contact $contact, Gift $gift) $contact->events()->forObject($gift)->get()->each->delete(); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.gifts_delete_success')); } } diff --git a/app/Http/Controllers/People/KidsController.php b/app/Http/Controllers/People/KidsController.php index 435163bcef8..e88d2ff5b78 100644 --- a/app/Http/Controllers/People/KidsController.php +++ b/app/Http/Controllers/People/KidsController.php @@ -2,12 +2,11 @@ namespace App\Http\Controllers\People; -use App\Contact; -use App\Http\Requests\People\KidsRequest; use App\Kid; +use App\Contact; use App\Reminder; -use Illuminate\Http\Request; use App\Http\Controllers\Controller; +use App\Http\Requests\People\KidsRequest; class KidsController extends Controller { @@ -53,7 +52,7 @@ public function store(KidsRequest $request, Contact $contact) ]) + [ 'account_id' => $contact->account_id, - 'food_preferencies' => $request->get('food_preferences') + 'food_preferencies' => $request->get('food_preferences'), ] ); @@ -81,7 +80,7 @@ public function store(KidsRequest $request, Contact $contact) $contact->logEvent('kid', $kid->id, 'create'); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.kids_add_success')); } @@ -129,7 +128,7 @@ public function update(KidsRequest $request, Contact $contact, Kid $kid) ]) + [ 'account_id' => $contact->account_id, - 'food_preferencies' => $request->get('food_preferences') + 'food_preferencies' => $request->get('food_preferences'), ] ); @@ -167,7 +166,7 @@ public function update(KidsRequest $request, Contact $contact, Kid $kid) $contact->logEvent('kid', $kid->id, 'update'); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.kids_update_success')); } @@ -188,7 +187,7 @@ public function destroy(Contact $contact, Kid $kid) $kid->delete(); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.kids_delete_success')); } } diff --git a/app/Http/Controllers/People/NotesController.php b/app/Http/Controllers/People/NotesController.php index b0a2de1bd5e..c31b8bbd9ca 100644 --- a/app/Http/Controllers/People/NotesController.php +++ b/app/Http/Controllers/People/NotesController.php @@ -52,7 +52,7 @@ public function store(NotesRequest $request, Contact $contact) $contact->logEvent('note', $note->id, 'create'); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.notes_create_success')); } @@ -101,7 +101,7 @@ public function update(NotesRequest $request, Contact $contact, Note $note) $contact->logEvent('note', $note->id, 'update'); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.notes_update_success')); } @@ -118,7 +118,7 @@ public function destroy(Contact $contact, Note $note) $contact->events()->forObject($note)->get()->each->delete(); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.notes_delete_success')); } } diff --git a/app/Http/Controllers/People/RemindersController.php b/app/Http/Controllers/People/RemindersController.php index e12a7755973..d2adf5307cf 100644 --- a/app/Http/Controllers/People/RemindersController.php +++ b/app/Http/Controllers/People/RemindersController.php @@ -49,14 +49,14 @@ public function store(RemindersRequest $request, Contact $contact) 'description', 'frequency_type', 'next_expected_date', - 'frequency_number' + 'frequency_number', ]) + ['account_id' => $contact->account_id] ); $contact->logEvent('reminder', $reminder->id, 'create'); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.reminders_create_success')); } @@ -102,14 +102,14 @@ public function update(RemindersRequest $request, Contact $contact, Reminder $re 'next_expected_date', 'description', 'frequency_type', - 'frequency_number' + 'frequency_number', ]) + ['account_id' => $contact->account_id] ); $contact->logEvent('reminder', $reminder->id, 'update'); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.reminders_update_success')); } @@ -126,7 +126,7 @@ public function destroy(Contact $contact, Reminder $reminder) $contact->events()->forObject($reminder)->get()->each->delete(); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.reminders_delete_success')); } } diff --git a/app/Http/Controllers/People/SignificantOthersController.php b/app/Http/Controllers/People/SignificantOthersController.php index b448dbb93f5..2b7bd8b889e 100644 --- a/app/Http/Controllers/People/SignificantOthersController.php +++ b/app/Http/Controllers/People/SignificantOthersController.php @@ -81,7 +81,7 @@ public function store(SignificantOthersRequest $request, Contact $contact) $contact->logEvent('significantother', $significantOther->id, 'create'); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.significant_other_add_success')); } @@ -139,9 +139,9 @@ public function update(SignificantOthersRequest $request, Contact $contact, Sign $request->get('age') ); - if($significantOther->reminder) { + if ($significantOther->reminder) { $significantOther->update([ - 'birthday_reminder_id' => null + 'birthday_reminder_id' => null, ]); $significantOther->reminder->delete(); @@ -168,7 +168,7 @@ public function update(SignificantOthersRequest $request, Contact $contact, Sign $contact->logEvent('significantother', $significantOther->id, 'update'); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.significant_other_edit_success')); } @@ -181,7 +181,7 @@ public function update(SignificantOthersRequest $request, Contact $contact, Sign */ public function destroy(Contact $contact, SignificantOther $significantOther) { - if($significantOther->reminder) { + if ($significantOther->reminder) { $significantOther->reminder->delete(); } @@ -189,7 +189,7 @@ public function destroy(Contact $contact, SignificantOther $significantOther) $significantOther->delete(); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.significant_other_delete_success')); } } diff --git a/app/Http/Controllers/People/TagsController.php b/app/Http/Controllers/People/TagsController.php index 893235f0d94..15ab143bf05 100644 --- a/app/Http/Controllers/People/TagsController.php +++ b/app/Http/Controllers/People/TagsController.php @@ -3,8 +3,6 @@ namespace App\Http\Controllers\People; use App\Contact; -use App\Tag; -use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Http\Requests\People\TagsRequest; @@ -21,7 +19,7 @@ class TagsController extends Controller public function update(TagsRequest $request, Contact $contact) { if (auth()->user()->account_id != $contact->account_id) { - return response()->json(array('status' => 'no')); + return response()->json(['status' => 'no']); } $tags = explode(',', $request->input('tags')); @@ -29,14 +27,15 @@ public function update(TagsRequest $request, Contact $contact) // if we receive an empty string, that means all tags have been removed. if ($request->input('tags') == '') { $contact->tags()->detach(); - return response()->json(array('status' => 'no', 'tags' => '')); + + return response()->json(['status' => 'no', 'tags' => '']); } - $tagsIDs = array(); - $tagsWithIdAndSlug = array(); + $tagsIDs = []; + $tagsWithIdAndSlug = []; foreach ($tags as $tag) { $tag = auth()->user()->account->tags()->firstOrCreate([ - 'name' => $tag + 'name' => $tag, ]); $tag->name_slug = str_slug($tag->name); @@ -47,16 +46,16 @@ public function update(TagsRequest $request, Contact $contact) // this is passed back in json to JS array_push($tagsWithIdAndSlug, [ 'id' => $tag->id, - 'slug' => $tag->name_slug + 'slug' => $tag->name_slug, ]); } $contact->tags()->sync($tagsIDs); - $response = array( + $response = [ 'status' => 'yes', 'tags' => $tagsWithIdAndSlug, - ); + ]; return response()->json($response); } diff --git a/app/Http/Controllers/People/TasksController.php b/app/Http/Controllers/People/TasksController.php index 76d59ed298a..b75a7bc2f65 100644 --- a/app/Http/Controllers/People/TasksController.php +++ b/app/Http/Controllers/People/TasksController.php @@ -46,17 +46,17 @@ public function store(TasksRequest $request, Contact $contact) $task = $contact->tasks()->create( $request->only([ 'title', - 'description' + 'description', ]) + [ 'account_id' => $contact->account_id, - 'status' => 'inprogress' + 'status' => 'inprogress', ] ); $contact->logEvent('task', $task->id, 'create'); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.tasks_add_success')); } @@ -99,14 +99,14 @@ public function update(TasksRequest $request, Contact $contact, Task $task) 'title', 'status', 'description', - 'completed_at' + 'completed_at', ]) + ['account_id' => $contact->account_id] ); $contact->logEvent('task', $task->id, 'update'); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.tasks_update_success')); } @@ -122,7 +122,7 @@ public function toggle(TasksRequest $request, Contact $contact, Task $task) { $task->toggle(); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.tasks_complete_success')); } @@ -139,7 +139,7 @@ public function destroy(Contact $contact, Task $task) $contact->events()->forObject($task)->get()->each->delete(); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.tasks_delete_success')); } } diff --git a/app/Http/Controllers/PeopleController.php b/app/Http/Controllers/PeopleController.php index 457d150eb49..46aa16193ce 100644 --- a/app/Http/Controllers/PeopleController.php +++ b/app/Http/Controllers/PeopleController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers; use Auth; -use App\Note; use App\Tag; use Validator; use App\Contact; @@ -42,8 +41,8 @@ public function index(Request $request) } $contacts = $user->account->contacts()->whereHas('tags', function ($query) use ($tag) { - $query->where('id', $tag->id); - })->sortedBy($sort)->get(); + $query->where('id', $tag->id); + })->sortedBy($sort)->get(); } else { $contacts = $user->account->contacts()->sortedBy($sort)->get(); } @@ -87,7 +86,7 @@ public function store(Request $request) $contact->gender = $request->input('gender'); $contact->first_name = ucfirst($request->input('first_name')); - if (!empty($request->input('last_name'))) { + if (! empty($request->input('last_name'))) { $contact->last_name = ucfirst($request->input('last_name')); } @@ -125,7 +124,6 @@ public function show(Contact $contact) */ public function edit(Contact $contact) { - return view('people.edit') ->withContact($contact); } @@ -288,7 +286,7 @@ public function update(Request $request, Contact $contact) $contact->save(); } - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.information_edit_success')); } @@ -331,7 +329,7 @@ public function editWork(Request $request, Contact $contact) } /** - * Save the work information + * Save the work information. * * @param Request $request * @param Contact $contact @@ -349,7 +347,7 @@ public function updateWork(Request $request, Contact $contact) $contact->save(); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.work_edit_success')); } @@ -379,32 +377,33 @@ public function updateFoodPreferencies(Request $request, Contact $contact) $contact->updateFoodPreferencies($food); - return redirect('/people/' . $contact->id) + return redirect('/people/'.$contact->id) ->with('success', trans('people.food_preferencies_add_success')); } /** - * Search used in the header + * Search used in the header. * @param Request $request */ - public function search(Request $request) { + public function search(Request $request) + { $needle = $request->needle; $accountId = $request->accountId; if ($accountId != auth()->user()->account_id) { - return null; + return; } - if($needle == null) { - return null; + if ($needle == null) { + return; } - if($accountId == null) { - return null; + if ($accountId == null) { + return; } $results = Contact::search($needle, $accountId); - if(sizeof($results) !== 0) { + if (count($results) !== 0) { return $results; } else { return ['noResults' => trans('people.people_search_no_results')]; diff --git a/app/Http/Controllers/Settings/SubscriptionsController.php b/app/Http/Controllers/Settings/SubscriptionsController.php index b865f37ec2c..fc1aa88d72d 100644 --- a/app/Http/Controllers/Settings/SubscriptionsController.php +++ b/app/Http/Controllers/Settings/SubscriptionsController.php @@ -2,7 +2,6 @@ namespace App\Http\Controllers\Settings; -use App\Contact; use Illuminate\Http\Request; use App\Http\Controllers\Controller; @@ -61,7 +60,7 @@ public function downgrade() } /** - * Process the downgrade process + * Process the downgrade process. * * @return \Illuminate\Http\Response */ @@ -77,7 +76,7 @@ public function processDowngrade() } /** - * Process the upgrade payment + * Process the upgrade payment. * * @return \Illuminate\Http\Response */ @@ -96,7 +95,7 @@ public function processPayment(Request $request) } /** - * Download the invoice as PDF + * Download the invoice as PDF. * * @return \Illuminate\Http\Response */ diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index e7849ec15b4..84de0959ea5 100644 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -3,18 +3,18 @@ namespace App\Http\Controllers; use Auth; +use App\Tag; use App\User; +use App\ImportJob; use Carbon\Carbon; use App\Invitation; -use App\ImportJob; -use App\Tag; use Illuminate\Http\Request; use App\Helpers\RandomHelper; use App\Jobs\SendNewUserAlert; use App\Jobs\ExportAccountAsSQL; use App\Jobs\AddContactFromVCard; -use App\Http\Requests\ImportsRequest; use App\Jobs\SendInvitationEmail; +use App\Http\Requests\ImportsRequest; use App\Http\Requests\SettingsRequest; use Illuminate\Support\Facades\Storage; use App\Http\Requests\InvitationRequest; @@ -45,9 +45,9 @@ public function save(SettingsRequest $request) 'timezone', 'locale', 'currency_id', - 'name_order' + 'name_order', ]) + [ - 'fluid_container' => $request->get('layout') + 'fluid_container' => $request->get('layout'), ] ); @@ -56,7 +56,7 @@ public function save(SettingsRequest $request) } /** - * Delete user account + * Delete user account. * * @param Request $request * @return \Illuminate\Http\Response @@ -66,7 +66,7 @@ public function delete(Request $request) $user = $request->user(); $account = $user->account; - if($account) { + if ($account) { $account->reminders->each->forceDelete(); $account->kids->each->forceDelete(); $account->notes->each->forceDelete(); @@ -89,7 +89,7 @@ public function delete(Request $request) } /** - * Reset user account + * Reset user account. * * @param Request $request * @return \Illuminate\Http\Response @@ -99,7 +99,7 @@ public function reset(Request $request) $user = $request->user(); $account = $user->account; - if($account) { + if ($account) { $account->reminders->each->forceDelete(); $account->kids->each->forceDelete(); $account->notes->each->forceDelete(); @@ -119,7 +119,7 @@ public function reset(Request $request) } /** - * Display the export view + * Display the export view. * * @return \Illuminate\Http\Response */ @@ -129,7 +129,7 @@ public function export() } /** - * Exports the data of the account in SQL format + * Exports the data of the account in SQL format. * * @return \Illuminate\Http\Response */ @@ -138,12 +138,12 @@ public function exportToSql() $path = $this->dispatchNow(new ExportAccountAsSQL()); return response() - ->download(Storage::disk('public')->getDriver()->getAdapter()->getPathPrefix() . $path, 'monica.sql') + ->download(Storage::disk('public')->getDriver()->getAdapter()->getPathPrefix().$path, 'monica.sql') ->deleteFileAfterSend(true); } /** - * Display the import view + * Display the import view. * * @return \Illuminate\Http\Response */ @@ -173,7 +173,7 @@ public function storeImport(ImportsRequest $request) $importJob = auth()->user()->account->importjobs()->create([ 'user_id' => auth()->user()->id, 'type' => 'vcard', - 'filename' => $filename + 'filename' => $filename, ]); dispatch(new AddContactFromVCard($importJob)); @@ -182,7 +182,7 @@ public function storeImport(ImportsRequest $request) } /** - * Display the import report view + * Display the import report view. * * @return \Illuminate\Http\Response */ @@ -198,7 +198,7 @@ public function report($importJobId) } /** - * Display the users view + * Display the users view. * * @return \Illuminate\Http\Response */ @@ -236,7 +236,7 @@ public function addUser() public function inviteUser(InvitationRequest $request) { // Make sure the confirmation to invite has not been bypassed - if(! $request->get('confirmation')) { + if (! $request->get('confirmation')) { return redirect()->back()->withErrors(trans('settings.users_error_please_confirm'))->withInput(); } @@ -290,7 +290,7 @@ public function destroyInvitation(Invitation $invitation) /** * Display the specified resource. * - * @param String $key + * @param string $key * @return \Illuminate\Http\Response */ public function acceptInvitation($key) @@ -309,7 +309,7 @@ public function acceptInvitation($key) * Store the specified resource. * * @param Request $request - * @param String $key + * @param string $key * @return \Illuminate\Http\Response */ public function storeAcceptedInvitation(Request $request, $key) @@ -344,7 +344,7 @@ public function storeAcceptedInvitation(Request $request, $key) } /** - * Delete additional user account + * Delete additional user account. * * @param Request $request * @return \Illuminate\Http\Response @@ -370,7 +370,7 @@ public function deleteAdditionalUser(Request $request, $userID) } /** - * Display the list of tags for this account + * Display the list of tags for this account. */ public function tags() { diff --git a/app/Http/Middleware/CheckLocale.php b/app/Http/Middleware/CheckLocale.php index 5f7c6b057b9..064677eaa2a 100644 --- a/app/Http/Middleware/CheckLocale.php +++ b/app/Http/Middleware/CheckLocale.php @@ -3,8 +3,8 @@ namespace App\Http\Middleware; use Auth; -use Carbon\Carbon; use Closure; +use Carbon\Carbon; class CheckLocale { diff --git a/app/Http/Requests/ImportsRequest.php b/app/Http/Requests/ImportsRequest.php index b6265373c41..ed59fbe2e39 100644 --- a/app/Http/Requests/ImportsRequest.php +++ b/app/Http/Requests/ImportsRequest.php @@ -24,7 +24,7 @@ public function authorize() public function rules() { return [ - 'vcard' => 'required|max:10240|mimes:vcf,vcard' + 'vcard' => 'required|max:10240|mimes:vcf,vcard', ]; } } diff --git a/app/Http/Requests/People/ActivitiesRequest.php b/app/Http/Requests/People/ActivitiesRequest.php index 0dcda05444d..2a18376079f 100644 --- a/app/Http/Requests/People/ActivitiesRequest.php +++ b/app/Http/Requests/People/ActivitiesRequest.php @@ -3,7 +3,6 @@ namespace App\Http\Requests\People; use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Validation\Rule; class ActivitiesRequest extends FormRequest { @@ -28,7 +27,7 @@ public function rules() 'summary' => 'required', 'date_it_happened' => 'required|date', 'description' => 'string|nullable', - 'activity_type_id' => 'int|nullable' + 'activity_type_id' => 'int|nullable', ]; } } diff --git a/app/Http/Requests/People/CallsRequest.php b/app/Http/Requests/People/CallsRequest.php index c4e12889b5f..aa12eb6f0b7 100644 --- a/app/Http/Requests/People/CallsRequest.php +++ b/app/Http/Requests/People/CallsRequest.php @@ -25,7 +25,7 @@ public function rules() { return [ 'content' => '', - 'called_at' => 'date|nullable' + 'called_at' => 'date|nullable', ]; } } diff --git a/app/Http/Requests/People/GiftsRequest.php b/app/Http/Requests/People/GiftsRequest.php index 4e03e765017..38ad3dc0cd2 100644 --- a/app/Http/Requests/People/GiftsRequest.php +++ b/app/Http/Requests/People/GiftsRequest.php @@ -31,7 +31,7 @@ public function rules() 'date_offered' => 'date|nullable', 'value_in_dollars' => 'int|nullable', 'has_recipient' => 'boolean', - 'recipient' => 'required_with:has_recipient' + 'recipient' => 'required_with:has_recipient', ]; } } diff --git a/app/Http/Requests/People/NotesRequest.php b/app/Http/Requests/People/NotesRequest.php index c62e281de20..42a477e5db6 100644 --- a/app/Http/Requests/People/NotesRequest.php +++ b/app/Http/Requests/People/NotesRequest.php @@ -24,7 +24,7 @@ public function authorize() public function rules() { return [ - 'body' => 'required|string' + 'body' => 'required|string', ]; } } diff --git a/app/Http/Requests/People/RemindersRequest.php b/app/Http/Requests/People/RemindersRequest.php index 5c7ddeb6aaa..a15a41f9ad8 100644 --- a/app/Http/Requests/People/RemindersRequest.php +++ b/app/Http/Requests/People/RemindersRequest.php @@ -28,7 +28,7 @@ public function rules() 'next_expected_date' => 'required|date', 'description' => 'string|nullable', 'frequency_type' => 'required', - 'frequency_number' => 'int|nullable' + 'frequency_number' => 'int|nullable', ]; } } diff --git a/app/Http/Requests/People/SignificantOthersRequest.php b/app/Http/Requests/People/SignificantOthersRequest.php index ce01b06e0ac..f35741baa02 100644 --- a/app/Http/Requests/People/SignificantOthersRequest.php +++ b/app/Http/Requests/People/SignificantOthersRequest.php @@ -29,7 +29,7 @@ public function rules() 'status' => 'in:active,past|nullable', 'is_birthdate_approximate' => 'required|in:unknown,approximate,exact', 'birthdate' => 'date|nullable', - 'age' => 'int|nullable' + 'age' => 'int|nullable', ]; } } diff --git a/app/Http/ViewComposers/CountrySelectViewComposer.php b/app/Http/ViewComposers/CountrySelectViewComposer.php index fc71d153fe0..d258b029f74 100644 --- a/app/Http/ViewComposers/CountrySelectViewComposer.php +++ b/app/Http/ViewComposers/CountrySelectViewComposer.php @@ -2,15 +2,13 @@ namespace App\Http\ViewComposers; -use Illuminate\View\View; use App\Country; +use Illuminate\View\View; class CountrySelectViewComposer { - public function __construct() { - } /** @@ -21,7 +19,7 @@ public function __construct() */ public function compose(View $view) { - $countries = Country::orderBy('country', 'asc')->get(); - $view->with('countries', $countries ); + $countries = Country::orderBy('country', 'asc')->get(); + $view->with('countries', $countries); } } diff --git a/app/Http/ViewComposers/CurrencySelectViewComposer.php b/app/Http/ViewComposers/CurrencySelectViewComposer.php index c078bf5a92b..0bcc1ccf410 100644 --- a/app/Http/ViewComposers/CurrencySelectViewComposer.php +++ b/app/Http/ViewComposers/CurrencySelectViewComposer.php @@ -2,15 +2,13 @@ namespace App\Http\ViewComposers; -use Illuminate\View\View; use App\Currency; +use Illuminate\View\View; class CurrencySelectViewComposer { - public function __construct() { - } /** @@ -21,7 +19,7 @@ public function __construct() */ public function compose(View $view) { - $currencies = Currency::orderBy('name', 'asc')->get(); - $view->with('currencies', $currencies ); + $currencies = Currency::orderBy('name', 'asc')->get(); + $view->with('currencies', $currencies); } } diff --git a/app/Http/routes.php b/app/Http/routes.php index bb0c0e879f1..a8faabacd14 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -139,6 +139,5 @@ Route::get('/settings/tags', 'SettingsController@tags')->name('.tags'); Route::get('/settings/tags/add', 'SettingsController@addUser')->name('.tags.add'); Route::get('/settings/tags/{user}/delete', ['as' => '.tags.delete', 'uses' => 'SettingsController@deleteTag']); - }); }); diff --git a/app/ImportJob.php b/app/ImportJob.php index e627ea456dd..81f17f24e0c 100644 --- a/app/ImportJob.php +++ b/app/ImportJob.php @@ -2,7 +2,6 @@ namespace App; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; diff --git a/app/ImportJobReport.php b/app/ImportJobReport.php index 65cb28e15d0..e2e99ebfbe7 100644 --- a/app/ImportJobReport.php +++ b/app/ImportJobReport.php @@ -2,7 +2,6 @@ namespace App; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; diff --git a/app/Instance.php b/app/Instance.php index 7f1d0fb0bae..1697793df43 100644 --- a/app/Instance.php +++ b/app/Instance.php @@ -3,7 +3,6 @@ namespace App; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\Relations\BelongsTo; class Instance extends Model { diff --git a/app/Invitation.php b/app/Invitation.php index b3693e397c8..60fe09bc998 100644 --- a/app/Invitation.php +++ b/app/Invitation.php @@ -2,9 +2,6 @@ namespace App; -use Auth; -use App\Helpers\DateHelper; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; diff --git a/app/Jobs/AddContactFromVCard.php b/app/Jobs/AddContactFromVCard.php index 972e28e5176..e5655890cd2 100644 --- a/app/Jobs/AddContactFromVCard.php +++ b/app/Jobs/AddContactFromVCard.php @@ -4,17 +4,16 @@ use App\User; use App\Contact; +use App\Country; use App\Reminder; use App\ImportJob; use App\ImportJobReport; -use App\Country; +use Sabre\VObject\Reader; use Illuminate\Bus\Queueable; -use Illuminate\Queue\SerializesModels; use Sabre\VObject\Component\VCard; -use Sabre\VObject\Property\ICalendar\DateTime; -use Sabre\VObject\Reader; -use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Storage; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -50,7 +49,6 @@ public function __construct(ImportJob $importJob) public function handle() { try { - $numberOfContactsInTheFile = preg_match_all('/(BEGIN:VCARD.*?END:VCARD)/s', Storage::disk('public')->get($this->importJob->filename), $matches); $this->importJob->started_at = \Carbon\Carbon::now(); @@ -58,7 +56,6 @@ public function handle() collect($matches[0])->map(function ($vcard) { return Reader::read($vcard); })->each(function (VCard $vcard) { - if ($this->contactExists($vcard, $this->importJob->account_id)) { $this->skippedContacts++; $this->fileImportJobReport($vcard, self::VCARD_SKIPPED, self::ERROR_CONTACT_EXIST); @@ -77,7 +74,7 @@ public function handle() $contact = new Contact(); $contact->account_id = $this->importJob->account_id; - if($vcard->N && ! empty($vcard->N->getParts()[1])) { + if ($vcard->N && ! empty($vcard->N->getParts()[1])) { $contact->first_name = $this->formatValue($vcard->N->getParts()[1]); $contact->middle_name = $this->formatValue($vcard->N->getParts()[2]); $contact->last_name = $this->formatValue($vcard->N->getParts()[0]); @@ -88,7 +85,7 @@ public function handle() $contact->gender = 'none'; $contact->is_birthdate_approximate = 'unknown'; - if ($vcard->BDAY && !empty((string) $vcard->BDAY)) { + if ($vcard->BDAY && ! empty((string) $vcard->BDAY)) { $contact->is_birthdate_approximate = 'exact'; $contact->birthdate = new \DateTime((string) $vcard->BDAY); } @@ -96,7 +93,7 @@ public function handle() $contact->email = $this->formatValue($vcard->EMAIL); $contact->phone_number = $this->formatValue($vcard->TEL); - if($vcard->ADR) { + if ($vcard->ADR) { $contact->street = $this->formatValue($vcard->ADR->getParts()[2]); $contact->city = $this->formatValue($vcard->ADR->getParts()[3]); $contact->province = $this->formatValue($vcard->ADR->getParts()[4]); @@ -145,7 +142,6 @@ public function handle() $this->importJob->contacts_imported = $this->importedContacts; $this->importJob->ended_at = \Carbon\Carbon::now(); $this->importJob->save(); - } catch (Exception $e) { $this->importJob->contacts_found = $numberOfContactsInTheFile; $this->importJob->failed = 1; @@ -166,24 +162,24 @@ public function handle() * @param VCard $vcard * @return bool */ - function contactHasName(VCard $vcard): bool + public function contactHasName(VCard $vcard): bool { return ! empty($vcard->N->getParts()[1]) || ! empty((string) $vcard->NICKNAME); } /** - * Formats and returns a string for the contact + * Formats and returns a string for the contact. * * @param null|string $value * @return null|string */ private function formatValue($value) { - return !empty((string) $value) ? (string) $value : null; + return ! empty((string) $value) ? (string) $value : null; } /** - * Checks whether a contact already exists for a given account + * Checks whether a contact already exists for a given account. * * @param VCard $vcard * @param User $user @@ -195,7 +191,7 @@ private function contactExists(VCard $vcard, $account_id) $contact = Contact::where([ ['account_id', $account_id], - ['email', $email] + ['email', $email], ])->first(); return $email && $contact; @@ -204,9 +200,9 @@ private function contactExists(VCard $vcard, $account_id) private function fileImportJobReport(VCard $vcard, $status, $reason = null) { $name = $this->formatValue($vcard->N->getParts()[1]); - $name .= ' ' . $this->formatValue($vcard->N->getParts()[2]); - $name .= ' ' . $this->formatValue($vcard->N->getParts()[0]); - $name .= ' ' . $this->formatValue($vcard->EMAIL); + $name .= ' '.$this->formatValue($vcard->N->getParts()[2]); + $name .= ' '.$this->formatValue($vcard->N->getParts()[0]); + $name .= ' '.$this->formatValue($vcard->EMAIL); $importJobReport = new ImportJobReport; $importJobReport->account_id = $this->importJob->account_id; diff --git a/app/Jobs/ExportAccountAsSQL.php b/app/Jobs/ExportAccountAsSQL.php index cf85685590d..6ded32224bc 100644 --- a/app/Jobs/ExportAccountAsSQL.php +++ b/app/Jobs/ExportAccountAsSQL.php @@ -5,8 +5,8 @@ use Carbon\Carbon; use Illuminate\Support\Facades\DB; use Illuminate\Queue\SerializesModels; -use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Support\Facades\Storage; +use Illuminate\Foundation\Bus\Dispatchable; class ExportAccountAsSQL { @@ -28,14 +28,14 @@ class ExportAccountAsSQL 'subscriptions', 'import_jobs', 'import_job_reports', - 'instances' + 'instances', ]; protected $ignoredColumns = [ 'stripe_id', 'card_brand', 'card_last_four', - 'trial_ends_at' + 'trial_ends_at', ]; protected $file = ''; @@ -50,7 +50,7 @@ class ExportAccountAsSQL public function __construct($file = null, $path = null) { $this->path = $path ?? 'exports/'; - $this->file = rand() . '.sql'; + $this->file = rand().'.sql'; } /** @@ -60,18 +60,18 @@ public function __construct($file = null, $path = null) */ public function handle() { - $downloadPath = $this->path . $this->file; + $downloadPath = $this->path.$this->file; $user = auth()->user(); $account = $user->account; - $sql = "# ************************************************************ -# " . $user->first_name . " " . $user->last_name . " dump of data + $sql = '# ************************************************************ +# '.$user->first_name.' '.$user->last_name." dump of data # {$this->file} -# Export date: " . Carbon::now() . " +# Export date: ".Carbon::now().' # ************************************************************ -" . PHP_EOL; +'.PHP_EOL; $tables = DB::select('SELECT table_name FROM information_schema.tables WHERE table_schema="monica"'); @@ -87,8 +87,7 @@ public function handle() // Looping over the rows foreach ($tableData as $data) { - - $newSQLLine = 'INSERT INTO ' . $tableName . ' ('; + $newSQLLine = 'INSERT INTO '.$tableName.' ('; $tableValues = []; $skipLine = false; @@ -98,11 +97,10 @@ public function handle() array_push($tableColumnNames, $columnName); } - $newSQLLine .= implode(',', $tableColumnNames) . ') VALUES ('; + $newSQLLine .= implode(',', $tableColumnNames).') VALUES ('; // Looping over the values foreach ($data as $columnName => $value) { - if ($columnName == 'account_id') { if ($value !== $account->id) { $skipLine = true; @@ -112,15 +110,15 @@ public function handle() if (is_null($value)) { $value = 'NULL'; - } elseif (!is_numeric($value)) { - $value = "'" . addslashes($value) . "'"; + } elseif (! is_numeric($value)) { + $value = "'".addslashes($value)."'"; } array_push($tableValues, $value); } if ($skipLine == false) { - $newSQLLine .= implode(',', $tableValues) . ');' . PHP_EOL; + $newSQLLine .= implode(',', $tableValues).');'.PHP_EOL; $sql .= $newSQLLine; } } @@ -128,24 +126,24 @@ public function handle() // Specific to `accounts` table $accounts = array_filter($tables, function ($e) { - return $e->table_name == 'accounts'; - } + return $e->table_name == 'accounts'; + } )[0]; $tableName = $accounts->table_name; $tableData = DB::table($tableName)->get()->toArray(); foreach ($tableData as $data) { - $newSQLLine = 'INSERT INTO ' . $tableName . ' VALUES ('; + $newSQLLine = 'INSERT INTO '.$tableName.' VALUES ('; $data = (array) $data; - if($data['id'] === $account->id): + if ($data['id'] === $account->id): $values = [ $data['id'], "'".addslashes($data['api_key'])."'", - $data['number_of_invitations_sent'] !== NULL + $data['number_of_invitations_sent'] !== null ? $data['number_of_invitations_sent'] : 'NULL', ]; - $newSQLLine .= implode(',', $values) . ');' . PHP_EOL; - $sql .= $newSQLLine; + $newSQLLine .= implode(',', $values).');'.PHP_EOL; + $sql .= $newSQLLine; endif; } diff --git a/app/Jobs/ResizeAvatars.php b/app/Jobs/ResizeAvatars.php index 0d76ab6c8c0..f4f35686d69 100644 --- a/app/Jobs/ResizeAvatars.php +++ b/app/Jobs/ResizeAvatars.php @@ -35,7 +35,6 @@ public function __construct(Contact $contact) public function handle() { if ($this->contact->has_avatar == 'true') { - $avatar_file = Storage::disk('public')->get($this->contact->avatar_file_name); $avatar_path = Storage::disk('public')->url($this->contact->avatar_file_name); $avatar_filename_without_extension = pathinfo($avatar_path, PATHINFO_FILENAME); diff --git a/app/Jobs/SendReminderEmail.php b/app/Jobs/SendReminderEmail.php index e1b8e5d93e6..6c08a90fc07 100644 --- a/app/Jobs/SendReminderEmail.php +++ b/app/Jobs/SendReminderEmail.php @@ -4,7 +4,6 @@ use App\User; use App\Reminder; -use Carbon\Carbon; use App\Mail\UserReminded; use Illuminate\Bus\Queueable; use Illuminate\Support\Facades\Mail; diff --git a/app/Jobs/SetNextReminderDate.php b/app/Jobs/SetNextReminderDate.php index 654c8c344f9..0927f74d58f 100644 --- a/app/Jobs/SetNextReminderDate.php +++ b/app/Jobs/SetNextReminderDate.php @@ -2,7 +2,6 @@ namespace App\Jobs; -use Log; use App\Reminder; use Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; diff --git a/app/Kid.php b/app/Kid.php index dd218f12c4d..fbb7b08a723 100644 --- a/app/Kid.php +++ b/app/Kid.php @@ -2,10 +2,7 @@ namespace App; -use App\Gift; -use App\User; use Carbon\Carbon; -use App\Helpers\DateHelper; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -83,7 +80,7 @@ public function assignBirthday($approximation, $exactDate, $age = null) } /** - * Get the date_it_happened field according to user's timezone + * Get the date_it_happened field according to user's timezone. * * @param string $value * @return string @@ -98,7 +95,7 @@ public function getBirthdateAttribute($value) } /** - * Get age according to the birthdate + * Get age according to the birthdate. * * @return string */ @@ -126,7 +123,7 @@ public function getAge() public function getBirthdate() { if (is_null($this->birthdate)) { - return null; + return; } return $this->birthdate; @@ -139,7 +136,7 @@ public function getBirthdate() public function getFirstName() { if (is_null($this->first_name)) { - return null; + return; } return $this->first_name; diff --git a/app/Mail/InvitationSent.php b/app/Mail/InvitationSent.php index 52cd66f9f74..e03ae882d5c 100644 --- a/app/Mail/InvitationSent.php +++ b/app/Mail/InvitationSent.php @@ -6,7 +6,6 @@ use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; -use Illuminate\Contracts\Queue\ShouldQueue; class InvitationSent extends Mailable { diff --git a/app/Mail/NewUserAlert.php b/app/Mail/NewUserAlert.php index 2684d57c388..9a411ef997a 100644 --- a/app/Mail/NewUserAlert.php +++ b/app/Mail/NewUserAlert.php @@ -6,7 +6,6 @@ use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; -use Illuminate\Contracts\Queue\ShouldQueue; class NewUserAlert extends Mailable { diff --git a/app/Mail/UserReminded.php b/app/Mail/UserReminded.php index f14e6640435..7fb4c3cdab1 100644 --- a/app/Mail/UserReminded.php +++ b/app/Mail/UserReminded.php @@ -8,7 +8,6 @@ use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; -use Illuminate\Contracts\Queue\ShouldQueue; class UserReminded extends Mailable { diff --git a/app/Note.php b/app/Note.php index 913c12c2d4e..98df70c8924 100644 --- a/app/Note.php +++ b/app/Note.php @@ -2,10 +2,10 @@ namespace App; +use Parsedown; use App\Helpers\DateHelper; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; -use Parsedown; /** * @property Account $account @@ -42,7 +42,7 @@ public function contact() } /** - * Return the markdown parsed body + * Return the markdown parsed body. * * @return string */ diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index b9fa7531aa2..e790a12657a 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,9 +2,9 @@ namespace App\Providers; -use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\View; use Laravel\Dusk\DuskServiceProvider; +use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { @@ -15,12 +15,12 @@ class AppServiceProvider extends ServiceProvider */ public function boot() { - View::composer( - 'partials.components.country-select','App\Http\ViewComposers\CountrySelectViewComposer' + View::composer( + 'partials.components.country-select', 'App\Http\ViewComposers\CountrySelectViewComposer' ); - View::composer( - 'partials.components.currency-select','App\Http\ViewComposers\CurrencySelectViewComposer' + View::composer( + 'partials.components.currency-select', 'App\Http\ViewComposers\CurrencySelectViewComposer' ); } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 65c8965d748..5e3ea30964c 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -2,7 +2,6 @@ namespace App\Providers; -use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; class EventServiceProvider extends ServiceProvider diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index bfbe6ab8ec0..207827cb9a2 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -2,16 +2,16 @@ namespace App\Providers; -use App\Activity; +use Route; +use App\Kid; use App\Debt; use App\Gift; -use App\Kid; use App\Note; -use App\Reminder; -use App\SignificantOther; use App\Task; -use Route; use App\Contact; +use App\Activity; +use App\Reminder; +use App\SignificantOther; use Illuminate\Routing\Router; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; @@ -41,56 +41,56 @@ public function boot() ->firstOrFail(); }); - Route::bind('activity', function($value, $route) { + Route::bind('activity', function ($value, $route) { return Activity::where('account_id', auth()->user()->account_id) ->where('contact_id', $route->parameter('contact')->id) ->where('id', $value) ->firstOrFail(); }); - Route::bind('reminder', function($value, $route) { + Route::bind('reminder', function ($value, $route) { return Reminder::where('account_id', auth()->user()->account_id) ->where('contact_id', $route->parameter('contact')->id) ->where('id', $value) ->firstOrFail(); }); - Route::bind('task', function($value, $route) { + Route::bind('task', function ($value, $route) { return Task::where('account_id', auth()->user()->account_id) ->where('contact_id', $route->parameter('contact')->id) ->where('id', $value) ->firstOrFail(); }); - Route::bind('gift', function($value, $route) { + Route::bind('gift', function ($value, $route) { return Gift::where('account_id', auth()->user()->account_id) ->where('contact_id', $route->parameter('contact')->id) ->where('id', $value) ->firstOrFail(); }); - Route::bind('debt', function($value, $route) { + Route::bind('debt', function ($value, $route) { return Debt::where('account_id', auth()->user()->account_id) ->where('contact_id', $route->parameter('contact')->id) ->where('id', $value) ->firstOrFail(); }); - Route::bind('significant_other', function($value, $route) { + Route::bind('significant_other', function ($value, $route) { return SignificantOther::where('account_id', auth()->user()->account_id) ->where('contact_id', $route->parameter('contact')->id) ->where('id', $value) ->firstOrFail(); }); - Route::bind('kid', function($value, $route) { + Route::bind('kid', function ($value, $route) { return Kid::where('account_id', auth()->user()->account_id) ->where('child_of_contact_id', $route->parameter('contact')->id) ->where('id', $value) ->firstOrFail(); }); - Route::bind('note', function($value, $route) { + Route::bind('note', function ($value, $route) { return Note::where('account_id', auth()->user()->account_id) ->where('contact_id', $route->parameter('contact')->id) ->where('id', $value) diff --git a/app/Reminder.php b/app/Reminder.php index b6ece88c313..3aa777a05ae 100644 --- a/app/Reminder.php +++ b/app/Reminder.php @@ -2,13 +2,11 @@ namespace App; -use Log; use Auth; use Carbon\Carbon; use App\Helpers\DateHelper; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; -use MartinJoiner\OrdinalNumber\OrdinalNumber; /** * @property Account $account @@ -51,7 +49,7 @@ public function contact() } /** - * Get the next_expected_date field according to user's timezone + * Get the next_expected_date field according to user's timezone. * * @param string $value * @return string @@ -66,7 +64,7 @@ public function getNextExpectedDateAttribute($value) } /** - * Correctly set the frequency type + * Correctly set the frequency type. * * @param string $value */ @@ -76,7 +74,7 @@ public function setFrequencyTypeAttribute($value) } /** - * Add a new birthday reminder + * Add a new birthday reminder. * * @param Contact $contact * @param string $title @@ -98,7 +96,7 @@ public static function addBirthdayReminder($contact, $title, $date, $kid = null, 'account_id' => $contact->account_id, 'is_birthday' => 'true', 'about_object' => $kid ? 'kid' : ($significantOther ? 'significantother' : 'contact'), - 'about_object_id' => $kid ? $kid->id : ($significantOther ? $significantOther->id : $contact->id) + 'about_object_id' => $kid ? $kid->id : ($significantOther ? $significantOther->id : $contact->id), ]); $account = $reminder->contact->account; @@ -118,7 +116,7 @@ public static function addBirthdayReminder($contact, $title, $date, $kid = null, public function getTitle() { if (is_null($this->title)) { - return null; + return; } return $this->title; @@ -131,7 +129,7 @@ public function getTitle() public function getDescription() { if (is_null($this->description)) { - return null; + return; } return $this->description; diff --git a/app/SignificantOther.php b/app/SignificantOther.php index 5cc8af200fe..fbd9d6f168a 100644 --- a/app/SignificantOther.php +++ b/app/SignificantOther.php @@ -3,8 +3,8 @@ namespace App; use Carbon\Carbon; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsTo; /** @@ -67,7 +67,7 @@ public function reminder() } /** - * Limit the query to active significant others + * Limit the query to active significant others. * * @param Builder $query * @return Builder @@ -102,7 +102,7 @@ public function assignBirthday($approximation, $exactDate, $age = null) } /** - * Get the date_it_happened field according to user's timezone + * Get the date_it_happened field according to user's timezone. * * @param string $value * @return string @@ -117,7 +117,7 @@ public function getBirthdateAttribute($value) } /** - * Get age according to the birthdate + * Get age according to the birthdate. * * @return string */ @@ -134,7 +134,7 @@ public function getAgeAttribute() public function getName() { if ($this->first_name == '') { - return null; + return; } return $this->first_name; @@ -148,7 +148,7 @@ public function getName() public function getBirthdate() { if (is_null($this->birthdate)) { - return null; + return; } return $this->birthdate; @@ -166,7 +166,7 @@ public function getAge() } /** - * Returns 'true' if the birthdate is an approximation + * Returns 'true' if the birthdate is an approximation. * * @return string */ diff --git a/app/Statistic.php b/app/Statistic.php index f04c3cab238..360f426ef0e 100644 --- a/app/Statistic.php +++ b/app/Statistic.php @@ -3,7 +3,6 @@ namespace App; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\SoftDeletes; class Statistic extends Model { diff --git a/app/Tag.php b/app/Tag.php index 15f1bbd7d8e..34d81569520 100644 --- a/app/Tag.php +++ b/app/Tag.php @@ -3,7 +3,6 @@ namespace App; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\Builder; class Tag extends Model { diff --git a/app/Task.php b/app/Task.php index 379216d5bbf..81c7570c369 100644 --- a/app/Task.php +++ b/app/Task.php @@ -2,10 +2,8 @@ namespace App; -use Auth; -use App\Helpers\DateHelper; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsTo; /** @@ -16,7 +14,6 @@ */ class Task extends Model { - /** * The attributes that aren't mass assignable. * @@ -52,7 +49,7 @@ public function contact() } /** - * Limit tasks to completed ones + * Limit tasks to completed ones. * * @param Builder $query * @return Builder @@ -63,7 +60,7 @@ public function scopeCompleted(Builder $query) } /** - * Limit tasks to in-progress ones + * Limit tasks to in-progress ones. * * @param Builder $query * @return Builder @@ -74,7 +71,7 @@ public function scopeInProgress(Builder $query) } /** - * Toggle task status + * Toggle task status. * * @return static */ diff --git a/app/Traits/Searchable.php b/app/Traits/Searchable.php index c15a417a69a..d9f8877f43b 100644 --- a/app/Traits/Searchable.php +++ b/app/Traits/Searchable.php @@ -17,7 +17,7 @@ trait Searchable public function scopeSearch(Builder $builder, $needle, $accountId) { if ($this->searchable_columns == null) { - return null; + return; } // building the query. there is probably a way to make this more elegant. @@ -26,15 +26,15 @@ public function scopeSearch(Builder $builder, $needle, $accountId) $queryString = ''; foreach ($this->searchable_columns as $column) { $queryString .= $column.' LIKE \'%'.$needle.'%\''; - if ($counter != $count) { + if ($counter != $count) { $queryString .= ' or '; - } + } $counter++; } - $builder->whereRaw('account_id = '.$accountId.' and ('. $queryString .')'); + $builder->whereRaw('account_id = '.$accountId.' and ('.$queryString.')'); $builder->select($this->return_from_search); return $builder->get(); } -} \ No newline at end of file +} diff --git a/app/User.php b/app/User.php index b010fde19ad..7b412010e00 100644 --- a/app/User.php +++ b/app/User.php @@ -16,7 +16,7 @@ class User extends Authenticatable * @var array */ protected $fillable = [ - 'name', 'email', 'password', 'timezone', 'locale', 'currency_id', 'fluid_container', 'name_order' + 'name', 'email', 'password', 'timezone', 'locale', 'currency_id', 'fluid_container', 'name_order', ]; /** @@ -44,7 +44,7 @@ public function account() } /** - * Assigns a default value just in case the sort order is empty + * Assigns a default value just in case the sort order is empty. * * @param string $value * @return string @@ -92,15 +92,15 @@ public function getNameAttribute() if ($this->name_order == 'firstname_first') { $completeName = $this->first_name; - if (!is_null($this->last_name)) { - $completeName = $completeName . ' ' . $this->last_name; + if (! is_null($this->last_name)) { + $completeName = $completeName.' '.$this->last_name; } } else { - if (!is_null($this->last_name)) { + if (! is_null($this->last_name)) { $completeName = $this->last_name; } - $completeName = $completeName . ' ' . $this->first_name; + $completeName = $completeName.' '.$this->first_name; } return $completeName; diff --git a/config/app.php b/config/app.php index f2cc67c9dec..9ac9a32990d 100644 --- a/config/app.php +++ b/config/app.php @@ -1,4 +1,5 @@ 'mysql', 'host' => $url['host'], 'port' => $url['port'], - 'database' => substr($url["path"], 1), - 'username' => $url["user"], - 'password' => $url["pass"], + 'database' => substr($url['path'], 1), + 'username' => $url['user'], + 'password' => $url['pass'], 'charset' => 'utf8', 'prefix' => '', 'schema' => 'public', ]; } -return $db; \ No newline at end of file +return $db; diff --git a/config/image.php b/config/image.php index b106809e245..67983819d09 100644 --- a/config/image.php +++ b/config/image.php @@ -1,6 +1,6 @@ 'gd' + 'driver' => 'gd', -); +]; diff --git a/config/monica.php b/config/monica.php index 8337262c93e..ca689ca8fc3 100644 --- a/config/monica.php +++ b/config/monica.php @@ -16,7 +16,7 @@ 'fr', 'pt-br', 'ru', - 'cz' + 'cz', ], /* diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 8938797c3bb..b45d4dbc0ac 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -22,13 +22,13 @@ 'remember_token' => str_random(10), 'timezone' => config('app.timezone'), 'name_order' => 'firstname_first', - 'account_id' => factory('App\Account')->create()->id + 'account_id' => factory('App\Account')->create()->id, ]; }); $factory->define(App\Account::class, function (Faker\Generator $faker) { return [ - 'api_key' => RandomHelper::generateString(30) + 'api_key' => RandomHelper::generateString(30), ]; }); diff --git a/database/migrations/2016_08_28_122938_create_kids_table.php b/database/migrations/2016_08_28_122938_create_kids_table.php index a4ca9d98414..72d822553b5 100644 --- a/database/migrations/2016_08_28_122938_create_kids_table.php +++ b/database/migrations/2016_08_28_122938_create_kids_table.php @@ -1,7 +1,6 @@ id; - if (!is_null ($contact->email)) { + if (! is_null($contact->email)) { $contact->email = decrypt($contact->email); } - if (!is_null ($contact->phone_number)) { + if (! is_null($contact->phone_number)) { $contact->phone_number = decrypt($contact->phone_number); } - if (!is_null ($contact->street)) { + if (! is_null($contact->street)) { $contact->street = decrypt($contact->street); } - if (!is_null ($contact->city)) { + if (! is_null($contact->city)) { $contact->city = decrypt($contact->city); } - if (!is_null ($contact->province)) { + if (! is_null($contact->province)) { $contact->province = decrypt($contact->province); } - if (!is_null ($contact->postal_code)) { + if (! is_null($contact->postal_code)) { $contact->postal_code = decrypt($contact->postal_code); } diff --git a/database/migrations/2017_05_04_193252_alter_activity_nullable.php b/database/migrations/2017_05_04_193252_alter_activity_nullable.php index e792d338285..87a62086c83 100644 --- a/database/migrations/2017_05_04_193252_alter_activity_nullable.php +++ b/database/migrations/2017_05_04_193252_alter_activity_nullable.php @@ -13,7 +13,7 @@ class AlterActivityNullable extends Migration */ public function up() { - Schema::table('activities', function(Blueprint $table) { + Schema::table('activities', function (Blueprint $table) { $table->integer('activity_type_id')->unsigned()->nullable()->change(); }); } diff --git a/database/migrations/2017_05_08_164514_remove_encryption_tasks.php b/database/migrations/2017_05_08_164514_remove_encryption_tasks.php index 97e558fd90c..93bd70747af 100644 --- a/database/migrations/2017_05_08_164514_remove_encryption_tasks.php +++ b/database/migrations/2017_05_08_164514_remove_encryption_tasks.php @@ -1,8 +1,6 @@ id.' '; - if (!is_null ($task->title)) { + if (! is_null($task->title)) { $task->title = decrypt($task->title); } - if (!is_null ($task->description)) { + if (! is_null($task->description)) { $task->description = decrypt($task->description); } $task->save(); } } -} \ No newline at end of file +} diff --git a/database/migrations/2017_05_30_002239_remove_predefined_reminders.php b/database/migrations/2017_05_30_002239_remove_predefined_reminders.php index 3c572b27498..bfdb22d9b5a 100644 --- a/database/migrations/2017_05_30_002239_remove_predefined_reminders.php +++ b/database/migrations/2017_05_30_002239_remove_predefined_reminders.php @@ -17,11 +17,11 @@ public function up() $reminders = Reminder::all(); foreach ($reminders as $reminder) { echo $reminder->id.' '; - if (!is_null ($reminder->title)) { + if (! is_null($reminder->title)) { $reminder->title = decrypt($reminder->title); } - if (!is_null ($reminder->description)) { + if (! is_null($reminder->description)) { $reminder->description = decrypt($reminder->description); } diff --git a/database/migrations/2017_05_30_023116_create_money_table.php b/database/migrations/2017_05_30_023116_create_money_table.php index 78a28340f87..f972892b38c 100644 --- a/database/migrations/2017_05_30_023116_create_money_table.php +++ b/database/migrations/2017_05_30_023116_create_money_table.php @@ -1,7 +1,6 @@ getPDO()->getAttribute(PDO::ATTR_DRIVER_NAME); - switch($driverName) - { + switch ($driverName) { case 'mysql': DB::statement("ALTER TABLE contacts CHANGE COLUMN gender gender ENUM('male', 'female', 'none')"); DB::statement("ALTER TABLE significant_others CHANGE COLUMN gender gender ENUM('male', 'female', 'none')"); @@ -33,18 +30,19 @@ public function up() } /** - * Alter an enum field constraints. Source: https://stackoverflow.com/a/36198549 + * Alter an enum field constraints. Source: https://stackoverflow.com/a/36198549. * @param $table * @param $field * @param array $options */ - protected function alterEnum($table, $field, array $options) { + protected function alterEnum($table, $field, array $options) + { $check = "${table}_${field}_check"; $enumList = []; - foreach($options as $option) { + foreach ($options as $option) { $enumList[] = sprintf("'%s'::CHARACTER VARYING", $option); } - $enumString = implode(", ", $enumList); + $enumString = implode(', ', $enumList); DB::transaction(function () use ($table, $field, $check, $options, $enumString) { DB::statement(sprintf('ALTER TABLE %s DROP CONSTRAINT %s;', $table, $check)); DB::statement(sprintf('ALTER TABLE %s ADD CONSTRAINT %s CHECK (%s::TEXT = ANY (ARRAY[%s]::TEXT[]))', $table, $check, $field, $enumString)); diff --git a/database/migrations/2017_06_10_155349_create_currencies_data.php b/database/migrations/2017_06_10_155349_create_currencies_data.php index 3cafe8b2500..e7602aaea70 100644 --- a/database/migrations/2017_06_10_155349_create_currencies_data.php +++ b/database/migrations/2017_06_10_155349_create_currencies_data.php @@ -13,26 +13,25 @@ class CreateCurrenciesData extends Migration */ public function up() { - Schema::create('currencies', function (Blueprint $table) { - $table->increments('id'); - $table->string('iso'); - $table->string('name'); - $table->string('symbol'); - }); + Schema::create('currencies', function (Blueprint $table) { + $table->increments('id'); + $table->string('iso'); + $table->string('name'); + $table->string('symbol'); + }); //defaults - DB::table('currencies')->insert([ 'iso' => 'CAD', 'name' => 'Canadian Dollar', 'symbol'=>'$' ]); - DB::table('currencies')->insert([ 'iso' => 'USD', 'name' => 'US Dollar', 'symbol'=>'$' ]); - DB::table('currencies')->insert([ 'iso' => 'GBP', 'name' => 'British Pound', 'symbol'=>'£' ]); - DB::table('currencies')->insert([ 'iso' => 'EUR', 'name' => 'Euro', 'symbol'=>'€' ]); - DB::table('currencies')->insert([ 'iso' => 'RUB', 'name' => 'Russian Ruble', 'symbol'=>'₽' ]); + DB::table('currencies')->insert(['iso' => 'CAD', 'name' => 'Canadian Dollar', 'symbol'=>'$']); + DB::table('currencies')->insert(['iso' => 'USD', 'name' => 'US Dollar', 'symbol'=>'$']); + DB::table('currencies')->insert(['iso' => 'GBP', 'name' => 'British Pound', 'symbol'=>'£']); + DB::table('currencies')->insert(['iso' => 'EUR', 'name' => 'Euro', 'symbol'=>'€']); + DB::table('currencies')->insert(['iso' => 'RUB', 'name' => 'Russian Ruble', 'symbol'=>'₽']); - Schema::table('users', function (Blueprint $table) { - $dollarResult = DB::table('currencies')->select('id')->where('iso','=','USD')->value('id'); - $table->integer('currency_id')->after('timezone')->default( + Schema::table('users', function (Blueprint $table) { + $dollarResult = DB::table('currencies')->select('id')->where('iso', '=', 'USD')->value('id'); + $table->integer('currency_id')->after('timezone')->default( $dollarResult ); - }); - + }); } } diff --git a/database/migrations/2017_06_11_025227_remove_encryption_journal.php b/database/migrations/2017_06_11_025227_remove_encryption_journal.php index fbfb6745e56..5399aab446f 100644 --- a/database/migrations/2017_06_11_025227_remove_encryption_journal.php +++ b/database/migrations/2017_06_11_025227_remove_encryption_journal.php @@ -1,8 +1,6 @@ id.' '; - if (!is_null ($entry->title)) { + if (! is_null($entry->title)) { $entry->title = decrypt($entry->title); } - if (!is_null ($entry->post)) { + if (! is_null($entry->post)) { $entry->post = decrypt($entry->post); } diff --git a/database/migrations/2017_06_13_035059_remove_gifts_encryption.php b/database/migrations/2017_06_13_035059_remove_gifts_encryption.php index 73c99d9172e..4a2e5e8a0f0 100644 --- a/database/migrations/2017_06_13_035059_remove_gifts_encryption.php +++ b/database/migrations/2017_06_13_035059_remove_gifts_encryption.php @@ -1,8 +1,6 @@ id; - if (!is_null ($gift->name)) { + if (! is_null($gift->name)) { $gift->name = decrypt($gift->name); } - if (!is_null ($gift->comment)) { + if (! is_null($gift->comment)) { $gift->comment = decrypt($gift->comment); } - if (!is_null ($gift->url)) { + if (! is_null($gift->url)) { $gift->url = decrypt($gift->url); } diff --git a/database/migrations/2017_06_14_131803_remove_bern_timezone.php b/database/migrations/2017_06_14_131803_remove_bern_timezone.php index 13fc9b26a2e..13923e7b507 100644 --- a/database/migrations/2017_06_14_131803_remove_bern_timezone.php +++ b/database/migrations/2017_06_14_131803_remove_bern_timezone.php @@ -1,8 +1,6 @@ insert([ 'iso' => 'ZAR', 'name' => 'South African Rand', 'symbol'=>'R ' ]); + DB::table('currencies')->insert(['iso' => 'ZAR', 'name' => 'South African Rand', 'symbol'=>'R ']); } } diff --git a/database/migrations/2017_06_17_010900_fix_contacts_table.php b/database/migrations/2017_06_17_010900_fix_contacts_table.php index d64f850d1e6..3caf9bc97c6 100644 --- a/database/migrations/2017_06_17_010900_fix_contacts_table.php +++ b/database/migrations/2017_06_17_010900_fix_contacts_table.php @@ -1,8 +1,6 @@ integer('invited_by_user_id')->after('contacts_sort_order')->nullable(); diff --git a/database/migrations/2017_06_19_105842_add_stripe_fields_to_users.php b/database/migrations/2017_06_19_105842_add_stripe_fields_to_users.php index b68f9128da6..1f20e655ca4 100644 --- a/database/migrations/2017_06_19_105842_add_stripe_fields_to_users.php +++ b/database/migrations/2017_06_19_105842_add_stripe_fields_to_users.php @@ -1,7 +1,6 @@ insert([ 'iso' => 'DKK', 'name' => 'Danish krone', 'symbol'=>'kr.' ]); + DB::table('currencies')->insert(['iso' => 'DKK', 'name' => 'Danish krone', 'symbol'=>'kr.']); } } diff --git a/database/migrations/2017_07_18_215758_add_indian_rupee_to_currencies_table.php b/database/migrations/2017_07_18_215758_add_indian_rupee_to_currencies_table.php index f5cf29298f4..5a27738f3e2 100644 --- a/database/migrations/2017_07_18_215758_add_indian_rupee_to_currencies_table.php +++ b/database/migrations/2017_07_18_215758_add_indian_rupee_to_currencies_table.php @@ -1,7 +1,5 @@ insert([ 'iso' => 'INR', 'name' => 'Indian rupee', 'symbol'=>'₹' ]); + DB::table('currencies')->insert(['iso' => 'INR', 'name' => 'Indian rupee', 'symbol'=>'₹']); } } diff --git a/database/seeds/ActivityTypesTableSeeder.php b/database/seeds/ActivityTypesTableSeeder.php index d8c108d996b..2a5f9f8c850 100644 --- a/database/seeds/ActivityTypesTableSeeder.php +++ b/database/seeds/ActivityTypesTableSeeder.php @@ -2,7 +2,6 @@ use Carbon\Carbon; use Illuminate\Database\Seeder; -use Illuminate\Database\Eloquent\Model; class ActivityTypesTableSeeder extends Seeder { diff --git a/database/seeds/CountriesSeederTable.php b/database/seeds/CountriesSeederTable.php index 2a987d43b8c..0370469900b 100644 --- a/database/seeds/CountriesSeederTable.php +++ b/database/seeds/CountriesSeederTable.php @@ -1,7 +1,6 @@ notes()->create([ 'body' => $faker->realText(rand(40, 500)), - 'account_id' => $contact->account_id + 'account_id' => $contact->account_id, ]); $contact->logEvent('note', $note->id, 'create'); @@ -166,9 +160,9 @@ public function run() $activity = $contact->activities()->create([ 'summary' => $faker->realText(rand(40, 100)), 'date_it_happened' => $faker->date($format = 'Y-m-d', $max = 'now'), - 'activity_type_id' => rand(1,13), + 'activity_type_id' => rand(1, 13), 'description' => $faker->realText(rand(100, 1000)), - 'account_id' => $contact->account_id + 'account_id' => $contact->account_id, ]); $contact->logEvent('activity', $activity->id, 'create'); @@ -181,8 +175,8 @@ public function run() $task = $contact->tasks()->create([ 'title' => $faker->realText(rand(40, 100)), 'description' => $faker->realText(rand(100, 1000)), - 'status' => (rand(1,2) == 1 ? 'inprogress' : 'completed'), - 'account_id' => $contact->account_id + 'status' => (rand(1, 2) == 1 ? 'inprogress' : 'completed'), + 'account_id' => $contact->account_id, ]); $contact->logEvent('task', $task->id, 'create'); @@ -193,11 +187,11 @@ public function run() if (rand(1, 2) == 1) { for ($j = 0; $j < rand(1, 6); $j++) { $debt = $contact->debts()->create([ - 'in_debt' => (rand(1,2) == 1 ? 'yes' : 'no'), - 'amount' => rand(321,39391), + 'in_debt' => (rand(1, 2) == 1 ? 'yes' : 'no'), + 'amount' => rand(321, 39391), 'reason' => $faker->realText(rand(100, 1000)), 'status' => 'inprogress', - 'account_id' => $contact->account_id + 'account_id' => $contact->account_id, ]); $contact->logEvent('debt', $debt->id, 'create'); @@ -212,10 +206,10 @@ public function run() 'name' => $faker->realText(rand(10, 100)), 'comment' => $faker->realText(rand(1000, 5000)), 'url' => $faker->url, - 'value_in_dollars' => rand(12,120), + 'value_in_dollars' => rand(12, 120), 'account_id' => $contact->account_id, 'is_an_idea' => 'true', - 'has_been_offered' => 'false' + 'has_been_offered' => 'false', ]); $contact->logEvent('gift', $gift->id, 'create'); diff --git a/public/index.php b/public/index.php index c5820533bc1..fc6eb491e39 100644 --- a/public/index.php +++ b/public/index.php @@ -1,9 +1,8 @@ */ diff --git a/resources/lang/cz/passwords.php b/resources/lang/cz/passwords.php index 3e73f3d5d3e..0bd3b25ac86 100644 --- a/resources/lang/cz/passwords.php +++ b/resources/lang/cz/passwords.php @@ -17,6 +17,6 @@ 'reset' => 'Heslo bylo resetováno!', 'sent' => 'Byl odeslán odkaz na reset hesla!', 'token' => 'Toto není platný odkaz na reset hesla.', - 'user' => "Nelze nalézt uživatele s touto emailovou adresou.", + 'user' => 'Nelze nalézt uživatele s touto emailovou adresou.', ]; diff --git a/resources/lang/pt-br/validation.php b/resources/lang/pt-br/validation.php index 16b654e0044..7af348a2e54 100644 --- a/resources/lang/pt-br/validation.php +++ b/resources/lang/pt-br/validation.php @@ -148,4 +148,4 @@ 'year' => 'ano', ], -]; \ No newline at end of file +]; diff --git a/resources/lang/ru/journal.php b/resources/lang/ru/journal.php index 73143557fda..db08cedf88a 100644 --- a/resources/lang/ru/journal.php +++ b/resources/lang/ru/journal.php @@ -10,4 +10,4 @@ 'journal_blank_cta' => 'Добавить вашу первую запись в журнал', 'journal_blank_description' => 'В журнал вы можете добавлять записи о событиях в вашей жизни, чтобы сохранить их.', 'delete_confirmation' => 'Are you sure you want to delete this journal entry?', -]; \ No newline at end of file +]; diff --git a/resources/lang/ru/mail.php b/resources/lang/ru/mail.php index 35709b5079e..8fa25246bff 100644 --- a/resources/lang/ru/mail.php +++ b/resources/lang/ru/mail.php @@ -8,4 +8,4 @@ 'for' => 'О:', 'footer_contact_info' => 'Добавить, просмотреть, завершить и изменить информацию об этом контакте', -]; \ No newline at end of file +]; diff --git a/resources/lang/ru/pagination.php b/resources/lang/ru/pagination.php index 607e7119437..11301d09eed 100644 --- a/resources/lang/ru/pagination.php +++ b/resources/lang/ru/pagination.php @@ -15,4 +15,4 @@ 'previous' => '« Назад', 'next' => 'Вперёд »', -]; \ No newline at end of file +]; diff --git a/resources/lang/ru/passwords.php b/resources/lang/ru/passwords.php index 0eeba26c2d1..d352b077b49 100644 --- a/resources/lang/ru/passwords.php +++ b/resources/lang/ru/passwords.php @@ -18,4 +18,4 @@ 'token' => 'Ошибочный код сброса пароля.', 'user' => 'Не удалось найти пользователя с указанным электронным адресом.', -]; \ No newline at end of file +]; diff --git a/resources/lang/ru/reminder.php b/resources/lang/ru/reminder.php index ec80901e2fe..b9f000ff9d8 100644 --- a/resources/lang/ru/reminder.php +++ b/resources/lang/ru/reminder.php @@ -8,4 +8,4 @@ 'type_email' => 'Email', 'type_birthday_kid' => 'Поздравить его(её) ребёнка с днём рождения', -]; \ No newline at end of file +]; diff --git a/resources/lang/ru/validation.php b/resources/lang/ru/validation.php index a4ecb782391..f10042b9973 100644 --- a/resources/lang/ru/validation.php +++ b/resources/lang/ru/validation.php @@ -136,4 +136,4 @@ // ], -]; \ No newline at end of file +]; diff --git a/server.php b/server.php index f65c7c444f2..1b4655ba42c 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/Browser/ExampleTest.php b/tests/Browser/ExampleTest.php index 9273239f4cf..1eb3a174df0 100644 --- a/tests/Browser/ExampleTest.php +++ b/tests/Browser/ExampleTest.php @@ -3,8 +3,6 @@ namespace Tests\Browser; use Tests\DuskTestCase; -use Laravel\Dusk\Chrome; -use Illuminate\Foundation\Testing\DatabaseMigrations; class ExampleTest extends DuskTestCase { diff --git a/tests/Browser/Feature/UploadVCardTest.php b/tests/Browser/Feature/UploadVCardTest.php index c926e3250fa..2ac3b64bfb7 100644 --- a/tests/Browser/Feature/UploadVCardTest.php +++ b/tests/Browser/Feature/UploadVCardTest.php @@ -4,8 +4,6 @@ use App\User; use Tests\DuskTestCase; -use Laravel\Dusk\Chrome; -use Illuminate\Foundation\Testing\DatabaseMigrations; class UploadVCardTest extends DuskTestCase { diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php index 68c4c682a44..e5b8c88c38f 100644 --- a/tests/DuskTestCase.php +++ b/tests/DuskTestCase.php @@ -42,12 +42,12 @@ protected function driver() */ public function signIn($user = null) { - if( is_null($user) ) - { + if (is_null($user)) { $user = factory('App\User')->create(); } $this->be($user); + return $user; } } diff --git a/tests/Feature/ActivityTest.php b/tests/Feature/ActivityTest.php index c6dfced7613..36e76106c81 100644 --- a/tests/Feature/ActivityTest.php +++ b/tests/Feature/ActivityTest.php @@ -65,7 +65,7 @@ public function test_user_can_add_an_activity() $params = [ 'summary' => $activityTitle, - 'date_it_happened' => $activityDate + 'date_it_happened' => $activityDate, ]; $response = $this->post('/people/'.$contact->id.'/activities/store', $params); @@ -105,7 +105,7 @@ public function test_user_can_edit_an_activity() 'contact_id' => $contact->id, 'account_id' => $user->account_id, 'summary' => 'This is the title', - 'date_it_happened' => \Carbon\Carbon::now() + 'date_it_happened' => \Carbon\Carbon::now(), ]); // check that we can access the edit activity view @@ -117,7 +117,7 @@ public function test_user_can_edit_an_activity() 'summary' => 'this is another test', 'date_it_happened' => \Carbon\Carbon::now(), 'activity_type_id' => null, - 'description' => null + 'description' => null, ]; $this->put('/people/'.$contact->id.'/activities/'.$activity->id, $params); @@ -154,7 +154,7 @@ public function test_user_can_delete_an_activity() 'contact_id' => $contact->id, 'account_id' => $user->account_id, 'summary' => 'This is the title', - 'date_it_happened' => \Carbon\Carbon::now() + 'date_it_happened' => \Carbon\Carbon::now(), ]); $response = $this->get('/people/'.$contact->id); diff --git a/tests/Feature/CallTest.php b/tests/Feature/CallTest.php index 3476b4b8ac0..e4c913fa4d3 100644 --- a/tests/Feature/CallTest.php +++ b/tests/Feature/CallTest.php @@ -66,7 +66,7 @@ public function test_user_can_add_a_call_without_a_description() $params = [ 'called_at' => '2013-01-01', - 'content' => null + 'content' => null, ]; $response = $this->post('/people/'.$contact->id.'/call/store', $params); @@ -104,7 +104,7 @@ public function test_user_can_add_a_call_with_a_description() $params = [ 'called_at' => '2013-01-01', - 'content' => 'This is a test call' + 'content' => 'This is a test call', ]; $response = $this->post('/people/'.$contact->id.'/call/store', $params); @@ -144,7 +144,7 @@ public function test_user_can_delete_a_call() 'contact_id' => $contact->id, 'account_id' => $user->account_id, 'content' => 'this is a test', - 'called_at' => '2013-01-01 00:00:00' + 'called_at' => '2013-01-01 00:00:00', ]); $response = $this->get('/people/'.$contact->id); diff --git a/tests/Feature/ContactTest.php b/tests/Feature/ContactTest.php index 636ba8c3565..bd92b3b1bfb 100644 --- a/tests/Feature/ContactTest.php +++ b/tests/Feature/ContactTest.php @@ -8,7 +8,6 @@ class ContactTest extends FeatureTestCase { - use DatabaseTransactions; /** @@ -72,7 +71,6 @@ public function test_user_can_add_note_to_contact() 'account_id' => $user->account_id, 'body' => $body, ]); - } public function test_user_can_add_activity_to_contact() @@ -123,7 +121,6 @@ public function test_user_can_be_reminded_about_an_event_once() 'account_id' => $user->account_id, ]) ); - } public function test_user_can_add_a_task_to_a_contact() @@ -136,7 +133,7 @@ public function test_user_can_add_a_task_to_a_contact() ]; $this->post( - '/people/' . $contact->id . '/tasks/store', + '/people/'.$contact->id.'/tasks/store', $task ); @@ -162,7 +159,7 @@ public function test_user_can_add_a_gift_idea_to_a_contact() ]; $this->post( - '/people/' . $contact->id . '/gifts/store', + '/people/'.$contact->id.'/gifts/store', $gift ); @@ -223,15 +220,13 @@ public function test_user_can_be_owed_debt_by_a_contact() ]); } - public function test_a_contact_can_have_food_preferences() { list($user, $contact) = $this->fetchUser(); $food = ['food' => $this->faker->sentence()]; - $this->post('/people/' . $contact->id . '/food/save', $food); - + $this->post('/people/'.$contact->id.'/food/save', $food); $food['id'] = $contact->id; $this->changeArrayKey('food', 'food_preferencies', $food); @@ -243,7 +238,7 @@ public function test_a_contact_can_be_deleted() { list($user, $contact) = $this->fetchUser(); - $this->get('/people/' . $contact->id . '/delete'); + $this->get('/people/'.$contact->id.'/delete'); $this->assertDatabaseMissing('contacts', [ 'id' => $contact->id, diff --git a/tests/Feature/InstanceTest.php b/tests/Feature/InstanceTest.php index 57b07eb6528..e8903b07f48 100644 --- a/tests/Feature/InstanceTest.php +++ b/tests/Feature/InstanceTest.php @@ -3,11 +3,9 @@ namespace Tests\Feature; use Tests\TestCase; -use Illuminate\Foundation\Testing\DatabaseTransactions; class InstanceTest extends TestCase { - /** * Check if, by default, the disable signups feature is turned off in an * instance. @@ -35,7 +33,7 @@ public function test_disable_signup_set_to_true_hides_signup_button_and_register putenv('APP_DISABLE_SIGNUP=true'); // reload the environment as we've changed the ENV variable - $app = require __DIR__ . '/../../bootstrap/app.php'; + $app = require __DIR__.'/../../bootstrap/app.php'; $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap(); $response = $this->get('/'); diff --git a/tests/Feature/NoteTest.php b/tests/Feature/NoteTest.php index b18d4868817..9bcc339a935 100644 --- a/tests/Feature/NoteTest.php +++ b/tests/Feature/NoteTest.php @@ -63,7 +63,7 @@ public function test_user_can_add_a_note() $noteBody = 'This is a note that I would like to see'; $params = [ - 'body' => $noteBody + 'body' => $noteBody, ]; $response = $this->post('/people/'.$contact->id.'/notes/store', $params); @@ -101,7 +101,7 @@ public function test_user_can_edit_a_note() $note = factory(\App\Note::class)->create([ 'contact_id' => $contact->id, 'account_id' => $user->account_id, - 'body' => 'this is a test' + 'body' => 'this is a test', ]); // check that we can access the edit note view @@ -110,7 +110,7 @@ public function test_user_can_edit_a_note() // now edit the note $params = [ - 'body' => 'this is another test' + 'body' => 'this is another test', ]; $this->put('/people/'.$contact->id.'/notes/'.$note->id, $params); @@ -146,7 +146,7 @@ public function test_user_can_delete_a_note() $note = factory(\App\Note::class)->create([ 'contact_id' => $contact->id, 'account_id' => $user->account_id, - 'body' => 'this is a test' + 'body' => 'this is a test', ]); $response = $this->get('/people/'.$contact->id); diff --git a/tests/Feature/VersionCheckTest.php b/tests/Feature/VersionCheckTest.php index 65e5f0172a8..1847c575625 100644 --- a/tests/Feature/VersionCheckTest.php +++ b/tests/Feature/VersionCheckTest.php @@ -21,7 +21,7 @@ public function test_check_version_set_to_false_disables_the_check() putenv('CHECK_VERSION=false'); // reload the environment as we've changed the ENV variable - $app = require __DIR__ . '/../../bootstrap/app.php'; + $app = require __DIR__.'/../../bootstrap/app.php'; $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap(); $resultCommand = $this->artisan('monica:ping'); diff --git a/tests/FeatureTestCase.php b/tests/FeatureTestCase.php index 49d5fca2961..2b1240f299e 100644 --- a/tests/FeatureTestCase.php +++ b/tests/FeatureTestCase.php @@ -4,7 +4,6 @@ class FeatureTestCase extends TestCase { - /** * Create a user and sign in as that user. If a user * object is passed, then sign in as that user. @@ -14,12 +13,12 @@ class FeatureTestCase extends TestCase */ public function signIn($user = null) { - if( is_null($user) ) - { + if (is_null($user)) { $user = factory('App\User')->create(); } $this->be($user); + return $user; } -} \ No newline at end of file +} diff --git a/tests/Helper/DateHelperTest.php b/tests/Helper/DateHelperTest.php index c6db0bb8e7d..72e2183ee6b 100644 --- a/tests/Helper/DateHelperTest.php +++ b/tests/Helper/DateHelperTest.php @@ -5,9 +5,6 @@ use Carbon\Carbon; use Tests\FeatureTestCase; use App\Helpers\DateHelper; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; -use Illuminate\Foundation\Testing\DatabaseTransactions; class DateHelperTest extends FeatureTestCase { @@ -118,7 +115,6 @@ public function test_add_time_according_to_frequency_type_returns_the_right_valu DateHelper::addTimeAccordingToFrequencyType($testDate, 'week', 1)->toDateString() ); - $testDate = DateHelper::createDateFromFormat($date, $timezone); $this->assertEquals( '2017-02-22', diff --git a/tests/Helper/MoneyHelperTest.php b/tests/Helper/MoneyHelperTest.php index 79ec5e0add4..73fae9a60b8 100644 --- a/tests/Helper/MoneyHelperTest.php +++ b/tests/Helper/MoneyHelperTest.php @@ -2,10 +2,10 @@ namespace Tests\Helper; -use App\Currency; use App\User; -use App\Helpers\MoneyHelper; +use App\Currency; use Tests\TestCase; +use App\Helpers\MoneyHelper; use Illuminate\Foundation\Testing\DatabaseTransactions; class MoneyHelperTest extends TestCase @@ -15,7 +15,7 @@ class MoneyHelperTest extends TestCase public function testFormatReturnsAmountWithCurrencySymbol() { $currency = new Currency(); - $currency->symbol = "€"; + $currency->symbol = '€'; $this->assertEquals('€500', MoneyHelper::format(500, $currency)); } @@ -24,7 +24,7 @@ public function testFormatUsesCurrencySettingIfDefined() { $currency = Currency::where('iso', 'GBP')->first(); $user = factory(User::class)->create([ - 'currency_id' => $currency->id + 'currency_id' => $currency->id, ]); $this->actingAs($user); diff --git a/tests/Helper/RandomHelperTest.php b/tests/Helper/RandomHelperTest.php index 24a032033a0..8156b4d573b 100644 --- a/tests/Helper/RandomHelperTest.php +++ b/tests/Helper/RandomHelperTest.php @@ -4,9 +4,6 @@ use Tests\TestCase; use App\Helpers\RandomHelper; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; -use Illuminate\Foundation\Testing\DatabaseTransactions; class RandomHelperTest extends TestCase { diff --git a/tests/Unit/ActivityTest.php b/tests/Unit/ActivityTest.php index 6470c517f4b..dc77ddfa198 100644 --- a/tests/Unit/ActivityTest.php +++ b/tests/Unit/ActivityTest.php @@ -5,8 +5,6 @@ use App\Activity; use Carbon\Carbon; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; class ActivityTest extends TestCase @@ -43,7 +41,7 @@ public function testGetTitleReturnsAString() $type = factory(\App\ActivityType::class)->create(); $activity = factory(\App\Activity::class)->create([ - 'activity_type_id' => $type->id + 'activity_type_id' => $type->id, ]); $this->assertEquals($type->key, $activity->getTitle()); diff --git a/tests/Unit/ContactTest.php b/tests/Unit/ContactTest.php index 09ae0b1780b..dcb99e2cccb 100644 --- a/tests/Unit/ContactTest.php +++ b/tests/Unit/ContactTest.php @@ -2,14 +2,11 @@ namespace Tests\Unit; -use App\User; use App\Call; use App\Contact; use Carbon\Carbon; use Tests\TestCase; use App\SignificantOther; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; class ContactTest extends TestCase diff --git a/tests/Unit/EntryTest.php b/tests/Unit/EntryTest.php index ac89d2a295c..fda5fef2230 100644 --- a/tests/Unit/EntryTest.php +++ b/tests/Unit/EntryTest.php @@ -4,8 +4,6 @@ use App\Entry; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; class EntryTest extends TestCase diff --git a/tests/Unit/GiftTest.php b/tests/Unit/GiftTest.php index bb84982ebce..df335ab7b58 100644 --- a/tests/Unit/GiftTest.php +++ b/tests/Unit/GiftTest.php @@ -5,8 +5,6 @@ use App\Gift; use Carbon\Carbon; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; class GiftTest extends TestCase diff --git a/tests/Unit/ImportVCardsTest.php b/tests/Unit/ImportVCardsTest.php index 213d08ceca2..675b82f4093 100644 --- a/tests/Unit/ImportVCardsTest.php +++ b/tests/Unit/ImportVCardsTest.php @@ -2,15 +2,13 @@ namespace Tests\Unit; +use App\User; use App\Account; use App\Contact; use App\Country; -use App\Helpers\RandomHelper; -use App\User; use Mockery as m; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; +use App\Helpers\RandomHelper; use Illuminate\Foundation\Testing\DatabaseTransactions; class ImportVCardsTest extends TestCase @@ -32,7 +30,6 @@ public function testItValidatesUser() $this->assertEquals(0, $exitCode); } - public function testItValidatesFile() { $user = $this->getUser(); @@ -90,7 +87,8 @@ public function testItImportsContacts() $this->assertEquals(0, $exitCode); } - private function getUser() { + private function getUser() + { $user = new User(); $user->first_name = 'John'; $user->last_name = 'Doe'; @@ -106,5 +104,4 @@ private function getUser() { return $user; } - } diff --git a/tests/Unit/KidTest.php b/tests/Unit/KidTest.php index 21b19756ec4..504471326fa 100644 --- a/tests/Unit/KidTest.php +++ b/tests/Unit/KidTest.php @@ -5,8 +5,6 @@ use App\Kid; use Carbon\Carbon; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; class KidTest extends TestCase diff --git a/tests/Unit/NoteTest.php b/tests/Unit/NoteTest.php index b84687850d3..1b9aeb79395 100644 --- a/tests/Unit/NoteTest.php +++ b/tests/Unit/NoteTest.php @@ -3,10 +3,7 @@ namespace Tests\Unit; use App\Note; -use Carbon\Carbon; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; class NoteTest extends TestCase diff --git a/tests/Unit/ReminderTest.php b/tests/Unit/ReminderTest.php index b2425f02f50..84822b1198c 100644 --- a/tests/Unit/ReminderTest.php +++ b/tests/Unit/ReminderTest.php @@ -5,8 +5,6 @@ use App\Reminder; use Carbon\Carbon; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; class ReminderTest extends TestCase diff --git a/tests/Unit/SearchTest.php b/tests/Unit/SearchTest.php index 02d90d994d4..5376f61eaea 100644 --- a/tests/Unit/SearchTest.php +++ b/tests/Unit/SearchTest.php @@ -2,8 +2,8 @@ namespace Tests\Unit; -use Illuminate\Foundation\Testing\DatabaseTransactions; use Tests\TestCase; +use Illuminate\Foundation\Testing\DatabaseTransactions; class SearchTest extends TestCase { @@ -21,7 +21,7 @@ public function testSearchContactsReturnsCollection() /** @test */ public function testSearchContactsThroughFirstNameAndResultContainsContact() { - $contact = factory('App\Contact')->create([ 'first_name' => 'FirstName' ]); + $contact = factory('App\Contact')->create(['first_name' => 'FirstName']); $searchResults = $contact->search($contact->first_name, $contact->account_id); $this->assertTrue($searchResults->contains($contact)); @@ -49,7 +49,7 @@ public function testSearchContactsThroughLastNameAndResultContainsContact() /** @test */ public function testSearchContactsThroughEmailAndResultContainsContact() { - $contact = factory(\App\Contact::class)->create([ 'email' => 'email@email.com' ]); + $contact = factory(\App\Contact::class)->create(['email' => 'email@email.com']); $searchResults = $contact->search($contact->email, $contact->account_id); $this->assertTrue($searchResults->contains($contact)); @@ -58,7 +58,7 @@ public function testSearchContactsThroughEmailAndResultContainsContact() /** @test */ public function testSearchContactsThroughStreetAndResultContainsContact() { - $contact = factory(\App\Contact::class)->create([ 'street' => 'Street' ]); + $contact = factory(\App\Contact::class)->create(['street' => 'Street']); $searchResults = $contact->search($contact->street, $contact->account_id); $this->assertTrue($searchResults->contains($contact)); @@ -67,7 +67,7 @@ public function testSearchContactsThroughStreetAndResultContainsContact() /** @test */ public function testSearchContactsThroughPostalCodeAndResultContainsContact() { - $contact = factory(\App\Contact::class)->create([ 'postal_code' => '33080', ]); + $contact = factory(\App\Contact::class)->create(['postal_code' => '33080']); $searchResults = $contact->search($contact->postal_code, $contact->account_id); $this->assertTrue($searchResults->contains($contact)); @@ -76,7 +76,7 @@ public function testSearchContactsThroughPostalCodeAndResultContainsContact() /** @test */ public function testSearchContactsThroughProvinceAndResultContainsContact() { - $contact = factory(\App\Contact::class)->create([ 'province' => 'Province' ]); + $contact = factory(\App\Contact::class)->create(['province' => 'Province']); $searchResults = $contact->search($contact->province, $contact->account_id); $this->assertTrue($searchResults->contains($contact)); @@ -85,7 +85,7 @@ public function testSearchContactsThroughProvinceAndResultContainsContact() /** @test */ public function testSearchContactsThroughFoodPreferencesAndResultContainsContact() { - $contact = factory(\App\Contact::class)->create([ 'food_preferencies' => 'Food Preference' ]); + $contact = factory(\App\Contact::class)->create(['food_preferencies' => 'Food Preference']); $searchResults = $contact->search($contact->food_preferencies, $contact->account_id); $this->assertTrue($searchResults->contains($contact)); @@ -94,7 +94,7 @@ public function testSearchContactsThroughFoodPreferencesAndResultContainsContact /** @test */ public function testSearchContactsThroughJobAndResultContainsContact() { - $contact = factory(\App\Contact::class)->create([ 'job' => 'Job' ]); + $contact = factory(\App\Contact::class)->create(['job' => 'Job']); $searchResults = $contact->search($contact->job, $contact->account_id); $this->assertTrue($searchResults->contains($contact)); diff --git a/tests/Unit/SignificantOtherTest.php b/tests/Unit/SignificantOtherTest.php index 1f0d3bf271e..3f7295a64e9 100644 --- a/tests/Unit/SignificantOtherTest.php +++ b/tests/Unit/SignificantOtherTest.php @@ -5,8 +5,6 @@ use Carbon\Carbon; use Tests\TestCase; use App\SignificantOther; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; class SignificantOtherTest extends TestCase diff --git a/tests/Unit/TaskTest.php b/tests/Unit/TaskTest.php index afb774c23b2..e98bc63d005 100644 --- a/tests/Unit/TaskTest.php +++ b/tests/Unit/TaskTest.php @@ -3,11 +3,8 @@ namespace Tests\Unit; use App\Task; -use App\Contact; use Carbon\Carbon; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; class TaskTest extends TestCase @@ -63,7 +60,7 @@ public function testToggle() $task = factory(\App\Task::class)->make([ 'contact_id' => $contact->id, - 'status' => 'inprogress' + 'status' => 'inprogress', ]); $this->assertEquals( diff --git a/tests/Unit/UserTest.php b/tests/Unit/UserTest.php index c31d005a689..2844219946e 100644 --- a/tests/Unit/UserTest.php +++ b/tests/Unit/UserTest.php @@ -3,10 +3,7 @@ namespace Tests\Unit; use App\User; -use Carbon\Carbon; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; class UserTest extends TestCase