Laravel PhpStorm无法跟踪某些文件更改

Laravel PhpStorm无法跟踪某些文件更改,laravel,phpstorm,Laravel,Phpstorm,我注意到我在PhpStorm中的一些文件没有检测到任何更改,而在其他文件中,如果我做了一些代码更改,我可以立即看到更改 是否有办法在PhpStorm设置中找到自动检测所有已编辑文件的位置 我已经检查了我的.gitignore文件,但是我看不到不可跟踪的文件不在那里 例如,在我的UserScopeTrait.php文件中,我做了代码更改,并且在我查看git状态时自动看到了更改。但是在我的UserTrait.php文件中,如果我对其进行了更改,则找不到任何更改 以下是我做了一些更改的确切文件: &l

我注意到我在PhpStorm中的一些文件没有检测到任何更改,而在其他文件中,如果我做了一些代码更改,我可以立即看到更改

是否有办法在PhpStorm设置中找到自动检测所有已编辑文件的位置

我已经检查了我的
.gitignore
文件,但是我看不到不可跟踪的文件不在那里

例如,在我的
UserScopeTrait.php
文件中,我做了代码更改,并且在我查看git状态时自动看到了更改。但是在我的
UserTrait.php
文件中,如果我对其进行了更改,则找不到任何更改

以下是我做了一些更改的确切文件:

<?PHP
namespace App\Traits;
use App\Jobs\SendEmployeeInvitationEmail;
use App\Jobs\SendEmployeeInvitationMondayTuesdayJob;
use App\Jobs\UpdateAdminEmployeeSurvey;
use App\Language;
use App\Location;
use App\LocationManager;
use App\Mail\SendWeeklySurvey;
use App\Mail\SurveyResultsAvailableNotification;
use App\Mail\SurveySentNotification;
use App\Repositories\UserCompanyRepository;
use App\Survey;
use App\Team;
use App\TeamManager;
use App\User;
use App\UserCompany;
use App\UsersAnswer;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Mail;

