PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 2.2.0
Fluent Support – Helpdesk & Customer Support Ticket System v2.2.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 1.5.6 All 67 releases
fluent-support / app / Models / Tag.php

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

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