Completed
Push — master ( b4a558...04db93 )
by wen
03:09
created

ModelConfig::orderBy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Sco\Admin\Config;
4
5
use Illuminate\Database\Eloquent\Model;
6
use JsonSerializable;
7
use Illuminate\Contracts\Support\Arrayable;
8
use Illuminate\Contracts\Support\Jsonable;
9
use Sco\Admin\Contracts\Config as ConfigContract;
10
use Sco\Attributes\HasAttributesTrait;
11
12
class ModelConfig implements Arrayable, Jsonable, JsonSerializable
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: jsonSerialize, toArray, toJson
Loading history...
13
{
14
    use HasAttributesTrait;
15
16
    protected $configFactory;
17
    /**
18
     * @var \Illuminate\Database\Eloquent\Model
19
     */
20
    protected $model;
21
22
    public function __construct(ConfigContract $factory, Model $model)
23
    {
24
        $this->configFactory = $factory;
25
        $this->model = $model;
26
    }
27
28
    public function paginate($perPage = null)
29
    {
30
        $data = $this->model->paginate($perPage);
31
        return $data;
32
    }
33
34
    public function get()
35
    {
36
        $data = $this->model->get();
37
        return $data;
38
    }
39
40
    /**
41
     * Handle dynamic method calls into the model.
42
     *
43
     * @param  string  $method
44
     * @param  array  $parameters
45
     * @return mixed
46
     */
47
    public function __call($method, $parameters)
48
    {
49
        $this->model = $this->model->$method(...$parameters);
50
        return $this;
51
    }
52
53
    /**
54
     * Handle dynamic static method calls into the method.
55
     *
56
     * @param  string  $method
57
     * @param  array  $parameters
58
     * @return mixed
59
     */
60
    public static function __callStatic($method, $parameters)
61
    {
62
        return (new static)->$method(...$parameters);
0 ignored issues
show
Bug introduced by
The call to ModelConfig::__construct() misses some required arguments starting with $factory.
Loading history...
63
    }
64
}
65