Ticket.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\Core\Models\Whmcs;
  3. use \Illuminate\Database\Eloquent\Model as EloquentModel;
  4. use Michelf\Markdown;
  5. /**
  6. * Description of Product
  7. *
  8. * @autor ThurData <info@thurdata.ch>
  9. */
  10. class Ticket extends EloquentModel
  11. {
  12. /**
  13. * Table name
  14. *
  15. * @var string
  16. */
  17. protected $table = 'tbltickets';
  18. protected $primaryKey = 'id';
  19. /**
  20. * Eloquent guarded parameters
  21. * @var array
  22. */
  23. protected $guarded = ['id'];
  24. /**
  25. * Eloquent fillable parameters
  26. * @var array
  27. */
  28. protected $fillable = ['tid', 'did', 'userid', 'contactid', 'name', 'email', 'cc', 'c', 'date', 'title', 'message', 'status', 'urgency', 'admin', 'attachment', 'lastreply', 'flag', 'clientunread', 'adminunread', 'replyingadmin', 'replyingtime', 'service', 'merged_ticket_id', 'editor'];
  29. /**
  30. * Indicates if the model should soft delete.
  31. *
  32. * @var bool
  33. */
  34. protected $softDelete = false;
  35. /**
  36. * Indicates if the model should be timestamped.
  37. *
  38. * @var bool
  39. */
  40. public $timestamps = false;
  41. public function __construct(array $attributes = [])
  42. {
  43. parent::__construct($attributes);
  44. }
  45. /**
  46. * Get Realted client
  47. */
  48. public function client()
  49. {
  50. return $this->belongsTo('ThurData\Servers\KerioEmail\Core\Models\Whmcs\Client', 'userid');
  51. }
  52. public function clientRC()
  53. {
  54. return $this->belongsTo('ThurData\Servers\KerioEmail\Core\Models\ResellerClient', 'userid', "client_id");
  55. }
  56. public function replies()
  57. {
  58. return $this->hasMany('ThurData\Servers\KerioEmail\Core\Models\Whmcs\TicketReply', 'tid');
  59. }
  60. public function department()
  61. {
  62. return $this->belongsTo("ThurData\Servers\KerioEmail\Core\Models\Whmcs\TicketDepartment", "did");
  63. }
  64. public function updateStatus($status)
  65. {
  66. $this->status = $status;
  67. $this->save();
  68. }
  69. }