GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 77b1a2...30b493 )
by Dane
02:52
created

ServiceOption::getCopyScriptEntryAttribute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
1
<?php
2
/**
3
 * Pterodactyl - Panel
4
 * Copyright (c) 2015 - 2017 Dane Everitt <[email protected]>.
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to deal
8
 * in the Software without restriction, including without limitation the rights
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in all
14
 * copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 * SOFTWARE.
23
 */
24
25
namespace Pterodactyl\Models;
26
27
use Illuminate\Database\Eloquent\Model;
28
29
class ServiceOption extends Model
30
{
31
    /**
32
     * The table associated with the model.
33
     *
34
     * @var string
35
     */
36
    protected $table = 'service_options';
37
38
    /**
39
     * Fields that are not mass assignable.
40
     *
41
     * @var array
42
     */
43
    protected $guarded = ['id', 'created_at', 'updated_at'];
44
45
     /**
46
      * Cast values to correct type.
47
      *
48
      * @var array
49
      */
50
     protected $casts = [
51
         'service_id' => 'integer',
52
         'script_is_privileged' => 'boolean',
53
     ];
54
55
    /**
56
     * Returns the display startup string for the option and will use the parent
57
     * service one if the option does not have one defined.
58
     *
59
     * @return string
60
     */
61
    public function getDisplayStartupAttribute($value)
62
    {
63
        return (is_null($this->startup)) ? $this->service->startup : $this->startup;
64
    }
65
66
    /**
67
     * Returns the install script for the option; if option is copying from another
68
     * it will return the copied script.
69
     *
70
     * @return string
71
     */
72
    public function getCopyScriptInstallAttribute($value)
73
    {
74
        return (is_null($this->copy_script_from)) ? $this->script_install : $this->copyFrom->script_install;
75
    }
76
77
    /**
78
     * Returns the entry command for the option; if option is copying from another
79
     * it will return the copied entry command.
80
     *
81
     * @return string
82
     */
83
    public function getCopyScriptEntryAttribute($value)
84
    {
85
        return (is_null($this->copy_script_from)) ? $this->script_entry : $this->copyFrom->script_entry;
86
    }
87
88
    /**
89
     * Returns the install container for the option; if option is copying from another
90
     * it will return the copied install container.
91
     *
92
     * @return string
93
     */
94
    public function getCopyScriptContainerAttribute($value)
95
    {
96
        return (is_null($this->copy_script_from)) ? $this->script_container : $this->copyFrom->script_container;
97
    }
98
99
    /**
100
     * Gets service associated with a service option.
101
     *
102
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
103
     */
104
    public function service()
105
    {
106
        return $this->belongsTo(Service::class);
107
    }
108
109
    /**
110
     * Gets all servers associated with this service option.
111
     *
112
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
113
     */
114
    public function servers()
115
    {
116
        return $this->hasMany(Server::class, 'option_id');
117
    }
118
119
    /**
120
     * Gets all variables associated with this service.
121
     *
122
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
123
     */
124
    public function variables()
125
    {
126
        return $this->hasMany(ServiceVariable::class, 'option_id');
127
    }
128
129
    /**
130
     * Gets all packs associated with this service.
131
     *
132
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
133
     */
134
    public function packs()
135
    {
136
        return $this->hasMany(Pack::class, 'option_id');
137
    }
138
139
    public function copyFrom()
140
    {
141
        return $this->belongsTo(ServiceOption::class, 'copy_script_from');
142
    }
143
}
144