PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 1.5.2
Fluent Support – Helpdesk & Customer Support Ticket System v1.5.2
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 / Product.php

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

51 lines 1.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 Product extends Model
6 {
7 protected $table = 'fs_products';
8
9
10 /**
11 * The attributes that are mass assignable.
12 *
13 * @var array
14 */
15 protected $fillable = [
16 'source_uid',
17 'title',
18 'description',
19 'settings',
20 'source',
21 'created_by'
22 ];
23
24 protected $searchable = ['title', 'description'];
25
26 /**
27 * Local scope to filter products by search/query string
28 * @param ModelQueryBuilder $query
29 * @param string $search
30 * @return ModelQueryBuilder
31 */
32
33 public function scopeSearchBy($query, $search)
34 {
35 if ($search) {
36 $fields = $this->searchable;
37 $query->where(function ($query) use ($fields, $search) {
38 $query->where(array_shift($fields), 'LIKE', "%$search%");
39
40 foreach ($fields as $field) {
41 $query->orWhere($field, 'LIKE', "$search%");
42 }
43 });
44 }
45
46 return $query;
47 }
48
49
50 }
51