Passed
Pull Request — master (#35)
by Rafael
04:12
created

UserWebhooksController::onConstruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 10
ccs 9
cts 9
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gewaer\Api\Controllers;
6
7
use Gewaer\Models\UserWebhooks;
8
9
/**
10
 * Class LanguagesController
11
 *
12
 * @package Gewaer\Api\Controllers
13
 *
14
 * @property Users $userData
15
 * @property Request $request
16
 * @property Config $config
17
 * @property Apps $app
18
 *
19
 */
20
class UserWebhooksController extends BaseController
21
{
22
    /*
23
     * fields we accept to create
24
     *
25
     * @var array
26
     */
27
    protected $createFields = ['webhooks_id', 'url', 'method', 'format'];
28
29
    /*
30
     * fields we accept to create
31
     *
32
     * @var array
33
     */
34
    protected $updateFields = ['webhooks_id', 'url', 'method', 'format'];
35
36
    /**
37
     * set objects
38
     *
39
     * @return void
40
     */
41 5
    public function onConstruct()
42
    {
43 5
        $this->model = new UserWebhooks();
44 5
        $this->model->users_id = $this->userData->getId();
45 5
        $this->model->companies_id = $this->userData->currentCompanyId();
46 5
        $this->model->apps_id = $this->app->getId();
47 5
        $this->additionalSearchFields = [
48 5
            ['is_deleted', ':', '0'],
49 5
            ['apps_id', ':', $this->app->getId()],
50 5
            ['companies_id', ':', '0|' . $this->userData->currentCompanyId()],
51
        ];
52 5
    }
53
}
54