Edit / PDF / Mail / ->Leads
This commit is contained in:
parent
5d55e5be3f
commit
66ca252bfa
43 changed files with 2915 additions and 76 deletions
91
app/Models/LeadNotice.php
Normal file
91
app/Models/LeadNotice.php
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\User;
|
||||
|
||||
|
||||
/**
|
||||
* Class LeadNotice
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $lead_id
|
||||
* @property int $from_user_id
|
||||
* @property int $to_user_id
|
||||
* @property string $message
|
||||
* @property bool $show
|
||||
* @property bool $important
|
||||
* @property Carbon $edit_at
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
* @property User $user
|
||||
* @property Lead $lead
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class LeadNotice extends Model
|
||||
{
|
||||
protected $table = 'lead_notices';
|
||||
|
||||
protected $casts = [
|
||||
'lead_id' => 'int',
|
||||
'from_user_id' => 'int',
|
||||
'to_user_id' => 'int',
|
||||
'show' => 'bool',
|
||||
'important' => 'bool'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'edit_at'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'lead_id',
|
||||
'from_user_id',
|
||||
'to_user_id',
|
||||
'message',
|
||||
'show',
|
||||
'important',
|
||||
'edit_at'
|
||||
];
|
||||
|
||||
public function to_user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'to_user_id');
|
||||
}
|
||||
|
||||
public function from_user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'from_user_id');
|
||||
}
|
||||
public function lead()
|
||||
{
|
||||
return $this->belongsTo(Lead::class);
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
if($this->from_user){
|
||||
if($this->from_user->sf_guard_user){
|
||||
return $this->from_user->sf_guard_user->first_name." ".$this->from_user->sf_guard_user->last_name;
|
||||
}else{
|
||||
$this->from_user->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getSmallerMessage($max = 500){
|
||||
|
||||
$ret = substr($this->message, 0, $max);
|
||||
if(strlen($this->message) > 500){
|
||||
$ret .= " ...";
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue