芝麻web文件管理V1.00
编辑当前文件:/home/digitalh/yeahea.digitalhubbd.com/app/Models/Ticket.php
belongsTo(Shop::class)->withDefault([ 'name' => trans('app.vendor_not_available'), ]); } /** * Get the user associated with the model. */ public function user() { return $this->belongsTo(User::class)->withDefault(); } /** * Get the ticket category associated with the model. */ public function category() { return $this->belongsTo(TicketCategory::class, 'category_id'); } /** * Get the ticket assigned to associated with the model. */ public function assignedTo() { return $this->belongsTo(User::class, 'assigned_to'); } /** * Scope a query to only include records from the users shop. * * @return \Illuminate\Database\Eloquent\Builder */ public function scopeAssignedToMe($query) { return $query->where('assigned_to', Auth::id())->where('status', '<', self::STATUS_SOLVED); } /** * Scope a query to only include records from the users shop. * * @return \Illuminate\Database\Eloquent\Builder */ public function scopeUnAssigned($query) { return $query->where('assign_id', null)->where('status', '<', self::STATUS_SOLVED); } /** * Scope a query to only include records from the users shop. * * @return \Illuminate\Database\Eloquent\Builder */ public function scopeOpen($query) { return $query->where('status', '<', self::STATUS_SOLVED); } /** * Scope a query to only include records from the users shop. * * @return \Illuminate\Database\Eloquent\Builder */ public function scopeClosed($query) { return $query->where('status', '>=', self::STATUS_SOLVED); } /** * Scope a query to only include records that have the given status. * * @return \Illuminate\Database\Eloquent\Builder */ public function scopeStatusOf($query, $status) { return $query->where('status', $status); } /** * Scope a query to only include records that have the given priority. * * @return \Illuminate\Database\Eloquent\Builder */ public function scopePriorityOf($query, $priority) { return $query->where('priority', $priority); } /** * Scope a query to only include records from the users shop. * * @return \Illuminate\Database\Eloquent\Builder */ public function scopeCreatedByMe($query) { return $query->where('user_id', Auth::id()); } /** * Scope a query to only include records from the users shop. * * @return \Illuminate\Database\Eloquent\Builder */ public function scopeArchived($query) { return $query->onlyTrashed(); } public function statusName() { switch ($this->status) { case static::STATUS_NEW: return '
' . trans('app.statuses.new') . '
'; case static::STATUS_OPEN: return '
' . trans('app.statuses.open') . '
'; case static::STATUS_PENDING: return '
' . trans('app.statuses.pending') . '
'; case static::STATUS_SOLVED: return '
' . trans('app.statuses.solved') . '
'; case static::STATUS_CLOSED: return '
' . trans('app.statuses.closed') . '
'; case static::STATUS_SPAM: return '
' . trans('app.statuses.spam') . '
'; } } public function priorityLevel() { switch ($this->priority) { case static::PRIORITY_LOW: return '
' . trans('app.priorities.low') . '
'; case static::PRIORITY_NORMAL: return '
' . trans('app.priorities.normal') . '
'; case static::PRIORITY_HIGH: return '
' . trans('app.priorities.high') . '
'; case static::PRIORITY_CRITICAL: return '
' . trans('app.priorities.critical') . '
'; } } }