booking->date, $this->booking->language, 'l j F Y'); $data['data'] = [ 'icon' => 'info', 'booking_id' => $this->booking->id, 'status' => $this->booking->status, 'status_label' => BookingStatus::label($this->booking->status), 'review_id' => $this->booking->review->id, 'title' => $this->title($user), 'text' => $this->text($user), 'feedback' => $this->feedback($user), 'link' => $this->link($user), // Structured fields for compact notification view 'review_scores' => $this->reviewScores(), 'review_avg' => $this->reviewAvg(), 'customer_name' => $this->booking->name, 'customer_party' => $this->booking->party, 'booking_date_formatted' => $d_formatted, 'booking_time_formatted' => evavel_seconds_to_Hm($this->booking->time), 'customer_email' => $this->booking->email, 'customer_phone' => $this->booking->dial_code . $this->booking->phone, ]; $notification = \Alexr\Models\Notification::create($data); $notification->save(); } protected function title($user) { return __eva('REVIEW'); } public function text($user) { //$d_formatted = Carbon::createFromFormat('Y-m-d', $this->booking->date) // ->locale($this->booking->language) // ->translatedFormat('l j F Y'); $d_formatted = evavel_date_createFromFormatTranslate('Y-m-d', $this->booking->date, $this->booking->language, 'l j F Y'); $html = '
' . $d_formatted . ' - ' . evavel_seconds_to_Hm($this->booking->time).'
'; $html .= '

'.$this->booking->name.' (' . $this->booking->party . ')

'; $html .= "
{$this->booking->email}
"; $html .= "
{$this->booking->dial_code}{$this->booking->phone}
"; $review = $this->booking->review; if ($review) { //$html .= '
'; $html .= '
'; $keys = ['score1', 'score2', 'score3', 'score4', 'score5']; foreach($keys as $key) { $html .= '

'.ReviewItems::conceptForScore($key) . ': ' . ReviewItems::labelForNumber($review->{$key}).'

'; } $html .= '
'; } return $html; } protected function feedback($user) { $review = $this->booking->review; // base64 encoded if ($review) { return $review->feedback; } return ''; } protected function link($user) { return ''; } protected function reviewScores() { $review = $this->booking->review; if (!$review) return null; return [ 'score1' => intval($review->score1), 'score2' => intval($review->score2), 'score3' => intval($review->score3), 'score4' => intval($review->score4), 'score5' => intval($review->score5), ]; } protected function reviewAvg() { $review = $this->booking->review; if (!$review) return null; $scores = [intval($review->score1), intval($review->score2), intval($review->score3), intval($review->score4), intval($review->score5)]; $valid = array_filter($scores, function($s) { return $s > 0; }); return count($valid) > 0 ? round(array_sum($valid) / count($valid), 1) : 0; } }