You've already forked Atomcms-edit
Initial commit
This commit is contained in:
Executable
+83
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Help;
|
||||
|
||||
use App\Models\Concerns\BelongsToUser;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Stevebauman\Purify\Facades\Purify;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int $category_id
|
||||
* @property string $subject
|
||||
* @property string $content
|
||||
* @property int $severity
|
||||
* @property bool $open
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read string $content
|
||||
* @property-read User|null $user
|
||||
* @property-read WebsiteHelpCenterCategory|null $category
|
||||
* @property-read Collection<int, WebsiteHelpCenterTicketReply> $replies
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteHelpCenterTicket orderBy($column, $direction = 'asc')
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteHelpCenterTicket where($column, $operator = null, $value = null)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteHelpCenterTicket get($columns = ['*'])
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteHelpCenterTicket paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
|
||||
*/
|
||||
class WebsiteHelpCenterTicket extends Model
|
||||
{
|
||||
use BelongsToUser;
|
||||
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at', 'user_id', 'status', 'subject', 'category_id'];
|
||||
|
||||
/** @var array<int, string> */
|
||||
#[\Override]
|
||||
protected $with = ['user', 'category'];
|
||||
|
||||
#[\Override]
|
||||
public $timestamps = false;
|
||||
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WebsiteHelpCenterCategory::class);
|
||||
}
|
||||
|
||||
public function replies(): HasMany
|
||||
{
|
||||
return $this->hasMany(WebsiteHelpCenterTicketReply::class, 'ticket_id')->latest();
|
||||
}
|
||||
|
||||
public function canDeleteTicket()
|
||||
{
|
||||
return $this->user_id === Auth::id() || hasPermission('delete_website_tickets');
|
||||
}
|
||||
|
||||
public function canManageTicket()
|
||||
{
|
||||
return $this->user_id === Auth::id() || hasPermission('manage_website_tickets');
|
||||
}
|
||||
|
||||
public function canCloseTicket()
|
||||
{
|
||||
return $this->user_id === Auth::id() || hasPermission('manage_website_tickets');
|
||||
}
|
||||
|
||||
public function isOpen()
|
||||
{
|
||||
return $this->open || hasPermission('manage_website_tickets');
|
||||
}
|
||||
|
||||
public function getContentAttribute($value)
|
||||
{
|
||||
return Purify::clean($value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user