芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/qrafiqxcreativeagency.com/accounts/office/app/Models/SuperAdmin/SupportTicket.php
'datetime', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; protected $appends = ['created_on', 'updated_on']; protected static function boot() { parent::boot(); static::observe(SupportTicketObserver::class); } public function requester(): BelongsTo { return $this->belongsTo(User::class, 'user_id')->withoutGlobalScopes(['active', CompanyScope::class]); } public function agent(): BelongsTo { return $this->belongsTo(User::class, 'agent_id')->withoutGlobalScopes(['active', CompanyScope::class]); } public function reply(): HasMany { return $this->hasMany(SupportTicketReply::class, 'support_ticket_id'); } public function latestReply(): HasOne { return $this->hasOne(SupportTicketReply::class, 'support_ticket_id')->latest(); } public function client(): BelongsTo { return $this->belongsTo(User::class, 'user_id')->withoutGlobalScopes(['active']); } public function getCreatedOnAttribute() { if (is_null($this->created_at)) { return ''; } return $this->created_at->format('d M Y H:i'); } public function getUpdatedOnAttribute() { if (is_null($this->updated_at)) { return ''; } return $this->updated_at->format('Y-m-d H:i a'); } public function badge($tag = 'p') { $latestReplyUser = $this->latestReply?->user; $totalReply = $this->reply()->count(); $selfReplyCount = $this->reply()->where('user_id', $latestReplyUser?->id)->count(); if ($totalReply > 1 && ($totalReply !== $selfReplyCount) && $latestReplyUser && $latestReplyUser->id !== user()->id) { return '<'.$tag.' class="mb-0">
' . __('app.newResponse') . '
'.$tag.'>'; } return $totalReply == 1 || ($totalReply == $selfReplyCount) ? '<'.$tag.' class="mb-0">
' . __('app.new') . '
'.$tag.'>' : ''; } }