Failed Conditions
Pull Request — master (#55)
by Rafael
05:37
created

library/Models/AppsSettings.php (1 issue)

1
<?php
2
declare(strict_types=1);
3
4
namespace Gewaer\Models;
5
use Gewaer\Models\Apps;
6
7
class AppsSettings extends AbstractModel
8
{
9
    /**
10
     *
11
     * @var integer
12
     */
13
    public $apps_id;
14
15
    /**
16
     *
17
     * @var string
18
     */
19
    public $name;
20
21
    /**
22
     *
23
     * @var string
24
     */
25
    public $value;
26
27
    /**
28
     *
29
     * @var string
30
     */
31
    public $created_at;
32
33
    /**
34
     *
35
     * @var string
36
     */
37
    public $updated_at;
38
39
    /**
40
     *
41
     * @var integer
42
     */
43
    public $is_deleted;
44
45
    /**
46
     * Initialize method for model.
47
     */
48 3
    public function initialize()
49
    {
50
51 3
        $this->setSource('apps_settings');
52
53 3
        $this->belongsTo(
54 3
            'apps_id',
55 3
            'Gewaer\Models\Apps',
56 3
            'id',
57 3
            ['alias' => 'app']
58
        );
59 3
    }
60
61
    /**
62
     * Returns table name mapped in the model.
63
     *
64
     * @return string
65
     */
66 3
    public function getSource() : string
67
    {
68 3
        return 'apps_settings';
69
    }
70
71
    /**
72
     * Get default Apps Settings value by name
73
     * @param $name
74
     * @return string
75
     */
76 3
    public static function getDefaultAppsSettingsByName(string $name): string
77
    {
78 3
        return self::findFirst([
1 ignored issue
show
Bug Best Practice introduced by
The expression return self::findFirst(a...APP_ID, $name)))->value could return the type Phalcon\Mvc\Model\Resultset which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
79 3
            'conditions'=>'apps_id = ?0 and name = ?1 and is_deleted = 0',
80 3
            'bind'=>[Apps::GEWAER_DEFAULT_APP_ID,$name]
81 3
        ])->value;
82
    }
83
}
84