Issues (605)

src/Services/BaseService.php (2 issues)

1
<?php
2
3
namespace Hideyo\Ecommerce\Framework\Services;
4
  
5
class BaseService
6
{
7
    /**
8
     * Find a model item
9
     * @param  integer $id
10
     * @return object|null
11
     */
12
    public function find($id)
13
    {
14
        return $this->repo->find($id);
15
    }
16
17
    /**
18
     * Select all model items
19
     * @return object|null
20
     */
21
    public function selectAll()
22
    {
23
        return $this->repo->selectAll();
24
    }
25
26
    /**
27
     * Get model
28
     * @return return object
0 ignored issues
show
The type Hideyo\Ecommerce\Framework\Services\return was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
29
     */
30
    public function getModel()
31
    {
32
        return $this->repo->getModel();
33
    }
34
35
    /**
36
     * update or add model
37
     * @param  object $model      
38
     * @param  array $attributes 
39
     * @return object             
40
     */
41
    public function updateOrAddModel($model, $attributes) 
42
    {
43
        if (count($attributes) > 0) {
44
            $model->fill($attributes);
45
            $model->save();
46
        }
47
        return $model;  
48
    }
49
50
    /**
51
     * destroy model
52
     * @param  integer $id 
53
     * @return object     
54
     */
55
    public function destroy($id)
56
    {
57
        $model = $this->find($id);
58
        return $model->delete();
59
    }
60
61
    /**
62
     * Notifications and redirect
63
     * @param  string $routeName  
64
     * @param  object $result     
65
     * @param  string $successMsg 
66
     * @return mixed          
67
     */
68
    public function notificationRedirect($routeName, $result, $successMsg) 
69
    {
70
        if (isset($result->id)) {
71
            flash($successMsg);
72
            if(is_array($routeName)) {
0 ignored issues
show
The condition is_array($routeName) is always false.
Loading history...
73
                return redirect()->route($routeName[0], $routeName[1]);
74
            }
75
            return redirect()->route($routeName);   
76
        }
77
        
78
        foreach ($result->errors()->all() as $error) {
79
            flash($error);
80
        }
81
82
        return redirect()->back()->withInput();
83
    }
84
}