PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 1.4.1
Fluent Support – Helpdesk & Customer Support Ticket System v1.4.1
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 / Tag.php

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

46 lines 1.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 Tag extends Model
6 {
7 protected $table = 'fs_taggables';
8
9 protected $fillable = ['tag_type', 'title', 'slug', 'description', 'settings', 'created_by'];
10
11 protected $searchable = ['title', 'description'];
12
13 public function setSettingsAttribute($settings)
14 {
15 $this->attributes['settings'] = \maybe_serialize($settings);
16 }
17
18 public function getSettingsAttribute($value)
19 {
20 return \maybe_unserialize($this->attributes['settings']);
21 }
22
23 /**
24 * Local scope to filter tags by search/query string
25 * @param ModelQueryBuilder $query
26 * @param string $search
27 * @return ModelQueryBuilder
28 */
29
30 public function scopeSearchBy($query, $search)
31 {
32 if ($search) {
33 $fields = $this->searchable;
34 $query->where(function ($query) use ($fields, $search) {
35 $query->where(array_shift($fields), 'LIKE', "%$search%");
36
37 foreach ($fields as $field) {
38 $query->orWhere($field, 'LIKE', "$search%");
39 }
40 });
41 }
42
43 return $query;
44 }
45 }
46