Completed
Push — master ( e74f66...642bbe )
by Jan
01:51
created

Settings::getByName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
/**
3
 * Settings module model
4
 * 
5
 * Model for module Settings
6
 * 
7
 * @category Model
8
 * @subpackage Admin
9
 * @package Olapus
10
 * @author Jan Drda <[email protected]>
11
 * @copyright Jan Drda
12
 * @license https://opensource.org/licenses/MIT MIT
13
 */
14
15
namespace App;
16
17
use Illuminate\Database\Eloquent\Model;
18
use Illuminate\Database\Eloquent\SoftDeletes;
19
20
class Settings extends Model
21
{
22
    use SoftDeletes, AdminModelTrait;
23
24
    /**
25
     * Get settings by name
26
     *
27
     * @param $name
28
     * @return |null
0 ignored issues
show
Documentation introduced by
The doc-type |null could not be parsed: Unknown type name "|" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
29
     */
30
    public static function getByName($name){
31
        $result = self::where('name', $name)->first();
32
        if(!empty($result)){
33
            return $result->value;
34
        }
35
        else{
36
            return null;
37
        }
38
    }
39
40
41
    /**
42
     * The database table used by the model.
43
     *
44
     * @var string
45
     */
46
    protected $table = 'settings';
47
    
48
    /**
49
     * The attributes that should be mutated to dates.
50
     *
51
     * @var array
52
     */
53
    protected $dates = ['created_at', 'updated_at', 'deleted_at'];
54
    
55
    /**
56
     * The attributes that are mass assignable.
57
     *
58
     * @var array
59
     */
60
    protected $fillable = ['name', 'value', 'description'];
61
    
62
    /**
63
     * Columns to exclude from index
64
     * 
65
     * @var array 
66
     */
67
    protected $excludedFromIndex = [];
68
    
69
    /**
70
     * Fields to search in fulltext mode
71
     * 
72
     * @var array
73
     */
74
    protected $fulltextFields = [
75
        'id',
76
        'name' => [
77
            'operator' => 'LIKE',
78
            'prefix' => '%',
79
            'sufix' => '%'
80
        ],
81
        'value' => [
82
            'operator' => 'LIKE',
83
            'prefix' => '%',
84
            'sufix' => '%'
85
        ],
86
        'description' => [
87
            'operator' => 'LIKE',
88
            'prefix' => '%',
89
            'sufix' => '%'
90
        ],
91
    ];
92
    
93
    /**
94
     * Default order by
95
     * 
96
     * @var array
97
     */
98
    protected $defaultOrderBy = [
99
      'name' => 'asc'  
100
    ];
101
    
102
}
103