Updates
This commit is contained in:
@@ -4,43 +4,39 @@ namespace App\Model\helpdesk\Ticket;
|
||||
|
||||
use App\BaseModel;
|
||||
|
||||
class Ticket_Form_Data extends BaseModel
|
||||
{
|
||||
class Ticket_Form_Data extends BaseModel {
|
||||
|
||||
protected $table = 'ticket_form_data';
|
||||
protected $fillable = ['id', 'ticket_id', 'title', 'content', 'created_at', 'updated_at'];
|
||||
|
||||
public function getFieldKeyLabel()
|
||||
{
|
||||
public function getFieldKeyLabel() {
|
||||
$value = $this->attributes['title'];
|
||||
$fields = new \App\Model\helpdesk\Form\Fields();
|
||||
$field = $fields->where('name', $value)->first();
|
||||
if ($field) {
|
||||
$value = $field->label;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function isHidden()
|
||||
{
|
||||
|
||||
public function isHidden(){
|
||||
$check = false;
|
||||
$value = $this->attributes['title'];
|
||||
$fields = new \App\Model\helpdesk\Form\Fields();
|
||||
$field = $fields->where('name', $value)->first();
|
||||
if ($field && $field->type == 'hidden') {
|
||||
if ($field && $field->type=='hidden') {
|
||||
$check = true;
|
||||
}
|
||||
|
||||
return $check;
|
||||
}
|
||||
|
||||
public function getHidden()
|
||||
{
|
||||
|
||||
public function getHidden(){
|
||||
$value = $this->attributes['title'];
|
||||
$fields = new \App\Model\helpdesk\Form\Fields();
|
||||
$field = $fields->where('name', $value)->first();
|
||||
if ($field && $field->type == 'hidden') {
|
||||
if ($field && $field->type=='hidden') {
|
||||
return $field->label;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ use App\BaseModel;
|
||||
|
||||
class Ticket_Priority extends BaseModel
|
||||
{
|
||||
protected $primaryKey = 'priority_id';
|
||||
protected $primaryKey = 'priority_id';
|
||||
public $timestamps = false;
|
||||
protected $table = 'ticket_priority';
|
||||
protected $fillable = [
|
||||
'priority_id', 'priority', 'status', 'user_priority_status', 'priority_desc', 'priority_color', 'priority_urgency', 'ispublic', 'created_at', 'updated_at',
|
||||
'priority_id', 'priority', 'status','user_priority_status','priority_desc', 'priority_color', 'priority_urgency', 'ispublic','created_at', 'updated_at',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -3,23 +3,21 @@
|
||||
namespace App\Model\helpdesk\Ticket;
|
||||
|
||||
//use App\BaseModel;
|
||||
use File;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use File;
|
||||
|
||||
class Ticket_Thread extends Model {
|
||||
|
||||
class Ticket_Thread extends Model
|
||||
{
|
||||
protected $table = 'ticket_thread';
|
||||
protected $fillable = [
|
||||
'id', 'ticket_id', 'staff_id', 'user_id', 'thread_type', 'poster', 'source', 'is_internal', 'title', 'body', 'format', 'ip_address', 'created_at', 'updated_at',
|
||||
];
|
||||
|
||||
public function attach()
|
||||
{
|
||||
public function attach() {
|
||||
return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_attachments', 'thread_id');
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
public function delete() {
|
||||
$this->attach()->delete();
|
||||
parent::delete();
|
||||
}
|
||||
@@ -28,23 +26,20 @@ class Ticket_Thread extends Model
|
||||
// $this->attributes['title'] = str_replace('"', "'", $value);
|
||||
// }
|
||||
|
||||
public function getTitleAttribute($value)
|
||||
{
|
||||
public function getTitleAttribute($value) {
|
||||
return str_replace('"', "'", $value);
|
||||
}
|
||||
|
||||
public function thread($content)
|
||||
{
|
||||
// $porufi = $this->purify($content);
|
||||
public function thread($content) {
|
||||
// $porufi = $this->purify($content);
|
||||
// dd($content,$porufi);
|
||||
//return $content;
|
||||
return $this->purify($content);
|
||||
}
|
||||
|
||||
public function purifyOld($value)
|
||||
{
|
||||
require_once base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier.auto.php');
|
||||
$path = base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier'.DIRECTORY_SEPARATOR.'DefinitionCache'.DIRECTORY_SEPARATOR.'Serializer');
|
||||
public function purifyOld($value) {
|
||||
require_once base_path('vendor' . DIRECTORY_SEPARATOR . 'htmlpurifier' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'HTMLPurifier.auto.php');
|
||||
$path = base_path('vendor' . DIRECTORY_SEPARATOR . 'htmlpurifier' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'HTMLPurifier' . DIRECTORY_SEPARATOR . 'DefinitionCache' . DIRECTORY_SEPARATOR . 'Serializer');
|
||||
if (!File::exists($path)) {
|
||||
File::makeDirectory($path, $mode = 0777, true, true);
|
||||
}
|
||||
@@ -56,32 +51,27 @@ class Ticket_Thread extends Model
|
||||
if ($value != strip_tags($value)) {
|
||||
$value = $purifier->purify($value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function purify()
|
||||
{
|
||||
public function purify() {
|
||||
$value = $this->attributes['body'];
|
||||
$str = str_replace("'", '"', $value);
|
||||
$html = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $str);
|
||||
$string = trim(preg_replace('/\s+/', ' ', $html));
|
||||
$content = $this->inlineAttachment($string);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function setTitleAttribute($value)
|
||||
{
|
||||
if ($value == '') {
|
||||
public function setTitleAttribute($value) {
|
||||
if ($value == "") {
|
||||
$this->attributes['title'] = 'No available';
|
||||
} else {
|
||||
$this->attributes['title'] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeScript($html)
|
||||
{
|
||||
public function removeScript($html) {
|
||||
$doc = new \DOMDocument();
|
||||
|
||||
// load the HTML string we want to strip
|
||||
@@ -99,46 +89,50 @@ class Ticket_Thread extends Model
|
||||
|
||||
// get the HTML string back
|
||||
$no_script_html_string = $doc->saveHTML();
|
||||
|
||||
return $no_script_html_string;
|
||||
}
|
||||
|
||||
public function firstContent()
|
||||
{
|
||||
public function firstContent() {
|
||||
$poster = $this->attributes['poster'];
|
||||
if ($poster == 'client') {
|
||||
return 'yes';
|
||||
}
|
||||
|
||||
return 'no';
|
||||
}
|
||||
|
||||
public function inlineAttachment($body)
|
||||
{
|
||||
if ($this->attach()->where('poster', 'INLINE')->get()->count() > 0) {
|
||||
$search = $this->attach()->where('poster', 'INLINE')->lists('name')->toArray();
|
||||
foreach ($this->attach()->where('poster', 'INLINE')->get() as $key => $attach) {
|
||||
$replace[$key] = "data:$attach->type;base64,".$attach->file;
|
||||
public function inlineAttachment($body) {
|
||||
$attachments = $this->attach;
|
||||
if ($attachments->count() > 0) {
|
||||
foreach ($attachments as $key => $attach) {
|
||||
if($attach->poster=="INLINE" || $attach->poster=="inline"){
|
||||
$search = $attach->name;
|
||||
$replace = "data:$attach->type;base64," . $attach->file;
|
||||
$b = str_replace($search, $replace, $body);
|
||||
$body = $b;
|
||||
}
|
||||
}
|
||||
$body = str_replace($search, $replace, $body);
|
||||
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function getSubject()
|
||||
{
|
||||
public function getSubject(){
|
||||
$subject = $this->attributes['title'];
|
||||
$array = imap_mime_header_decode($subject);
|
||||
$title = '';
|
||||
if (is_array($array) && count($array) > 0) {
|
||||
foreach ($array as $text) {
|
||||
$title = "";
|
||||
if(is_array($array) && count($array)>0){
|
||||
foreach($array as $text){
|
||||
$title .= $text->text;
|
||||
}
|
||||
|
||||
return wordwrap($title, 70, "<br>\n");
|
||||
}
|
||||
|
||||
return wordwrap($subject, 70, "<br>\n");
|
||||
}
|
||||
|
||||
|
||||
public function user(){
|
||||
$related = 'App\User';
|
||||
$foreignKey = 'user_id';
|
||||
return $this->belongsTo($related, $foreignKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
131
app/Model/helpdesk/Ticket/Ticket_ThreadOld.php
Normal file
131
app/Model/helpdesk/Ticket/Ticket_ThreadOld.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model\helpdesk\Ticket;
|
||||
|
||||
//use App\BaseModel;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use File;
|
||||
|
||||
class Ticket_Thread extends Model {
|
||||
|
||||
protected $table = 'ticket_thread';
|
||||
protected $fillable = [
|
||||
'id', 'ticket_id', 'staff_id', 'user_id', 'thread_type', 'poster', 'source', 'is_internal', 'title', 'body', 'format', 'ip_address', 'created_at', 'updated_at',
|
||||
];
|
||||
|
||||
public function attach() {
|
||||
return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_attachments', 'thread_id');
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
$this->attach()->delete();
|
||||
parent::delete();
|
||||
}
|
||||
|
||||
// public function setTitleAttribute($value) {
|
||||
// $this->attributes['title'] = str_replace('"', "'", $value);
|
||||
// }
|
||||
|
||||
public function getTitleAttribute($value) {
|
||||
return str_replace('"', "'", $value);
|
||||
}
|
||||
|
||||
public function thread($content) {
|
||||
// $porufi = $this->purify($content);
|
||||
// dd($content,$porufi);
|
||||
//return $content;
|
||||
return $this->purify($content);
|
||||
}
|
||||
|
||||
public function purifyOld($value) {
|
||||
require_once base_path('vendor' . DIRECTORY_SEPARATOR . 'htmlpurifier' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'HTMLPurifier.auto.php');
|
||||
$path = base_path('vendor' . DIRECTORY_SEPARATOR . 'htmlpurifier' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'HTMLPurifier' . DIRECTORY_SEPARATOR . 'DefinitionCache' . DIRECTORY_SEPARATOR . 'Serializer');
|
||||
if (!File::exists($path)) {
|
||||
File::makeDirectory($path, $mode = 0777, true, true);
|
||||
}
|
||||
$config = \HTMLPurifier_Config::createDefault();
|
||||
$config->set('HTML.Trusted', true);
|
||||
$config->set('Filter.YouTube', true);
|
||||
|
||||
$purifier = new \HTMLPurifier($config);
|
||||
if ($value != strip_tags($value)) {
|
||||
$value = $purifier->purify($value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function purify() {
|
||||
$value = $this->attributes['body'];
|
||||
$str = str_replace("'", '"', $value);
|
||||
$html = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $str);
|
||||
$string = trim(preg_replace('/\s+/', ' ', $html));
|
||||
$content = $this->inlineAttachment($string);
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function setTitleAttribute($value) {
|
||||
if ($value == "") {
|
||||
$this->attributes['title'] = 'No available';
|
||||
} else {
|
||||
$this->attributes['title'] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeScript($html) {
|
||||
$doc = new \DOMDocument();
|
||||
|
||||
// load the HTML string we want to strip
|
||||
$doc->loadHTML($html);
|
||||
|
||||
// get all the script tags
|
||||
$script_tags = $doc->getElementsByTagName('script');
|
||||
|
||||
$length = $script_tags->length;
|
||||
|
||||
// for each tag, remove it from the DOM
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$script_tags->item($i)->parentNode->removeChild($script_tags->item($i));
|
||||
}
|
||||
|
||||
// get the HTML string back
|
||||
$no_script_html_string = $doc->saveHTML();
|
||||
return $no_script_html_string;
|
||||
}
|
||||
|
||||
public function firstContent() {
|
||||
$poster = $this->attributes['poster'];
|
||||
if ($poster == 'client') {
|
||||
return 'yes';
|
||||
}
|
||||
return 'no';
|
||||
}
|
||||
|
||||
public function inlineAttachment($body) {
|
||||
if ($this->attach()->where('poster', 'INLINE')->get()->count() > 0) {
|
||||
$search = $this->attach()->where('poster', 'INLINE')->lists('name')->toArray();
|
||||
foreach ($this->attach()->where('poster', 'INLINE')->get() as $key => $attach) {
|
||||
$replace[$key] = "data:$attach->type;base64," . $attach->file;
|
||||
}
|
||||
$body = str_replace($search, $replace, $body);
|
||||
}
|
||||
return $body;
|
||||
}
|
||||
public function getSubject(){
|
||||
$subject = $this->attributes['title'];
|
||||
$array = imap_mime_header_decode($subject);
|
||||
$title = "";
|
||||
if(is_array($array) && count($array)>0){
|
||||
foreach($array as $text){
|
||||
$title .= $text->text;
|
||||
}
|
||||
return wordwrap($title, 70, "<br>\n");
|
||||
}
|
||||
return wordwrap($subject, 70, "<br>\n");
|
||||
}
|
||||
|
||||
public function labels($ticketid){
|
||||
$label = new \App\Model\helpdesk\Filters\Label();
|
||||
return $label->assignedLabels($ticketid);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,44 +4,57 @@ namespace App\Model\helpdesk\Ticket;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Ticket_attachments extends Model
|
||||
{
|
||||
class Ticket_attachments extends Model {
|
||||
|
||||
protected $table = 'ticket_attachment';
|
||||
protected $fillable = [
|
||||
'id', 'thread_id', 'name', 'size', 'type', 'file', 'data', 'poster', 'updated_at', 'created_at',
|
||||
];
|
||||
'id', 'thread_id', 'name', 'size', 'type', 'file', 'data', 'poster', 'updated_at', 'created_at',
|
||||
];
|
||||
|
||||
public function setFileAttribute($value)
|
||||
{
|
||||
$this->attributes['file'] = base64_encode($value);
|
||||
public function setFileAttribute($value) {
|
||||
if ($value) {
|
||||
$this->attributes['file'] = base64_encode($value);
|
||||
} else {
|
||||
$this->attributes['file'] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFileAttribute($value)
|
||||
{
|
||||
if (base64_decode($value, true) === false) {
|
||||
public function getFileAttribute($value) {
|
||||
$drive = $this->driver;
|
||||
$name = $this->name;
|
||||
$root = $this->path;
|
||||
if (($drive=="database" || !$drive) && $value && base64_decode($value, true) === false) {
|
||||
|
||||
$value = base64_encode($value);
|
||||
}
|
||||
if($drive && $drive!=="database"){
|
||||
|
||||
$storage = new \App\FaveoStorage\Controllers\StorageController();
|
||||
$content = $storage->getFile($drive, $name);
|
||||
$value = base64_encode($content);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getFile()
|
||||
{
|
||||
public function getFile() {
|
||||
$size = $this->size;
|
||||
$units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
$drive = $this->driver;
|
||||
$name = $this->name;
|
||||
$root = $this->path;
|
||||
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
|
||||
$power = $size > 0 ? floor(log($size, 1024)) : 0;
|
||||
$value = number_format($size / pow(1024, $power), 2, '.', ',').' '.$units[$power];
|
||||
$value = number_format($size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power];
|
||||
if ($this->poster == 'ATTACHMENT') {
|
||||
if (mime($this->type) == true) {
|
||||
$var = '<a href="'.\URL::route('image', ['image_id' => $this->id]).'" target="_blank"><img style="max-width:200px;height:133px;" src="data:image/jpg;base64,'.$this->file.'"/></a>';
|
||||
if (mime($this->type) == "image") {
|
||||
|
||||
return '<li style="background-color:#f4f4f4;"><span class="mailbox-attachment-icon has-img">'.$var.'</span><div class="mailbox-attachment-info"><b style="word-wrap: break-word;">'.$this->name.'</b><br/><p>'.$value.'</p></div></li>';
|
||||
$var = '<a href="' . \URL::route('image', array('image_id' => $this->id)) . '" target="_blank"><img style="max-width:200px;height:133px;" src="data:image/jpg;base64,' . $this->file . '"/></a>';
|
||||
return '<li style="background-color:#f4f4f4;"><span class="mailbox-attachment-icon has-img">' . $var . '</span><div class="mailbox-attachment-info"><b style="word-wrap: break-word;">' . $this->name . '</b><br/><p>' . $value . '</p></div></li>';
|
||||
} else {
|
||||
//$var = '<a href="' . URL::route('image', array('image_id' => $attachment->id)) . '" target="_blank"><img style="max-width:200px;height:133px;" src="data:'.$attachment->type.';base64,' . base64_encode($data) . '"/></a>';
|
||||
$var = '<a style="max-width:200px;height:133px;color:#666;" href="'.\URL::route('image', ['image_id' => $this->id]).'" target="_blank"><span class="mailbox-attachment-icon" style="background-color:#fff; font-size:18px;">'.strtoupper($this->type).'</span><div class="mailbox-attachment-info"><span ><b style="word-wrap: break-word;">'.$this->name.'</b><br/><p>'.$value.'</p></span></div></a>';
|
||||
|
||||
return '<li style="background-color:#f4f4f4;">'.$var.'</li>';
|
||||
$var = '<a style="max-width:200px;height:133px;color:#666;" href="' . \URL::route('image', array('image_id' => $this->id)) . '" target="_blank"><span class="mailbox-attachment-icon" style="background-color:#fff; font-size:18px;">' . strtoupper(str_limit($this->type,15)) . '</span><div class="mailbox-attachment-info"><span ><b style="word-wrap: break-word;">' . $this->name . '</b><br/><p>' . $value . '</p></span></div></a>';
|
||||
return '<li style="background-color:#f4f4f4;">' . $var . '</li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,6 @@ class Ticket_source extends BaseModel
|
||||
public $timestamps = false;
|
||||
protected $table = 'ticket_source';
|
||||
protected $fillable = [
|
||||
'name', 'value', 'css_class',
|
||||
'name', 'value','css_class',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -4,63 +4,85 @@ namespace App\Model\helpdesk\Ticket;
|
||||
|
||||
use App\BaseModel;
|
||||
|
||||
class Tickets extends BaseModel
|
||||
{
|
||||
class Tickets extends BaseModel {
|
||||
|
||||
protected $table = 'tickets';
|
||||
protected $fillable = ['id', 'ticket_number', 'num_sequence', 'user_id', 'priority_id', 'sla', 'help_topic_id', 'max_open_ticket', 'captcha', 'status', 'lock_by', 'lock_at', 'source', 'isoverdue', 'reopened', 'isanswered', 'is_deleted', 'closed', 'is_transfer', 'transfer_at', 'reopened_at', 'duedate', 'closed_at', 'last_message_at', 'last_response_at', 'created_at', 'updated_at'];
|
||||
protected $fillable = ['id', 'ticket_number', 'num_sequence', 'user_id', 'priority_id', 'sla', 'help_topic_id', 'max_open_ticket', 'captcha', 'status', 'lock_by', 'lock_at', 'source', 'isoverdue', 'reopened', 'isanswered', 'is_deleted', 'closed', 'is_transfer', 'transfer_at', 'reopened_at', 'duedate', 'closed_at', 'last_message_at', 'last_response_at', 'created_at', 'updated_at', 'assigned_to'];
|
||||
|
||||
// public function attach(){
|
||||
// return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_attachments',);
|
||||
//
|
||||
// }
|
||||
public function thread()
|
||||
{
|
||||
public function thread() {
|
||||
return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_Thread', 'ticket_id');
|
||||
}
|
||||
|
||||
public function collaborator()
|
||||
{
|
||||
public function collaborator() {
|
||||
return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_Collaborator', 'ticket_id');
|
||||
}
|
||||
|
||||
public function helptopic(){
|
||||
$related = 'App\Model\helpdesk\Manage\Help_topic';
|
||||
$foreignKey = 'help_topic_id';
|
||||
return $this->belongsTo($related, $foreignKey);
|
||||
}
|
||||
|
||||
public function formdata()
|
||||
{
|
||||
public function formdata() {
|
||||
return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_Form_Data', 'ticket_id');
|
||||
}
|
||||
|
||||
public function extraFields()
|
||||
{
|
||||
public function extraFields() {
|
||||
$id = $this->attributes['id'];
|
||||
$ticket_form_datas = \App\Model\helpdesk\Ticket\Ticket_Form_Data::where('ticket_id', '=', $id)->get();
|
||||
|
||||
return $ticket_form_datas;
|
||||
}
|
||||
|
||||
public function source()
|
||||
{
|
||||
public function source() {
|
||||
$source_id = $this->attributes['source'];
|
||||
$sources = new Ticket_source();
|
||||
$source = $sources->find($source_id);
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
||||
public function sourceCss()
|
||||
{
|
||||
$css = 'fa fa-comment';
|
||||
public function sourceCss() {
|
||||
$css = "fa fa-comment";
|
||||
$source = $this->source();
|
||||
if ($source) {
|
||||
$css = $source->css_class;
|
||||
}
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
public function delete() {
|
||||
$this->thread()->delete();
|
||||
$this->collaborator()->delete();
|
||||
$this->formdata()->delete();
|
||||
parent::delete();
|
||||
}
|
||||
|
||||
public function setAssignedToAttribute($value) {
|
||||
if (!$value) {
|
||||
$this->attributes['assigned_to'] = null;
|
||||
}else{
|
||||
$this->attributes['assigned_to'] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getAssignedTo() {
|
||||
$agentid = $this->attributes['assigned_to'];
|
||||
if ($agentid) {
|
||||
$users = new \App\User();
|
||||
$user = $users->where('id', $agentid)->first();
|
||||
if ($user) {
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function user(){
|
||||
$related = "App\User";
|
||||
$foreignKey = "user_id";
|
||||
return $this->belongsTo($related, $foreignKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user