Completed
Push — master ( e04365...86cad5 )
by vijay
09:15 queued 05:39
created

SlaController::create()   B

Complexity

Conditions 4
Paths 14

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 23
rs 8.7972
cc 4
eloc 16
nc 14
nop 0
1
<?php
2
3
namespace App\Http\Controllers\Licence;
4
5
use App\Http\Controllers\Controller;
6
use App\Model\licence\Licence;
7
use App\Model\Licence\LicencedOrganization;
8
use App\Model\licence\Sla;
9
use App\Model\licence\SlaServiceRelation;
10
use App\Model\Product\Service;
11
use App\Organization;
12
use Illuminate\Http\Request;
13
14
class SlaController extends Controller
15
{
16
    public $sla;
17
    public $slaServiceRelation;
18
    public $service;
19
    public $licence;
20
    public $organization;
21
    public $licencedOrganization;
22
23
    public function __construct()
24
    {
25
        $this->middleware('auth');
26
        $this->middleware('service.provider', ['only' => ['create', 'store', 'edit', 'update']]);
27
        //$this->middleware('admin');
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
28
        $cart = new \App\Http\Controllers\Front\CheckoutController();
29
        $auth = $cart->GetXdeskAuthOrganization();
0 ignored issues
show
Documentation Bug introduced by
The method GetXdeskAuthOrganization does not exist on object<App\Http\Controll...ont\CheckoutController>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
30
        $this->org = $auth;
0 ignored issues
show
Bug introduced by
The property org does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
31
32
        $sla = new Sla();
33
        $this->sla = $sla;
34
35
        $slaServiceRelation = new SlaServiceRelation();
36
        $this->slaServiceRelation = $slaServiceRelation;
37
38
        $service = new Service();
39
        $this->service = $service;
40
41
        $licence = new Licence();
42
        $this->licence = $licence;
43
44
        $organization = new Organization();
45
        $this->organization = $organization;
46
47
        $licencedOrganization = new LicencedOrganization();
48
        $this->licencedOrganization = $licencedOrganization;
49
    }
50
51
    public function index()
52
    {
53
        try {
54
            return view('themes.default1.sla.index');
55
        } catch (\Exception $ex) {
56
            return redirect()->back()->with('fails', $ex->getMessage());
57
        }
58
    }
59
60
    public function GetSlas()
61
    {
62
        return \Datatable::collection($this->sla->get())
0 ignored issues
show
Documentation Bug introduced by
The method get does not exist on object<App\Model\licence\Sla>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
63
                        ->addColumn('licence_id', function ($model) {
64
                            $licence_name = $this->licence->where('id', $model->licence_id)->first()->name;
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Model\licence\Licence>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
65
66
                            return $licence_name;
67
                        })
68
                        ->showColumns('name', 'description')
69 View Code Duplication
                        ->addColumn('service', function ($model) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
70
                            $serviceid = $this->slaServiceRelation->where('sla_id', $model->id)->first()->service_id;
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Model\licence\SlaServiceRelation>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
71
72
                            return $this->service->where('id', $serviceid)->first()->name;
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Model\Product\Service>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
73
                        })
74 View Code Duplication
                        ->addColumn('organization_id', function ($model) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
75
                            $name = $this->organization->where('id', $model->organization_id)->where('type', 'client')->first()->name;
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Organization>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
76
77
                            return $name;
78
                        })
79
                        ->addColumn('service_provider_id', function ($model) {
80
                            $name = $this->organization->where('id', $model->service_provider_id)->where('type', 'service_provider')->first()->name;
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Organization>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
81
82
                            return $name;
83
                        })
84
                        ->showColumns('start_date', 'end_date', 'grace_period')
85
                        ->addColumn('action', function ($model) {
86
                            return '<a href='.url('slas/'.$model->id.'/edit')." class='btn btn-sm btn-primary'>Edit</a>";
87
                        })
88
                        ->searchColumns('name')
89
                        ->orderColumns('name')
90
                        ->make();
91
    }
92
93
    public function create()
94
    {
95
        try {
96
            //dd($this->org);
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
97
            $organizations = $this->organization->where('type', 'client')->lists('name', 'id')->toArray();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Organization>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
98
            if ($this->org->type == 'xdesk') {
99
                $licences = $this->licence->lists('name', 'id')->toArray();
0 ignored issues
show
Documentation Bug introduced by
The method lists does not exist on object<App\Model\licence\Licence>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
100
                $serviceProviders = $this->organization->where('type', 'service_provider')->lists('name', 'id')->toArray();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Organization>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
101
            } else {
102
                $purchased = $this->licencedOrganization->where('organization_id', $this->org->id)->where('payment_status', 'success')->distinct('licence_name')->lists('licence_name');
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Model\Licence\LicencedOrganization>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
103
                if (count($purchased) == 0) {
104
                    return redirect()->back()->with('fails', 'No licence to create SLA');
105
                }
106
                $licences = $this->licence->whereIn('name', $purchased)->lists('name', 'id')->toArray();
0 ignored issues
show
Documentation Bug introduced by
The method whereIn does not exist on object<App\Model\licence\Licence>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
107
                $serviceProviders = [$this->org->id => $this->org->name];
108
            }
109
            $services = $this->service->lists('name', 'id')->toArray();
0 ignored issues
show
Documentation Bug introduced by
The method lists does not exist on object<App\Model\Product\Service>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
110
111
            return view('themes.default1.sla.create', compact('organizations', 'serviceProviders', 'services', 'licences'));
112
        } catch (\Exception $ex) {
113
            return redirect()->back()->with('fails', $ex->getMessage());
114
        }
115
    }
