PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 2.2.0
Fluent Support – Helpdesk & Customer Support Ticket System v2.2.0
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 / SavedReply.php

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

103 lines 2.1 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 class SavedReply extends Model
6 {
7 protected $table = 'fs_saved_replies';
8
9 /**
10 * The attributes that are mass assignable.
11 *
12 * @var array
13 */
14 protected $fillable = [
15 'created_by',
16 'product_id',
17 'title',
18 'content'
19 ];
20
21 /**
22 * $searchable Columns in table to search
23 * @var array
24 */
25 protected $searchable = [
26 'title',
27 'content'
28 ];
29
30 /**
31 * The attributes that should be cast.
32 *
33 * @var array
34 */
35 protected $casts = [
36 'product_id' => 'integer'
37 ];
38
39 /**
40 * Local scope to filter subscribers by search/query string
41 * @param ModelQueryBuilder $query
42 * @param string $search
43 * @return ModelQueryBuilder
44 */
45 public function scopeSearchBy($query, $search)
46 {
47 if ($search) {
48 $fields = $this->searchable;
49 $query->where(function ($query) use ($fields, $search) {
50 $query->where(array_shift($fields), 'LIKE', "%$search%");
51
52 foreach ($fields as $field) {
53 $query->orWhere($field, 'LIKE', "$search%");
54 }
55 });
56 }
57
58 return $query;
59 }
60
61 /**
62 * Local scope to filter subscribers by search/query string
63 * @param ModelQueryBuilder $query
64 * @param array $statuses
65 * @return ModelQueryBuilder
66 */
67 public function scopeProductBy($query, $productId)
68 {
69 if ($productId) {
70 $query->where('product_id', $productId);
71 }
72
73 return $query;
74 }
75
76 /**
77 * One2Many: Customer has to many Click Tickets
78 * @return Model Collection
79 */
80 public function person()
81 {
82 $class = __NAMESPACE__ . '\Person';
83
84 return $this->belongsTo(
85 $class, 'created_by', 'id'
86 );
87 }
88
89 /**
90 * One2Many: Customer has to many Click Tickets
91 * @return Model Collection
92 */
93 public function product()
94 {
95 $class = __NAMESPACE__ . '\Product';
96
97 return $this->belongsTo(
98 $class, 'product_id', 'id'
99 );
100 }
101
102 }
103