2022-07-26 06:36:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Backpack\CRUD\app\Models\Traits\CrudTrait;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
class Ticket extends Model
|
|
|
|
|
{
|
|
|
|
|
use CrudTrait;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| GLOBAL VARIABLES
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
protected $table = 'tickets';
|
|
|
|
|
// protected $primaryKey = 'id';
|
|
|
|
|
// public $timestamps = false;
|
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
|
protected $fillable = [
|
2022-07-29 10:32:39 +00:00
|
|
|
'client_id',
|
2022-07-26 06:36:47 +00:00
|
|
|
'status_id',
|
|
|
|
|
'title',
|
|
|
|
|
'content'
|
|
|
|
|
];
|
|
|
|
|
// protected $hidden = [];
|
|
|
|
|
// protected $dates = [];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| FUNCTIONS
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
2022-07-29 10:32:39 +00:00
|
|
|
public function messagesOfTicket(){
|
2022-08-02 10:12:09 +00:00
|
|
|
return '<a class="btn btn-sm btn-link" href="/chat?ticket_id='. $this->id .'" data-toggle="tooltip">
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" style="width:15px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
|
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
|
|
|
|
|
</svg> Chat</a>';
|
2022-07-29 10:32:39 +00:00
|
|
|
}
|
2022-07-26 06:36:47 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| RELATIONS
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
2022-07-29 10:32:39 +00:00
|
|
|
public function client(){
|
|
|
|
|
return $this->belongsTo(Client::class, 'client_id');
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-26 06:36:47 +00:00
|
|
|
public function category(){
|
|
|
|
|
return $this->belongsTo(Category::class, 'category_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function status(){
|
|
|
|
|
return $this->belongsTo(Status::class, 'status_id');
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-02 10:12:09 +00:00
|
|
|
public function messages(){
|
|
|
|
|
return $this->hasMany(Message::class);
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-26 06:36:47 +00:00
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| SCOPES
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| ACCESSORS
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| MUTATORS
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
}
|