116
117
    public function store(Request $request)
118
    {
119
        try {
120
            if ($this->org->type == 'xdesk') {
121
                $serviceprovider_id = $request->input('service_provider_id');
122
            } else {
123
                $serviceprovider_id = $this->org->id;
124
            }
125
            $service_id = $request->input('service');
126
127
            $serviceprovider = $this->organization->where('id', $serviceprovider_id)->where('type', 'service_provider')->first();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Organization>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
128
            $licenced = $this->licencedOrganization->where('organization_id', $serviceprovider->id)->lists('number_of_slas', 'licence_name')->toArray();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Model\Licence\LicencedOrganization>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
129
            //dd($licenced);
130
            //check if service provider purchased licence
131
            if (count($licenced) == 0) {
132
                return redirect()->back()->with('fails', 'No Licence');
133
            }
134
            $CountOfSlaCanCreate = array_sum($licenced);
135
            //dd($CountOfSlaCanCreate);
136
            $CountOfSlaCreated = $this->sla->where('service_provider_id', $serviceprovider->id)->count();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Model\licence\Sla>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
137
138
            //check if service provider has enough licence to create slas OR it is unlimited licence
139
            if ($CountOfSlaCanCreate > $CountOfSlaCreated || in_array('0', $licenced)) {
140
                $this->sla->fill($request->input())->save();
0 ignored issues
show
Bug introduced by
It seems like $request->input() targeting Illuminate\Http\Request::input() can also be of type string; however, Illuminate\Database\Eloquent\Model::fill() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
141
                $this->slaServiceRelation->create(['sla_id' => $this->sla->id, 'service_id' => $service_id]);
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<App\Model\licence\Sla>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
142
143
                return redirect()->back()->with('success', \Lang::get('message.saved-successfully'));
144
            } else {
145
                return redirect()->back()->with('fails', 'Licence Over to create Slas ! ');
146
            }
147
        } catch (\Exception $ex) {
148
            return redirect()->back()->with('fails', $ex->getMessage());
149
        }
150
    }
151
152
    public function edit($id)
153
    {
154
        try {
155
            $organizations = $this->organization->where('type', 'client')->lists('name', 'id')->toArray();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Organization>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
156
            if ($this->org->type == 'xdesk') {
157
                $licences = $this->licence->lists('name', 'id')->toArray();
0 ignored issues
show
Documentation Bug introduced by
The method lists does not exist on object<App\Model\licence\Licence>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
158
                $serviceProviders = $this->organization->where('type', 'service_provider')->lists('name', 'id')->toArray();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Organization>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
159
            } else {
160
                $purchased = $this->licencedOrganization->where('organization_id', $this->org->id)->where('payment_status', 'success')->distinct('licence_name')->lists('licence_name');
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Model\Licence\LicencedOrganization>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
161
                if (count($purchased) == 0) {
162
                    return redirect()->back()->with('fails', 'No licence to create SLA');
163
                }
164
                $licences = $this->licence->whereIn('name', $purchased)->lists('name', 'id')->toArray();
0 ignored issues
show
Documentation Bug introduced by
The method whereIn does not exist on object<App\Model\licence\Licence>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
165
                $serviceProviders = $this->organization->where('type', 'service_provider')->where('id', $this->org->id)->lists('name', 'id')->toArray();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Organization>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
166
            }
167
            $services = $this->service->lists('name', 'id')->toArray();
0 ignored issues
show
Documentation Bug introduced by
The method lists does not exist on object<App\Model\Product\Service>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
168
            $sla = $this->sla->where('id', $id)->first();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Model\licence\Sla>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
169
170
            return view('themes.default1.sla.edit', compact('organizations', 'serviceProviders', 'services', 'sla', 'licences'));
171
        } catch (\Exception $ex) {
172
            return redirect()->back()->with('fails', $ex->getMessage());
173
        }
174
    }
175
176
    public function update($id, Request $request)
177
    {
178
        try {
179
            $service = $this->slaServiceRelation->where('sla_id', $id)->first();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Model\licence\SlaServiceRelation>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
180
            $service->delete();
181
182
            $service_id = $request->input('service');
183
            $sla = $this->sla->where('id', $id)->first();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Model\licence\Sla>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
184
            $sla->fill($request->input())->save();
185
            $this->slaServiceRelation->create(['sla_id' => $id, 'service_id' => $service_id]);
186
187
            return redirect()->back()->with('success', \Lang::get('message.updated-successfully'));
188
        } catch (\Exception $ex) {
189
            return redirect()->back()->with('fails', $ex->getMessage());
190
        }
191
    }
192
}
193