Edit / PDF / Mail / ->Leads
This commit is contained in:
parent
5d55e5be3f
commit
66ca252bfa
43 changed files with 2915 additions and 76 deletions
100
app/Models/LeadFile.php
Normal file
100
app/Models/LeadFile.php
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class LeadFile
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $lead_id
|
||||
* @property int $lead_mail_id
|
||||
* @property string $identifier
|
||||
* @property string $filename
|
||||
* @property string $dir
|
||||
* @property string $original_name
|
||||
* @property string $ext
|
||||
* @property string $mine
|
||||
* @property int $size
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
* @property Lead $lead
|
||||
* @property LeadMail $lead_mail
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class LeadFile extends Model
|
||||
{
|
||||
protected $table = 'lead_files';
|
||||
|
||||
protected $casts = [
|
||||
'lead_id' => 'int',
|
||||
'lead_mail_id' => 'int',
|
||||
'size' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'lead_id',
|
||||
'lead_mail_id',
|
||||
'identifier',
|
||||
'filename',
|
||||
'dir',
|
||||
'original_name',
|
||||
'ext',
|
||||
'mine',
|
||||
'size'
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
];
|
||||
|
||||
public function lead()
|
||||
{
|
||||
return $this->belongsTo(Lead::class);
|
||||
}
|
||||
|
||||
public function lead_mail()
|
||||
{
|
||||
return $this->belongsTo(LeadMail::class);
|
||||
}
|
||||
|
||||
|
||||
public function getIconExt(){
|
||||
return isset(self::$icon_ext[$this->ext]) ? self::$icon_ext[$this->ext] : self::$icon_ext['default'];
|
||||
}
|
||||
|
||||
public function getURL($do=false){
|
||||
return route('storage_file', [$this->id, 'lead', $do]);
|
||||
}
|
||||
|
||||
public function getPath(){
|
||||
return \Storage::disk('lead')->path($this->dir.$this->filename);
|
||||
|
||||
}
|
||||
|
||||
public function formatBytes($precision = 2)
|
||||
{
|
||||
$size = $this->size;
|
||||
|
||||
if ($size > 0) {
|
||||
$size = (int) $size;
|
||||
$base = log($size) / log(1024);
|
||||
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
|
||||
|
||||
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
|
||||
} else {
|
||||
return $size;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue