PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 1.10.3
Fluent Support – Helpdesk & Customer Support Ticket System v1.10.3
2.4.0 2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 All 68 releases
fluent-support / app / Models / Attachment.php

Attachment.php in Fluent Support – Helpdesk & Customer Support Ticket System 1.10.3, at app/Models/Attachment.php

66 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentSupport\App\Models;
4
5 use FluentSupport\App\Services\Helper;
6
7 class Attachment extends Model
8 {
9 protected $table = 'fs_attachments';
10
11 protected $hidden = ['full_url', 'file_path'];
12
13 protected $appends = ['secureUrl'];
14
15 /**
16 * The attributes that are mass assignable.
17 *
18 * @var array
19 */
20 protected $fillable = [
21 'ticket_id',
22 'person_id',
23 'conversation_id',
24 'file_type',
25 'file_path',
26 'full_url',
27 'title',
28 'driver',
29 'file_size',
30 'status',
31 'settings'
32 ];
33
34 public static function boot()
35 {
36 parent::boot();
37
38 static::creating(function ($model) {
39 $uid = wp_generate_uuid4();
40 $model->file_hash = md5($uid . wp_rand(0, 1000));
41 });
42 }
43
44 public function setSettingsAttribute($settings)
45 {
46 $this->attributes['settings'] = \maybe_serialize($settings);
47 }
48
49 public function getSettingsAttribute($settings)
50 {
51 return Helper::safeUnserialize($settings);
52 }
53
54 /**
55 * Accessor to get dynamic full_name attribute
56 * @return string
57 */
58 public function getSecureUrlAttribute()
59 {
60 return add_query_arg([
61 'fst_file' => $this->file_hash,
62 'secure_sign' => md5($this->id . date('YmdH'))
63 ], site_url('/index.php'));
64 }
65 }
66