mirror of
https://github.com/dyzulk/trustlab-api.git
synced 2026-01-26 13:22:05 +07:00
First commit
This commit is contained in:
45
app/Models/Ticket.php
Normal file
45
app/Models/Ticket.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||
|
||||
class Ticket extends Model
|
||||
{
|
||||
use HasFactory, HasUuids;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'ticket_number',
|
||||
'subject',
|
||||
'category',
|
||||
'priority',
|
||||
'status',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the user that owns the ticket.
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the replies for the ticket.
|
||||
*/
|
||||
public function replies()
|
||||
{
|
||||
return $this->hasMany(TicketReply::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to generate a unique ticket number.
|
||||
*/
|
||||
public static function generateTicketNumber()
|
||||
{
|
||||
return 'TKT-' . strtoupper(bin2hex(random_bytes(3)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user