editButton(route('admin.sant.edit', $this->id), 'Edit Sant'); } /** * @return string */ public function getSantViewChaturmasActionAttribute(): string { return $this->chaturmasListButton(route('admin.sant.chaturmas.index', $this->id), "View Chaturmas"); } /** * @return string */ public function getSantViharListActionAttribute(): string { $route = route('admin.sant.vihar.index', $this->id); return ' '; } /** * @return string */ public function getSantStatusActionAttribute(): string { if ($this->status === 1) { return '' . __('label.inactive') . ''; } else { return '' . __('label.active') . ''; } } /** * @return string */ public function getVerificationStatusActionAttribute(): string { if ($this->verification_status === 1) { return '' . __('label.approved') . ''; } else if ($this->verification_status === 2) { return '' . __('label.in_review') . ''; } else if ($this->verification_status === 3) { return '' . __('label.sent_back') . ''; // } else if ($this->status === 4) { // return '' . __('label.approved') . ''; } else if ($this->verification_status === 5) { return '' . __('label.rejected') . ''; } } /** * @return string */ public function getSantCheckboxActionAttribute(): string { return $this->checkboxAction($this); } /** * @return string */ public function getSantActionButtonsAttribute(): string { $action = $this->sant_view_chaturmas_action; $action .= $this->sant_vihar_list_action; $action .= $this->sant_edit_action; //$action .= $this->sant_edit_action; // $action =$action.$this->sant_view_action; // if (loggedInUser()->isSuperAdmin() || loggedInUser()->isAdmin()) { // $action =$action.$this->sant_delete_action; // } return $action; } /** * Returns age of model in year since birth. */ public function getAgeAttribute() { if (!empty($this->attributes['birth_date'])) { return Carbon::parse($this->attributes['birth_date'])->age; } return Constant::STATUS_ZERO; } /** * Returns age of model in year since dikha_date. */ public function getDikshaYearAttribute() { if (!empty($this->attributes['diksha_date'])) { return Carbon::parse($this->attributes['diksha_date'])->age; } return Constant::STATUS_ZERO; } /** * Returns age of model in year since dikha_date. */ public function getIsUserFollowingAttribute() { if (loggedInUser()) { return loggedInUser()->followings->contains($this->attributes['id']); } } /** * Returns sant verification status. */ public function getIsApprovedAttribute() { $sant = Sant::where([ 'id' => $this->id ])->value('verification_status'); //When sant is approved if ($sant === Constant::STATUS_ONE) { return Constant::STATUS_ONE; //When not approved } else { return Constant::STATUS_ZERO; } } /** * Returns sant verification status. */ public function getIsInReviewAttribute() { $sant = SantTemp::where([ 'sant_id' => $this->id ])->value('verification_status'); //When sant is in review if ($sant === Constant::STATUS_FOUR) { return Constant::STATUS_ONE; } else { return Constant::STATUS_ZERO; } } /** * Returns sant profile owner. */ public function getIsOwnerAttribute() { $sant = Sant::where([ 'id' => $this->id ])->value('created_by'); if (loggedInUser() && $sant == loggedInUser()->id) { return Constant::STATUS_ONE; } else { return Constant::STATUS_ZERO; } } /** * Get upcoming vihar counts * @return int */ public function getUpcomingViharCountAttribute(): int { $counts = Vihar::where(function ($query) { $query->where(function ($subQuery) { $subQuery->where('start_date', '=', Carbon::now()->toDateString()) ->where('start_time', '>=', Carbon::now()->subHour(2)->toTimeString()); })->orWhere(function ($subQuery) { $subQuery->where('start_date', '>', Carbon::now()->toDateString()) ->where('start_time', '>=', '00:00:00'); }); })->where('sant_id', $this->id)->count(); // $counts = Vihar::where(function ($subQuery) { // $subQuery->where('start_date', '>=', Carbon::now()->toDateString()) // ->where('start_time', '>=', Carbon::now()->subHour(2)->toTimeString()); // }) // ->orWhere(function ($subQuery) { // $subQuery->where('start_date', '>', Carbon::now()->toDateString()) // ->where('start_time', '>=', '00:00:00'); // }) // ->where('sant_id', $this->id)->count(); if (!empty($counts)) { return $counts; } else { return Constant::STATUS_ZERO; } } /** * Get current year & next year chaturmas count * @return int */ public function getCurrentChaturmasCountAttribute(): int { $count = Chaturmas::join('chaturmas_dates', 'chaturmas_dates.id', '=', 'chaturmas.chaturmas_date_id') ->select('chaturmas.*') ->with('chaturmasInfo') ->where('chaturmas_dates.year', '>=', Carbon::now()->format('Y')) ->where('sant_id', $this->id) ->count(); if (!empty($count)) { return $count; } else { return Constant::STATUS_ZERO; } } }