trait UserScopeTrait
{
public function scopeDispatchEmployeeInvites($query)
{
    $users = $query->whereHas('userCompany', function ($company) {
        $company->where('company_id', auth()->user()->company->id)->where('role_name', 'employee');
    })->where('invite_sent', 0)->get();

    $auth = auth()->user();
    $dispatcher = new User();
    $toSend = 0;
    $notifyState = [];
    // this is the changes I've made
    adsfdsfasdfas
    if ($users->count() == 5) {
        /**
         * first survey batch send
         * date of action: all days except Monday, Tuesday
         * send invitation & update survey details for admin and then mimic admin survey details to employee
         */
        if (!Carbon::now()->isMonday() && !Carbon::now()->isTuesday()) {
            $this->updateSurveyDetailsAdminEmployee(null, $auth, 'admin');
        }
    }

    foreach ($users as $employee) {

        $notifyState['total'] = $users->count();

        $employee->invite_sent = true;
        $employee->save();
        $toSend++;

        if ($notifyState['total'] == $toSend) {
            $notifyState['last'] = true;

            // Admin receive an email notification about surveys sent
            $dispatcher->dispatchAdminSurveySentNotification($auth);
        } else {
            $notifyState['last'] = false;
        }
        /**
         * counter reaches to 5 this means that this is the first survey
         * and should update survey details for both admin & employee
         */
        if ($users->count() == 5) {
            if (Carbon::now()->isMonday()||Carbon::now()->isTuesday()) {
                /**
                 * first survey batch send
                 * date of action: Monday, Tuesday
                 * send invitation only
                 */
                SendEmployeeInvitationMondayTuesdayJob::dispatch($employee, auth()->user())->onQueue('notification');
            } else {
                /**
                 * first survey batch send
                 * date of action: all days except Monday, Tuesday
                 * send invitation & mimic admin survey details to employee
                 */
                $this->updateSurveyDetailsAdminEmployee($employee, $auth, 'employee');

                SendEmployeeInvitationEmail::dispatch($auth, $employee, $notifyState)->onQueue('notification');
            }
        }
        /**
         * not first survey batch & single execution
         */
        else {
            if ($users->count() >=2 && $users->count() <= 3) {
                /**
                 * not first survey batch execution
                 * date of action: Monday, Tuesday
                 * send invitation only
                 */
                if (Carbon::now()->isMonday()||Carbon::now()->isTuesday()) {
                    SendEmployeeInvitationMondayTuesdayJob::dispatch($employee, auth()->user())->onQueue('notification');
                }
                /**
                 * not first survey batch execution
                 * date of action: all days except Monday, Tuesday
                 * send invitation & update survey details for employee only mimic admin survey details
                 */
                else {
                    $this->updateSurveyDetailsAdminEmployee($employee, $auth, 'employee');
                    SendEmployeeInvitationEmail::dispatch($auth, $employee, $notifyState)->onQueue('notification');
                }
            }

            if ($users->count() == 1) {
                /**
                 * not first survey single execution
                 * date of action: Monday, Tuesday
                 * send invitation only
                 */
                if (Carbon::now()->isMonday()||Carbon::now()->isTuesday()) {
                    SendEmployeeInvitationMondayTuesdayJob::dispatch($employee, auth()->user())->onQueue('notification');
                }
                /**
                 * not first survey single execution
                 * date of action: all days except Monday, Tuesday
                 * send invitation & update survey details for employee mimic admin survey details
                 */
                else {
                    $this->updateSurveyDetailsAdminEmployee($employee, $auth, 'employee');
                    SendEmployeeInvitationEmail::dispatch($auth, $employee, $notifyState)->onQueue('notification');
                }
            }
        }
    }
}
private function updateSurveyDetailsAdminEmployee($employee, $auth, $type)
{
    $currentDate    = Carbon::now();
    $nextSurveyDate = clone $currentDate;

    if ($type == 'admin') {
        date_default_timezone_set($auth->timezone);
        // Set next_survey_date base on account owner survey frequency setting
        if ($auth->account->survey_frequency == 'every_week_wednesday') {
            $nextSurveyDate = $nextSurveyDate->next(Carbon::WEDNESDAY);
        } else {
            $nextSurveyDate = $nextSurveyDate->next(Carbon::WEDNESDAY)->next(Carbon::WEDNESDAY);
        }

        // Update survey_date and next_survey_number for admin
        $auth->current_survey_date = $currentDate;
        $auth->next_survey_date    = $nextSurveyDate;
        $auth->first_survey        = true;
        $auth->next_survey_number  = (new User())->getNextSurveyNumber($auth);
        $auth->save();
    }
    else if ($type == 'employee') {
        date_default_timezone_set($employee->timezone);
        // Update next_survey_date and next_survey_number for employee
        $employee->next_survey_date    = $auth->next_survey_date;
        $employee->current_survey_id   = $auth->current_survey_id;
        $employee->current_survey_date = $currentDate;
        $employee->next_survey_number  = $auth->next_survey_number;
        $employee->invite_sent_time    = now()->toDateTimeString();

        $employee->save();
    }
}
public function scopeUpdateMessageNotificationCounter($query, $data)
{
    $managers = $query->whereHas('userCompany', function ($userCompany) use ($data) {
        $userCompany->where('company_id', (new User())->authUserCompanyId())->where('role_name', 'manager');
    })->get();

    foreach ($managers as $user) {

        $user->wait_for_my_reply = $data['waitingForMyReply'];
        $user->wait_for_employee_organization_reply = $data['waitingForEmployeeOrganizationReply'];

        $user->save();
    }

    $admin = User::whereHas('company', function ($company) {
        $company->where('id', (new User())->authUserCompanyId());
    })->first();

    $admin->wait_for_my_reply = $data['waitingForMyReply'];
    $admin->wait_for_employee_organization_reply = $data['waitingForEmployeeOrganizationReply'];

    $admin->save();
}

public function scopeUserHasSurvey($query, $id)
{
    $currentSurveyDate = $query->find($id)->current_survey_date;
    $nextSurveyDate = $query->find($id)->next_survey_date;

    if ($currentSurveyDate != null && $nextSurveyDate != null) {
        return true;
    } else {
        return false;
    }
}

public function scopeUserCompanyId($query, $id)
{
    return $query->find($id)->company->id;
}

public function scopeUserCurrentSurveyId($query, $id)
{
    return $query->find($id)->current_survey_id;
}

public function scopeFilterAdminAccess()
{
    if (auth()->user()->freeze_account > 0 && auth()->user()->role_name == 'admin') {
        return redirect()->route('billing')->with(['info' => 'Your account is freeze']);
    }
}

public function scopeActiveAdmin($query)
{
    $query = $query->role('admin')->where('freeze_account', 0);
    $query = $query->whereNotNull('email_verified_at')->where('active', 1)->get();

    return $query;
}

public function scopeTrialGracePeriodActiveAdmin($query)
{
    return $query->role('admin')
            ->where('freeze_account', 0)
            ->whereNotNull('email_verified_at')
            ->where('active', 1)
            ->where('trial_grace_period', true);

}

public function scopeActiveEmployee($query, $companyId)
{
    $query = $query->whereHas('roles', function ($roles) {
        $roles->where('name', 'employee');
    });

    $query = $query->whereNotNull('email_verified_at')->where('active', 1);

    $query = $query->whereHas('userCompany', function ($userCompany) use ($companyId) {
        $userCompany->where('company_id', $companyId);
    })->get();

    return $query->count();
}

public function scopeAdminReplies($query)
{
    $query = $query->whereHas('company', function ($company) {
        $company->where('id', (new User())->authUserCompanyId());
    })->first();

    return $query->total_replies;
}

public function scopeIncrementReplies($query, $message)
{
    $query = $query->whereHas('company', function ($company) {
        $company->where('id', (new User())->authUserCompanyId());
    })->first();

    if (!is_null($message)) {
        $query->increment('total_replies');
    }
}

public function scopeSendSurveyResultNotification($query)
{
    $user = new User();

    $admin = $query->whereHas('company', function ($company) {
        $company->where('id', (new User())->authUserCompanyId());
    })->first();

    // process survey result for admin
    $user->processSurveyResult($admin);


    $managers = User::whereHas('userCompany', function ($userCompany) use ($admin) {
        $userCompany->where('company_id',  $admin->company->id)->where('role_name', 'manager');
    })->get();

    if ($managers->count() > 0) {
        foreach ($managers as $manager) {
            // process survey result for manager
            $user->processSurveyResultManager($manager);
        }
    }
}

public function scopeIncrementUserColumn($query, $column)
{
    $query = $query->whereHas('company', function ($company) {
        $company->where('id', (new User())->authUserCompanyId());
    })->first();

    switch ($column) {
        case 'surveys_completed':
            $query->increment('surveys_completed');
            break;

        case 'email_notification_sent':
            $query->increment('email_notification_sent');
            break;

        case 'cheers_sent':
            $query->increment('cheers_sent');
            break;

        case 'resolved_issues':
            $query->increment('resolved_issues');
            break;

        case 'total_answers':
            $query->increment('total_answers');
            break;

        case 'uncompleted_replies':
            $query->increment('uncompleted_replies');
            break;

        case 'add_more':
            $query->increment('add_more');
            break;
    }
}

public function scopeDecrementUserColumn($query, $column)
{
    $query = $query->whereHas('company', function ($company) {
        $company->where('id', (new User())->authUserCompanyId());
    })->first();

    switch ($column) {
        case 'uncompleted_replies':
            $query->decrement('uncompleted_replies');
            break;
    }

    if ($query->uncompleted_replies < 1) {
        $query->add_more = 0;
        $query->save();
    }
}

public function scopeDecrementResolvedIssues($query)
{
    $query = $query->whereHas('company', function ($company) {
        $company->where('id', (new User())->authUserCompanyId());
    })->first();

    $query->decrement('resolved_issues');
}

public function scopeGetUserEmployeeId($query)
{
    $query = $query->whereHas('roles', function ($q) {
        $q->where('name', 'employee');
    })->get();

    $query = $query->pluck('id');

    return $query;
}

public function sendSurvey($query)
{
    $users = User::get();
    foreach ($users as $user) {

        if ($user->employees >= 5) {

            // Get all employees where company is equal to $this->user
            $userId = UserCompany::where('company_id', $user->company->id)->pluck('user_id');
        }
    }
}

public function scopeGetCompanyId($query, $userId)
{
    $query = $query->find($userId)->userCompany->company_id;

    return $query;
}

public function scopeGetSurveyCompleted($query)
{
    $users = User::whereHas('roles', function ($role) {
        $role->where('name', 'admin');
    });
}

public function scopeGetCurrentSurveyDetails($query, $request = null)
{
    $companyId = null;
    $userAnswerFilter = new UsersAnswer();

    if (!is_null($request)) {
        // this is checking request parameters from super admin's vibe monitor
        if (isset($request['id'])) {

            $user = $query->find($request['id']);
        } else {
            $user = $query->find(auth()->id());
        }
    } else {

        $user = $query->find(auth()->id());
    }


    if ($user->role_name == 'admin') {
        $companyId = $user->company->id;
    } elseif ($user->role_name == 'manager') {
        $companyId = $user->userCompany->company_id;
    }

    $employeeCount = UserCompany::where('company_id', $companyId)
        ->where('role_name', 'employee')
        ->where('last_login_at', '!=', null);

    $surveyCompleted = UserCompany::where('company_id', $companyId)
        ->where('role_name', 'employee')
        ->where('survey_completed', true);

    $userAnswerFilter->filter($request, $surveyCompleted);
    $userAnswerFilter->filter($request, $employeeCount);

    $surveyCompleted = $surveyCompleted->count();
    $employeeCount = $employeeCount->count();

    if ($surveyCompleted > 0) {
        $completionPercentage = round(($surveyCompleted / $employeeCount) * 100);
    } else {
        $completionPercentage = 0;
    }
    // date_default_timezone_set($user->timezone);
    $now = Carbon::now();
    $start = Carbon::parse($user->current_survey_date);
    $end = Carbon::parse($user->current_survey_date)->next(Carbon::TUESDAY)->endOfDay();
    // $end    = $user->next_survey_date;

    // $surveyStarts = Carbon::parse($start);

    $surveyStarts = Carbon::parse($start)->format('Y-m-d');

    // $surveyEnds   = Carbon::parse($end);
    $surveyEnds = Carbon::parse($end)->format('Y-m-d');

    $now = Carbon::parse($now);
    // $start  = Carbon::parse($start);
    // $end    = Carbon::parse($end);


    $diff = $end->diffInDays($now);

    $status = $diff > 1 ? ('(' . $diff . ' days left)') : ('(' . $diff . ' day left)');
    // $start  = Carbon::parse($start)->isoFormat('LL');
    // $end    = Carbon::parse($end)->isoFormat('LL');

    return [
        'surveyId' => $user->current_survey_id,
        'employeeCount' => $employeeCount,
        'surveyCompleted' => $surveyCompleted,
        'completionPercentage' => $completionPercentage,
        'status' => $status,
        'difference' => $diff,
        'start' => $start->isoFormat('LL'),
        'end' => $end->isoFormat('LL'),
        'surveyStarts' => $surveyStarts,
        'surveyEnds' => $surveyEnds
    ];
}

public function scopeGetUpcomingSurveyDetails($query, $userId = null)
{
    $uId = $userId ?? auth()->id();

    $auth = $query->find($uId);

    // $surveyStarts = Carbon::createFromFormat('m-d-Y', $auth->next_survey_date);
    $surveyStarts = Carbon::parse($auth->next_survey_date);

    // Set survey ends base on account owner survey frequency setting
    if ($auth->account->survey_frequency == 'every_week_wednesday') {
        // $surveyEnds = $surveyStarts->addDays(7)->format('m-d-Y');
        $surveyEnds = $surveyStarts->next(Carbon::TUESDAY)->endOfDay();
    } else {
        // $surveyEnds = $surveyStarts->addDays(14)->format('m-d-Y');
        $surveyEnds = $surveyStarts->next(Carbon::TUESDAY)->next(Carbon::TUESDAY)->endOfDay();
    }
    // $now    = Carbon::now()->format('m-d-Y');
    $start = $auth->next_survey_date;
    $end = $surveyEnds;


    $now = Carbon::now();
    $start = Carbon::parse($auth->next_survey_date);
    $end = Carbon::parse($end);

    $dateStartDbFormat = $auth->next_survey_date;
    $dateEndDbFormat = $end;


    $diff = $end->diffInDays($now);


    $status = $diff > 1 ? ('(' . $diff . ' days left)') : ('(' . $diff . ' day left)');
    $start = Carbon::parse($start)->isoFormat('LL');
    $end = Carbon::parse($end)->isoFormat('LL');

    return [
        'surveyId' => $userId != null ? 'this is for email notification' : (new User())->authUserNextSurveyId(),
        'status' => $status,
        'start' => $start,
        'dateStartDbFormat' => $dateStartDbFormat,
        'dateEndDbFormat' => $dateEndDbFormat,
        'end' => $end
    ];
}

public function scopeGetUpcomingSurveyDetails2($query)
{
    $auth = $query->find(auth()->id());

    $surveyStarts = Carbon::createFromFormat('m-d-Y', $auth->next_survey_date);

    // Set survey ends base on account owner survey frequency setting
    if ($auth->account->survey_frequency == 'every_week_wednesday') {
        $surveyEnds = $surveyStarts->addDays(7)->format('m-d-Y');
    } else {
        $surveyEnds = $surveyStarts->addDays(14)->format('m-d-Y');
    }

    $now = Carbon::now()->format('m-d-Y');
    $start = $auth->next_survey_date;
    $end = $surveyEnds;


    $now = Carbon::createFromFormat('m-d-Y', $now);
    $start = Carbon::createFromFormat('m-d-Y', $start);
    $end = Carbon::createFromFormat('m-d-Y', $end);

    $dateStartDbFormat = $auth->next_survey_date;
    $dateEndDbFormat = $end->format('m-d-Y');


    $diff = $end->diffInDays($now);


    $status = $diff > 1 ? ('(' . $diff . ' days left)') : ('(' . $diff . ' day left)');
    $start = Carbon::parse($start, 'Asia/Manila')->isoFormat('LL');
    $end = Carbon::parse($end, 'Asia/Manila')->isoFormat('LL');

    return [
        'surveyId' => (new User())->authUserNextSurveyId(),
        'status' => $status,
        'start' => $start,
        'dateStartDbFormat' => $dateStartDbFormat,
        'dateEndDbFormat' => $dateEndDbFormat,
        'end' => $end
    ];
}

public function scopeGetPastSurveys($query)
{
    $auth = $query->find(auth()->id());

    $currentSurveyDate = Carbon::createFromFormat('m-d-Y', $auth->current_survey_date);
}

public function scopeAccountNotificationsSchedule($query, $schedule)
{
    $users = $query->where('email_verified_at', '!=', null)->where('active', 1)->get();

    foreach ($users as $user) {
        $notification = $user->account->notifications['new_message'] ?? null;

        if ($notification) {
            $frequency = null;
            switch ($notification) {
                case 'every_10_minutes':
                    $frequency = 'everyTenMinutes';
                    break;

                case '1x_per_hour':
                    $frequency = 'hourly';
                    break;

                case '1x_per_day':
                    $frequency = 'daily';
                    break;

                default:

                    break;
            }

            if ($user->total_replies != $user->new_messages_notification) {
                $schedule->call(function () use ($user, $frequency) {
                        $language = $user->language;
                        $newMessages = $user->new_messages_notification;
                        $totalReply = $user->total_replies;

                        if ($newMessages > 1) {
                            $newMessages = $totalReply - $newMessages;
                        } else {
                            $newMessages = $user->total_replies;
                        }

                        if ($user->account->language_setting) {
                            $language = Language::find($user->account->language_setting)->language;
                        }

                        /** this should have job to avoid rapid sending of email that spikes email service provider */
                        Mail::to($user)->locale($language)->send(new \App\Mail\SendNewMessagesNotification($user, $newMessages));

                        $user->new_messages_notification = $user->total_replies;
                        $user->save();
                })->$frequency();
            }
        }
    }
}

这是
UserScopeTrait.php
文件,可以自动检测到文件更改:

<?PHP
namespace App\Traits;
use App\Jobs\SendEmployeeInvitationEmail;
use App\Jobs\SendEmployeeInvitationMondayTuesdayJob;
use App\Jobs\UpdateAdminEmployeeSurvey;
use App\Language;
use App\Location;
use App\LocationManager;
use App\Mail\SendWeeklySurvey;
use App\Mail\SurveyResultsAvailableNotification;
use App\Mail\SurveySentNotification;
use App\Repositories\UserCompanyRepository;
use App\Survey;
use App\Team;
use App\TeamManager;
use App\User;
use App\UserCompany;
use App\UsersAnswer;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Mail;

trait UserScopeTrait
{
public function scopeDispatchEmployeeInvites($query)
{
    $users = $query->whereHas('userCompany', function ($company) {
        $company->where('company_id', auth()->user()->company->id)->where('role_name', 'employee');
    })->where('invite_sent', 0)->get();

    $auth = auth()->user();
    $dispatcher = new User();
    $toSend = 0;
    $notifyState = [];
    // this is the changes I've made
    adsfdsfasdfas
    if ($users->count() == 5) {
        /**
         * first survey batch send
         * date of action: all days except Monday, Tuesday
         * send invitation & update survey details for admin and then mimic admin survey details to employee
         */
        if (!Carbon::now()->isMonday() && !Carbon::now()->isTuesday()) {
            $this->updateSurveyDetailsAdminEmployee(null, $auth, 'admin');
        }
    }

    foreach ($users as $employee) {

        $notifyState['total'] = $users->count();

        $employee->invite_sent = true;
        $employee->save();
        $toSend++;

        if ($notifyState['total'] == $toSend) {
            $notifyState['last'] = true;

            // Admin receive an email notification about surveys sent
            $dispatcher->dispatchAdminSurveySentNotification($auth);
        } else {
            $notifyState['last'] = false;
        }
        /**
         * counter reaches to 5 this means that this is the first survey
         * and should update survey details for both admin & employee
         */
        if ($users->count() == 5) {
            if (Carbon::now()->isMonday()||Carbon::now()->isTuesday()) {
                /**
                 * first survey batch send
                 * date of action: Monday, Tuesday
                 * send invitation only
                 */
                SendEmployeeInvitationMondayTuesdayJob::dispatch($employee, auth()->user())->onQueue('notification');
            } else {
                /**
                 * first survey batch send
                 * date of action: all days except Monday, Tuesday
                 * send invitation & mimic admin survey details to employee
                 */
                $this->updateSurveyDetailsAdminEmployee($employee, $auth, 'employee');

                SendEmployeeInvitationEmail::dispatch($auth, $employee, $notifyState)->onQueue('notification');
            }
        }
        /**
         * not first survey batch & single execution
         */
        else {
            if ($users->count() >=2 && $users->count() <= 3) {
                /**
                 * not first survey batch execution
                 * date of action: Monday, Tuesday
                 * send invitation only
                 */
                if (Carbon::now()->isMonday()||Carbon::now()->isTuesday()) {
                    SendEmployeeInvitationMondayTuesdayJob::dispatch($employee, auth()->user())->onQueue('notification');
                }
                /**
                 * not first survey batch execution
                 * date of action: all days except Monday, Tuesday
                 * send invitation & update survey details for employee only mimic admin survey details
                 */
                else {
                    $this->updateSurveyDetailsAdminEmployee($employee, $auth, 'employee');
                    SendEmployeeInvitationEmail::dispatch($auth, $employee, $notifyState)->onQueue('notification');
                }
            }

            if ($users->count() == 1) {
                /**
                 * not first survey single execution
                 * date of action: Monday, Tuesday
                 * send invitation only
                 */
                if (Carbon::now()->isMonday()||Carbon::now()->isTuesday()) {
                    SendEmployeeInvitationMondayTuesdayJob::dispatch($employee, auth()->user())->onQueue('notification');
                }
                /**
                 * not first survey single execution
                 * date of action: all days except Monday, Tuesday
                 * send invitation & update survey details for employee mimic admin survey details
                 */
                else {
                    $this->updateSurveyDetailsAdminEmployee($employee, $auth, 'employee');
                    SendEmployeeInvitationEmail::dispatch($auth, $employee, $notifyState)->onQueue('notification');
                }
            }
        }
    }
}
private function updateSurveyDetailsAdminEmployee($employee, $auth, $type)
{
    $currentDate    = Carbon::now();
    $nextSurveyDate = clone $currentDate;

    if ($type == 'admin') {
        date_default_timezone_set($auth->timezone);
        // Set next_survey_date base on account owner survey frequency setting
        if ($auth->account->survey_frequency == 'every_week_wednesday') {
            $nextSurveyDate = $nextSurveyDate->next(Carbon::WEDNESDAY);
        } else {
            $nextSurveyDate = $nextSurveyDate->next(Carbon::WEDNESDAY)->next(Carbon::WEDNESDAY);
        }

        // Update survey_date and next_survey_number for admin
        $auth->current_survey_date = $currentDate;
        $auth->next_survey_date    = $nextSurveyDate;
        $auth->first_survey        = true;
        $auth->next_survey_number  = (new User())->getNextSurveyNumber($auth);
        $auth->save();
    }
    else if ($type == 'employee') {
        date_default_timezone_set($employee->timezone);
        // Update next_survey_date and next_survey_number for employee
        $employee->next_survey_date    = $auth->next_survey_date;
        $employee->current_survey_id   = $auth->current_survey_id;
        $employee->current_survey_date = $currentDate;
        $employee->next_survey_number  = $auth->next_survey_number;
        $employee->invite_sent_time    = now()->toDateTimeString();

        $employee->save();
    }
}
public function scopeUpdateMessageNotificationCounter($query, $data)
{
    $managers = $query->whereHas('userCompany', function ($userCompany) use ($data) {
        $userCompany->where('company_id', (new User())->authUserCompanyId())->where('role_name', 'manager');
    })->get();

    foreach ($managers as $user) {

        $user->wait_for_my_reply = $data['waitingForMyReply'];
        $user->wait_for_employee_organization_reply = $data['waitingForEmployeeOrganizationReply'];

        $user->save();
    }

    $admin = User::whereHas('company', function ($company) {
        $company->where('id', (new User())->authUserCompanyId());
    })->first();

    $admin->wait_for_my_reply = $data['waitingForMyReply'];
    $admin->wait_for_employee_organization_reply = $data['waitingForEmployeeOrganizationReply'];

    $admin->save();
}

public function scopeUserHasSurvey($query, $id)
{
    $currentSurveyDate = $query->find($id)->current_survey_date;
    $nextSurveyDate = $query->find($id)->next_survey_date;

    if ($currentSurveyDate != null && $nextSurveyDate != null) {
        return true;
    } else {
        return false;
    }
}

public function scopeUserCompanyId($query, $id)
{
    return $query->find($id)->company->id;
}

public function scopeUserCurrentSurveyId($query, $id)
{
    return $query->find($id)->current_survey_id;
}

public function scopeFilterAdminAccess()
{
    if (auth()->user()->freeze_account > 0 && auth()->user()->role_name == 'admin') {
        return redirect()->route('billing')->with(['info' => 'Your account is freeze']);
    }
}

public function scopeActiveAdmin($query)
{
    $query = $query->role('admin')->where('freeze_account', 0);
    $query = $query->whereNotNull('email_verified_at')->where('active', 1)->get();

    return $query;
}

public function scopeTrialGracePeriodActiveAdmin($query)
{
    return $query->role('admin')
            ->where('freeze_account', 0)
            ->whereNotNull('email_verified_at')
            ->where('active', 1)
            ->where('trial_grace_period', true);

}

public function scopeActiveEmployee($query, $companyId)
{
    $query = $query->whereHas('roles', function ($roles) {
        $roles->where('name', 'employee');
    });

    $query = $query->whereNotNull('email_verified_at')->where('active', 1);

    $query = $query->whereHas('userCompany', function ($userCompany) use ($companyId) {
        $userCompany->where('company_id', $companyId);
    })->get();

    return $query->count();
}

public function scopeAdminReplies($query)
{
    $query = $query->whereHas('company', function ($company) {
        $company->where('id', (new User())->authUserCompanyId());
    })->first();

    return $query->total_replies;
}

public function scopeIncrementReplies($query, $message)
{
    $query = $query->whereHas('company', function ($company) {
        $company->where('id', (new User())->authUserCompanyId());
    })->first();

    if (!is_null($message)) {
        $query->increment('total_replies');
    }
}

public function scopeSendSurveyResultNotification($query)
{
    $user = new User();

    $admin = $query->whereHas('company', function ($company) {
        $company->where('id', (new User())->authUserCompanyId());
    })->first();

    // process survey result for admin
    $user->processSurveyResult($admin);


    $managers = User::whereHas('userCompany', function ($userCompany) use ($admin) {
        $userCompany->where('company_id',  $admin->company->id)->where('role_name', 'manager');
    })->get();

    if ($managers->count() > 0) {
        foreach ($managers as $manager) {
            // process survey result for manager
            $user->processSurveyResultManager($manager);
        }
    }
}

public function scopeIncrementUserColumn($query, $column)
{
    $query = $query->whereHas('company', function ($company) {
        $company->where('id', (new User())->authUserCompanyId());
    })->first();

    switch ($column) {
        case 'surveys_completed':
            $query->increment('surveys_completed');
            break;

        case 'email_notification_sent':
            $query->increment('email_notification_sent');
            break;

        case 'cheers_sent':
            $query->increment('cheers_sent');
            break;

        case 'resolved_issues':
            $query->increment('resolved_issues');
            break;

        case 'total_answers':
            $query->increment('total_answers');
            break;

        case 'uncompleted_replies':
            $query->increment('uncompleted_replies');
            break;

        case 'add_more':
            $query->increment('add_more');
            break;
    }
}

public function scopeDecrementUserColumn($query, $column)
{
    $query = $query->whereHas('company', function ($company) {
        $company->where('id', (new User())->authUserCompanyId());
    })->first();

    switch ($column) {
        case 'uncompleted_replies':
            $query->decrement('uncompleted_replies');
            break;
    }

    if ($query->uncompleted_replies < 1) {
        $query->add_more = 0;
        $query->save();
    }
}

public function scopeDecrementResolvedIssues($query)
{
    $query = $query->whereHas('company', function ($company) {
        $company->where('id', (new User())->authUserCompanyId());
    })->first();

    $query->decrement('resolved_issues');
}

public function scopeGetUserEmployeeId($query)
{
    $query = $query->whereHas('roles', function ($q) {
        $q->where('name', 'employee');
    })->get();

    $query = $query->pluck('id');

    return $query;
}

public function sendSurvey($query)
{
    $users = User::get();
    foreach ($users as $user) {

        if ($user->employees >= 5) {

            // Get all employees where company is equal to $this->user
            $userId = UserCompany::where('company_id', $user->company->id)->pluck('user_id');
        }
    }
}

public function scopeGetCompanyId($query, $userId)
{
    $query = $query->find($userId)->userCompany->company_id;

    return $query;
}

public function scopeGetSurveyCompleted($query)
{
    $users = User::whereHas('roles', function ($role) {
        $role->where('name', 'admin');
    });
}

public function scopeGetCurrentSurveyDetails($query, $request = null)
{
    $companyId = null;
    $userAnswerFilter = new UsersAnswer();

    if (!is_null($request)) {
        // this is checking request parameters from super admin's vibe monitor
        if (isset($request['id'])) {

            $user = $query->find($request['id']);
        } else {
            $user = $query->find(auth()->id());
        }
    } else {

        $user = $query->find(auth()->id());
    }


    if ($user->role_name == 'admin') {
        $companyId = $user->company->id;
    } elseif ($user->role_name == 'manager') {
        $companyId = $user->userCompany->company_id;
    }

    $employeeCount = UserCompany::where('company_id', $companyId)
        ->where('role_name', 'employee')
        ->where('last_login_at', '!=', null);

    $surveyCompleted = UserCompany::where('company_id', $companyId)
        ->where('role_name', 'employee')
        ->where('survey_completed', true);

    $userAnswerFilter->filter($request, $surveyCompleted);
    $userAnswerFilter->filter($request, $employeeCount);

    $surveyCompleted = $surveyCompleted->count();
    $employeeCount = $employeeCount->count();

    if ($surveyCompleted > 0) {
        $completionPercentage = round(($surveyCompleted / $employeeCount) * 100);
    } else {
        $completionPercentage = 0;
    }
    // date_default_timezone_set($user->timezone);
    $now = Carbon::now();
    $start = Carbon::parse($user->current_survey_date);
    $end = Carbon::parse($user->current_survey_date)->next(Carbon::TUESDAY)->endOfDay();
    // $end    = $user->next_survey_date;

    // $surveyStarts = Carbon::parse($start);

    $surveyStarts = Carbon::parse($start)->format('Y-m-d');

    // $surveyEnds   = Carbon::parse($end);
    $surveyEnds = Carbon::parse($end)->format('Y-m-d');

    $now = Carbon::parse($now);
    // $start  = Carbon::parse($start);
    // $end    = Carbon::parse($end);


    $diff = $end->diffInDays($now);

    $status = $diff > 1 ? ('(' . $diff . ' days left)') : ('(' . $diff . ' day left)');
    // $start  = Carbon::parse($start)->isoFormat('LL');
    // $end    = Carbon::parse($end)->isoFormat('LL');

    return [
        'surveyId' => $user->current_survey_id,
        'employeeCount' => $employeeCount,
        'surveyCompleted' => $surveyCompleted,
        'completionPercentage' => $completionPercentage,
        'status' => $status,
        'difference' => $diff,
        'start' => $start->isoFormat('LL'),
        'end' => $end->isoFormat('LL'),
        'surveyStarts' => $surveyStarts,
        'surveyEnds' => $surveyEnds
    ];
}

public function scopeGetUpcomingSurveyDetails($query, $userId = null)
{
    $uId = $userId ?? auth()->id();

    $auth = $query->find($uId);

    // $surveyStarts = Carbon::createFromFormat('m-d-Y', $auth->next_survey_date);
    $surveyStarts = Carbon::parse($auth->next_survey_date);

    // Set survey ends base on account owner survey frequency setting
    if ($auth->account->survey_frequency == 'every_week_wednesday') {
        // $surveyEnds = $surveyStarts->addDays(7)->format('m-d-Y');
        $surveyEnds = $surveyStarts->next(Carbon::TUESDAY)->endOfDay();
    } else {
        // $surveyEnds = $surveyStarts->addDays(14)->format('m-d-Y');
        $surveyEnds = $surveyStarts->next(Carbon::TUESDAY)->next(Carbon::TUESDAY)->endOfDay();
    }
    // $now    = Carbon::now()->format('m-d-Y');
    $start = $auth->next_survey_date;
    $end = $surveyEnds;


    $now = Carbon::now();
    $start = Carbon::parse($auth->next_survey_date);
    $end = Carbon::parse($end);

    $dateStartDbFormat = $auth->next_survey_date;
    $dateEndDbFormat = $end;


    $diff = $end->diffInDays($now);


    $status = $diff > 1 ? ('(' . $diff . ' days left)') : ('(' . $diff . ' day left)');
    $start = Carbon::parse($start)->isoFormat('LL');
    $end = Carbon::parse($end)->isoFormat('LL');

    return [
        'surveyId' => $userId != null ? 'this is for email notification' : (new User())->authUserNextSurveyId(),
        'status' => $status,
        'start' => $start,
        'dateStartDbFormat' => $dateStartDbFormat,
        'dateEndDbFormat' => $dateEndDbFormat,
        'end' => $end
    ];
}

public function scopeGetUpcomingSurveyDetails2($query)
{
    $auth = $query->find(auth()->id());

    $surveyStarts = Carbon::createFromFormat('m-d-Y', $auth->next_survey_date);

    // Set survey ends base on account owner survey frequency setting
    if ($auth->account->survey_frequency == 'every_week_wednesday') {
        $surveyEnds = $surveyStarts->addDays(7)->format('m-d-Y');
    } else {
        $surveyEnds = $surveyStarts->addDays(14)->format('m-d-Y');
    }

    $now = Carbon::now()->format('m-d-Y');
    $start = $auth->next_survey_date;
    $end = $surveyEnds;


    $now = Carbon::createFromFormat('m-d-Y', $now);
    $start = Carbon::createFromFormat('m-d-Y', $start);
    $end = Carbon::createFromFormat('m-d-Y', $end);

    $dateStartDbFormat = $auth->next_survey_date;
    $dateEndDbFormat = $end->format('m-d-Y');


    $diff = $end->diffInDays($now);


    $status = $diff > 1 ? ('(' . $diff . ' days left)') : ('(' . $diff . ' day left)');
    $start = Carbon::parse($start, 'Asia/Manila')->isoFormat('LL');
    $end = Carbon::parse($end, 'Asia/Manila')->isoFormat('LL');

    return [
        'surveyId' => (new User())->authUserNextSurveyId(),
        'status' => $status,
        'start' => $start,
        'dateStartDbFormat' => $dateStartDbFormat,
        'dateEndDbFormat' => $dateEndDbFormat,
        'end' => $end
    ];
}

public function scopeGetPastSurveys($query)
{
    $auth = $query->find(auth()->id());

    $currentSurveyDate = Carbon::createFromFormat('m-d-Y', $auth->current_survey_date);
}

public function scopeAccountNotificationsSchedule($query, $schedule)
{
    $users = $query->where('email_verified_at', '!=', null)->where('active', 1)->get();

    foreach ($users as $user) {
        $notification = $user->account->notifications['new_message'] ?? null;

        if ($notification) {
            $frequency = null;
            switch ($notification) {
                case 'every_10_minutes':
                    $frequency = 'everyTenMinutes';
                    break;

                case '1x_per_hour':
                    $frequency = 'hourly';
                    break;

                case '1x_per_day':
                    $frequency = 'daily';
                    break;

                default:

                    break;
            }

            if ($user->total_replies != $user->new_messages_notification) {
                $schedule->call(function () use ($user, $frequency) {
                        $language = $user->language;
                        $newMessages = $user->new_messages_notification;
                        $totalReply = $user->total_replies;

                        if ($newMessages > 1) {
                            $newMessages = $totalReply - $newMessages;
                        } else {
                            $newMessages = $user->total_replies;
                        }

                        if ($user->account->language_setting) {
                            $language = Language::find($user->account->language_setting)->language;
                        }

                        /** this should have job to avoid rapid sending of email that spikes email service provider */
                        Mail::to($user)->locale($language)->send(new \App\Mail\SendNewMessagesNotification($user, $newMessages));

                        $user->new_messages_notification = $user->total_replies;
                        $user->save();
                })->$frequency();
            }
        }
    }
}

1)只是想一想:也许那个文件还没有保存?如果启用
设置/首选项|编辑器|常规|编辑器选项卡|标记已修改(*)
如果文件尚未保存到磁盘,则应在编辑器选项卡中的文件图标旁边看到星号
*
。2) 如果切换
设置/首选项|外观和行为|系统设置|保存前备份文件
选项,会有什么不同吗?目前我没有其他可靠的想法。更不用说我只是克隆了一个新文件并在phpstorm中重新打开它。这解决了我的问题。