芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/qrafiqxcreativeagency.com/accounts/office/app/Models/Ticket.php
$mentionUser * @property-read int|null $mention_user_count * @property-read \Illuminate\Database\Eloquent\Collection
$ticketMention * @property-read int|null $ticket_mention_count * @mixin \Eloquent */ class Ticket extends BaseModel { use HasCompany; use SoftDeletes, HasFactory; use CustomFieldsTrait; protected $casts = [ 'deleted_at' => 'datetime', ]; protected $appends = ['created_on']; const CUSTOM_FIELD_MODEL = 'App\Models\Ticket'; public function requester(): BelongsTo { return $this->belongsTo(User::class, 'user_id')->withoutGlobalScope(ActiveScope::class); } public function agent(): BelongsTo { return $this->belongsTo(User::class, 'agent_id')->withoutGlobalScope(ActiveScope::class); } public function client(): BelongsTo { return $this->belongsTo(User::class, 'user_id')->withoutGlobalScope(ActiveScope::class); } public function reply(): HasMany { return $this->hasMany(TicketReply::class, 'ticket_id'); } public function latestReply(): HasOne { return $this->hasOne(TicketReply::class, 'ticket_id')->latest(); } public function tags(): HasMany { return $this->hasMany(TicketTag::class, 'ticket_id'); } public function ticketTags(): BelongsToMany { return $this->belongsToMany(TicketTagList::class, 'ticket_tags', 'ticket_id', 'tag_id'); } public function getCreatedOnAttribute() { $setting = company(); if (is_null($this->created_at)) { return ''; } return $this->created_at->timezone($setting->timezone)->format('d M Y H:i'); } 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.'>' : ''; } public function mentionUser(): BelongsToMany { return $this->belongsToMany(User::class, 'mention_users')->withoutGlobalScope(ActiveScope::class)->using(MentionUser::class); } public function ticketMention(): HasMany { return $this->hasMany(MentionUser::class, 'ticket_id'); } public function project(): BelongsTo { return $this->belongsTo(Project::class, 'project_id'); } public function activities(): HasMany { return $this->hasMany(TicketActivity::class, 'ticket_id')->latest(); } }