Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions app/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App;

use DB;
use Carbon\Carbon;
use Laravel\Cashier\Billable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
Expand Down Expand Up @@ -46,7 +45,7 @@ public static function createDefault($first_name, $last_name, $email, $password)
// create new account
$account = new self;
$account->api_key = str_random(30);
$account->created_at = Carbon::now();
$account->created_at = now();
$account->save();

$account->populateDefaultFields($account);
Expand Down Expand Up @@ -531,8 +530,8 @@ public function populateDefaultReminderRulesTable()
*/
public function getRemindersForMonth(int $month)
{
$startOfMonth = \Carbon\Carbon::now()->addMonthsNoOverflow($month)->startOfMonth();
$endInThreeMonths = \Carbon\Carbon::now()->addMonthsNoOverflow($month)->endOfMonth();
$startOfMonth = now()->addMonthsNoOverflow($month)->startOfMonth();
$endInThreeMonths = now()->addMonthsNoOverflow($month)->endOfMonth();

return auth()->user()->account->reminders()
->whereBetween('next_expected_date', [$startOfMonth, $endInThreeMonths])
Expand Down
3 changes: 1 addition & 2 deletions app/Console/Commands/SendNotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Console\Commands;

use Carbon\Carbon;
use App\Notification;
use Illuminate\Console\Command;
use App\Jobs\Notification\ScheduleNotification;
Expand Down Expand Up @@ -30,7 +29,7 @@ class SendNotifications extends Command
*/
public function handle()
{
$notifications = Notification::where('trigger_date', '<', Carbon::now()->addDays(2))
$notifications = Notification::where('trigger_date', '<', now()->addDays(2))
->orderBy('trigger_date', 'asc')->get();

foreach ($notifications as $notification) {
Expand Down
3 changes: 1 addition & 2 deletions app/Console/Commands/SendReminders.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\User;
use App\Account;
use App\Reminder;
use Carbon\Carbon;
use App\Jobs\SendReminderEmail;
use Illuminate\Console\Command;
use App\Jobs\SetNextReminderDate;
Expand Down Expand Up @@ -37,7 +36,7 @@ public function handle()
// Why 2? because in terms of timezone, we can have up to more than 24 hours
// between two timezones and we need to take into accounts reminders
// that are not in the same timezone.
$reminders = Reminder::where('next_expected_date', '<', Carbon::now()->addDays(2))
$reminders = Reminder::where('next_expected_date', '<', now()->addDays(2))
->orderBy('next_expected_date', 'asc')->get();

foreach ($reminders as $reminder) {
Expand Down
6 changes: 3 additions & 3 deletions app/Helpers/DateHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public static function addTimeAccordingToFrequencyType(Carbon $date, $frequency,
*/
public static function getMonthAndYear(int $month)
{
$date = Date::now()->addMonthsNoOverflow($month);
$date = now()->addMonthsNoOverflow($month);
$format = 'M Y';

return $date->format($format);
Expand All @@ -193,10 +193,10 @@ public static function getMonthAndYear(int $month)
public static function getNextTheoriticalBillingDate(String $interval)
{
if ($interval == 'monthly') {
return Date::now()->addMonth();
return now()->addMonth();
}

return Date::now()->addYear();
return now()->addYear();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Api/ApiNoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function store(Request $request)
}

if ($request->get('is_favorited')) {
$note->favorited_at = \Carbon\Carbon::now();
$note->favorited_at = now();
$note->save();
}

Expand Down Expand Up @@ -134,7 +134,7 @@ public function update(Request $request, $noteId)
}

if ($request->get('is_favorited')) {
$note->favorited_at = \Carbon\Carbon::now();
$note->favorited_at = now();
$note->save();
} else {
$note->favorited_at = null;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Contacts/NotesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function toggle(NoteToggleRequest $request, Contact $contact, Note $note)
$note->is_favorited = false;
} else {
$note->is_favorited = true;
$note->favorited_at = \Carbon\Carbon::now();
$note->favorited_at = now();
}

$contact->logEvent('note', $note->id, 'update');
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Contacts/TasksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function toggle(TaskToggleRequest $request, Contact $contact, Task $task)
$task->completed = false;
} else {
$task->completed = true;
$task->completed_at = \Carbon\Carbon::now();
$task->completed_at = now();
}

$contact->logEvent('task', $task->id, 'update');
Expand Down
8 changes: 4 additions & 4 deletions app/Http/Controllers/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function show(Contact $contact)

$reminders = $contact->getRemindersAboutRelatives();

$contact->last_consulted_at = \Carbon\Carbon::now(auth()->user()->timezone);
$contact->last_consulted_at = now(auth()->user()->timezone);
$contact->save();

return view('people.profile')
Expand All @@ -201,9 +201,9 @@ public function show(Contact $contact)
public function edit(Contact $contact)
{
$age = (string) (! is_null($contact->birthdate) ? $contact->birthdate->getAge() : 0);
$birthdate = ! is_null($contact->birthdate) ? $contact->birthdate->date->format('Y-m-d') : \Carbon\Carbon::now()->format('Y-m-d');
$day = ! is_null($contact->birthdate) ? $contact->birthdate->date->day : \Carbon\Carbon::now()->day;
$month = ! is_null($contact->birthdate) ? $contact->birthdate->date->month : \Carbon\Carbon::now()->month;
$birthdate = ! is_null($contact->birthdate) ? $contact->birthdate->date->format('Y-m-d') : now()->format('Y-m-d');
$day = ! is_null($contact->birthdate) ? $contact->birthdate->date->day : now()->day;
$month = ! is_null($contact->birthdate) ? $contact->birthdate->date->month : now()->month;

return view('people.edit')
->withContact($contact)
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/JournalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function get(JournalEntry $journalEntry)
public function storeDay(DaysRequest $request)
{
$day = auth()->user()->account->days()->create([
'date' => \Carbon\Carbon::now(auth()->user()->timezone),
'date' => now(auth()->user()->timezone),
'rate' => $request->get('rate'),
]);

Expand Down
4 changes: 2 additions & 2 deletions app/Jobs/AddContactFromVCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function handle()
protected function workInit($matchCount)
{
$this->matchCount = $matchCount;
$this->importJob->started_at = \Carbon\Carbon::now();
$this->importJob->started_at = now();

return true;
}
Expand All @@ -83,7 +83,7 @@ protected function workEnd($numberOfContactsInTheFile, $skippedContacts, $import
$this->importJob->contacts_found = $numberOfContactsInTheFile;
$this->importJob->contacts_skipped = $skippedContacts;
$this->importJob->contacts_imported = $importedContacts;
$this->importJob->ended_at = \Carbon\Carbon::now();
$this->importJob->ended_at = now();
$this->importJob->save();

Storage::disk('public')->delete($this->importJob->filename);
Expand Down
3 changes: 1 addition & 2 deletions app/Jobs/ExportAccountAsSQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Jobs;

use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Storage;
Expand Down Expand Up @@ -76,7 +75,7 @@ public function handle()
$sql = '# ************************************************************
# '.$user->first_name.' '.$user->last_name." dump of data
# {$this->file}
# Export date: ".Carbon::now().'
# Export date: ".now().'
# ************************************************************

'.PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion app/JournalEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function account()
public function add($resourceToLog)
{
$this->account_id = $resourceToLog->account_id;
$this->date = \Carbon\Carbon::now();
$this->date = now();
$this->journalable_id = $resourceToLog->id;
$this->journalable_type = get_class($resourceToLog);
$this->save();
Expand Down
2 changes: 1 addition & 1 deletion app/Reminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function scheduleSingleNotification(int $numberOfDaysBefore)
{
$date = DateHelper::getDateMinusGivenNumberOfDays($this->next_expected_date, $numberOfDaysBefore);

if ($date->lte(Carbon::now())) {
if ($date->lte(now())) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions app/SpecialDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function getAge()
return;
}

return $this->date->diffInYears(Carbon::now());
return $this->date->diffInYears(now());
}

/**
Expand All @@ -178,7 +178,7 @@ public function getAge()
public function createFromAge(int $age)
{
$this->is_age_based = true;
$this->date = Carbon::now()->subYears($age)->month(1)->day(1);
$this->date = now()->subYears($age)->month(1)->day(1);
$this->save();

return $this;
Expand All @@ -197,7 +197,7 @@ public function createFromDate(int $year, int $month, int $day)
if ($year != 0) {
$date = Carbon::createFromDate($year, $month, $day);
} else {
$date = Carbon::createFromDate(Carbon::now()->year, $month, $day);
$date = Carbon::createFromDate(now()->year, $month, $day);
$this->is_year_unknown = true;
}

Expand Down
6 changes: 3 additions & 3 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static function createDefault($account_id, $first_name, $last_name, $emai
$user->email = $email;
$user->password = bcrypt($password);
$user->timezone = config('app.timezone');
$user->created_at = Carbon::now();
$user->created_at = now();
$user->locale = \App::getLocale();
$user->save();

Expand Down Expand Up @@ -176,7 +176,7 @@ public function hasAlreadyRatedToday()
{
try {
Day::where('account_id', $this->account_id)
->where('date', \Carbon\Carbon::now($this->timezone)->format('Y-m-d'))
->where('date', now($this->timezone)->format('Y-m-d'))
->firstOrFail();
} catch (ModelNotFoundException $e) {
return false;
Expand Down Expand Up @@ -224,7 +224,7 @@ public function shouldBeReminded(Carbon $date)
{
$dateOfReminder = $date->hour(0)->minute(0)->second(0)->toDateString();

$currentDate = Carbon::now($this->timezone);
$currentDate = now($this->timezone);

$currentHourOnUserTimezone = $currentDate->format('H:00');
$currentDateOnUserTimezone = $currentDate->hour(0)->minute(0)->second(0)->toDateString();
Expand Down
2 changes: 1 addition & 1 deletion database/factories/ModelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,6 @@
'stripe_id' => $stripe_id,
'stripe_plan' => $stripe_plan ?: $faker->randomElement(['plan-1', 'plan-2', 'plan-3']),
'quantity' => 1,
'created_at' => \Carbon\Carbon::now(),
'created_at' => now(),
];
});
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function up()
'contact_id' => $contact->id,
'contact_field_type_id' => $emailId->id,
'data' => $contact->email,
'created_at' => \Carbon\Carbon::now(),
'created_at' => now(),
]);
}

Expand All @@ -57,7 +57,7 @@ public function up()
'contact_id' => $contact->id,
'contact_field_type_id' => $idPhoneNumber->id,
'data' => $contact->phone_number,
'created_at' => \Carbon\Carbon::now(),
'created_at' => now(),
]);
}

Expand All @@ -67,7 +67,7 @@ public function up()
'contact_id' => $contact->id,
'contact_field_type_id' => $idFacebook->id,
'data' => $contact->facebook_profile_url,
'created_at' => \Carbon\Carbon::now(),
'created_at' => now(),
]);
}

Expand All @@ -77,7 +77,7 @@ public function up()
'contact_id' => $contact->id,
'contact_field_type_id' => $idTwitter->id,
'data' => $contact->twitter_profile_url,
'created_at' => \Carbon\Carbon::now(),
'created_at' => now(),
]);
}
}
Expand Down
8 changes: 4 additions & 4 deletions database/migrations/2017_12_04_165421_move_ages_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function up()
'is_age_based' => false,
'date' => $contact->deceased_date,
'reminder_id' => null,
'created_at' => \Carbon\Carbon::now(),
'created_at' => now(),
]);
}

Expand All @@ -43,7 +43,7 @@ public function up()
'is_age_based' => true,
'date' => $contact->birthdate,
'reminder_id' => $contact->birthday_reminder_id,
'created_at' => \Carbon\Carbon::now(),
'created_at' => now(),
]);

break;
Expand All @@ -54,7 +54,7 @@ public function up()
'is_age_based' => false,
'date' => $contact->birthdate,
'reminder_id' => $contact->birthday_reminder_id,
'created_at' => \Carbon\Carbon::now(),
'created_at' => now(),
]);

break;
Expand All @@ -68,7 +68,7 @@ public function up()
'is_age_based' => false,
'date' => $contact->first_met,
'reminder_id' => null,
'created_at' => \Carbon\Carbon::now(),
'created_at' => now(),
]);
}

Expand Down
Loading