Completed
Push — master ( 62d2ea...1993b9 )
by Andrii
11:09
created

SaleController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 27
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B actions() 0 24 1
1
<?php
2
3
namespace hipanel\modules\finance\controllers;
4
5
use hipanel\actions\IndexAction;
6
use hipanel\actions\ViewAction;
7
use hipanel\modules\client\models\stub\ClientRelationFreeStub;
8
use hipanel\modules\finance\logic\TariffManagerFactory;
9
use hipanel\modules\finance\models\Tariff;
10
use yii\base\Event;
11
12
class SaleController extends \hipanel\base\CrudController
13
{
14
    public function actions()
15
    {
16
        return [
17
            'index' => [
18
                'class' => IndexAction::class,
19
            ],
20
            'view' => [
21
                'class' => ViewAction::class,
22
                'data' => function ($action) {
23
                    $sale = $action->model;
24
                    $attributes = [
25
                        'id' => $sale->buyer_id,
26
                        'login' => $sale->buyer,
27
                        'seller' => $sale->seller,
28
                        'seller_id' => $sale->seller_id,
29
                    ];
30
                    $client = new ClientRelationFreeStub($attributes);
31
                    $tariff = Tariff::find()->where(['id' => $sale->tariff_id])->one();
32
33
                    return compact('client', 'tariff');
34
                },
35
            ],
36
        ];
37
    }
38
}
39