CRMCallArchive.php
1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Auth;
class CRMCallArchive extends Model{
protected $table = 'crmcalls_archive';
public function user()
{
return $this->belongsTo('App\Models\User','user_id');
}
public function getRecFilePath()
{
$file="";
$data=json_decode($this->data,true);
if(isset($data['recFolder']))
{
$recFilePath = $this->type.'_'.date('YmdHis', strtotime($this->created_at)).'_'.$this->client.'_'.$this->number.'_'.$this->id.'_'.$this->user->username.'_'.$this->crm_id;
$file=storage_path("app/".$data['recFolder'])."/".$recFilePath.".".$data['recExt'];
}
return $file;
}
// Below function for getting new file path
public function getRecFilePathNew()
{
$file="";
$data=json_decode($this->data,true);
if(isset($data['recFolder']))
{
$recFilePath = $this->type.'_'.date('YmdHis', strtotime($this->created_at)).'_'.$this->client.'_'.$this->number.'_'.$this->id.'_'.$this->user->username.'_'.$this->lan.'_'.$this->crm_id;
$file=storage_path("app/".$data['recFolder'])."/".$recFilePath.".".$data['recExt'];
}
return $file;
}
public function getRecFileExt()
{
$ext="";
$data=json_decode($this->data,true);
if(isset($data['recExt']))
{
$ext=$data['recExt'];
}
return $ext;
}
public function saveRecFileSize()
{
$fsize=0;
$data=json_decode($this->data,true);
if(isset($data['recFolder']))
{
$fpath=storage_path("app/".$data['recFolder'])."/".$this->id.".".$data['recExt'];
if(file_exists($fpath))$fsize=filesize($fpath);
}
$this->recsize=$fsize;
}
}