PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 1.5.3
Fluent Support – Helpdesk & Customer Support Ticket System v1.5.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 / SavedReply.php

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

94 lines 2.0 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 * Local scope to filter subscribers by search/query string
32 * @param ModelQueryBuilder $query
33 * @param string $search
34 * @return ModelQueryBuilder
35 */
36 public function scopeSearchBy($query, $search)
37 {
38 if ($search) {
39 $fields = $this->searchable;
40 $query->where(function ($query) use ($fields, $search) {
41 $query->where(array_shift($fields), 'LIKE', "%$search%");
42
43 foreach ($fields as $field) {
44 $query->orWhere($field, 'LIKE', "$search%");
45 }
46 });
47 }
48
49 return $query;
50 }
51
52 /**
53 * Local scope to filter subscribers by search/query string
54 * @param ModelQueryBuilder $query
55 * @param array $statuses
56 * @return ModelQueryBuilder
57 */
58 public function scopeProductBy($query, $productId)
59 {
60 if ($productId) {
61 $query->where('product_id', $productId);
62 }
63
64 return $query;
65 }
66
67 /**
68 * One2Many: Customer has to many Click Tickets
69 * @return Model Collection
70 */
71 public function person()
72 {
73 $class = __NAMESPACE__ . '\Person';
74
75 return $this->belongsTo(
76 $class, 'created_by', 'id'
77 );
78 }
79
80 /**
81 * One2Many: Customer has to many Click Tickets
82 * @return Model Collection
83 */
84 public function product()
85 {
86 $class = __NAMESPACE__ . '\Product';
87
88 return $this->belongsTo(
89 $class, 'product_id', 'id'
90 );
91 }
92
93 }
94