@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param array $columns Columns to retrieve with the object. |
19 | 19 | * @return mixed Model|NULL An Eloquent object when there is a result, NULL when there are no matches. |
20 | 20 | */ |
21 | - public function findOneBy( $value = NULL, $field = 'id', array $columns = ['*'] ); |
|
21 | + public function findOneBy($value = NULL, $field = 'id', array $columns = ['*']); |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Finds ALL items the repository abstract without any kind of filter. |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param array $columns Columns to retrieve with the objects. |
27 | 27 | * @return mixed Collection Laravel Eloquent's Collection that may or may not be empty. |
28 | 28 | */ |
29 | - public function findAll( array $columns = ['*'] ); |
|
29 | + public function findAll(array $columns = ['*']); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Finds ALL items by the provided field. If NULL specified for the first 2 parameters, then it will take ONLY the |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param array $columns Columns to retrieve with the objects. |
38 | 38 | * @return mixed Collection Laravel Eloquent's Collection that may or may not be empty. |
39 | 39 | */ |
40 | - public function findAllBy( $value = NULL, $field = NULL, array $columns = ['*'] ); |
|
40 | + public function findAllBy($value = NULL, $field = NULL, array $columns = ['*']); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Finds ALL the items in the repository where the given field is inside the given values. |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param array $columns Columns to retrieve with the objects. |
48 | 48 | * @return mixed Collection Laravel Eloquent's Collection that may or may not be empty. |
49 | 49 | */ |
50 | - public function findAllWhereIn( array $value, $field, array $columns = ['*'] ); |
|
50 | + public function findAllWhereIn(array $value, $field, array $columns = ['*']); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * Allows you to eager-load entity relationships when retrieving entities, either with or without criterias. |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param array|string $relations Relations to eager-load along with the entities. |
56 | 56 | * @return mixed The current repository object instance. |
57 | 57 | */ |
58 | - public function with( $relations ); |
|
58 | + public function with($relations); |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Adds a criteria to the query. |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param CriteriaInterface $criteria Object that declares and implements the criteria used. |
64 | 64 | * @return mixed The current repository object instance. |
65 | 65 | */ |
66 | - public function addCriteria( CriteriaInterface $criteria ); |
|
66 | + public function addCriteria(CriteriaInterface $criteria); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Skips the current criteria (all of them). Useful when you don't want to reset the object but just not use the |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param bool|TRUE $status If you want to skip the criteria or not. |
73 | 73 | * @return mixed The current repository object instance. |
74 | 74 | */ |
75 | - public function skipCriteria( $status = TRUE ); |
|
75 | + public function skipCriteria($status = TRUE); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * Returns a Paginator that based on the criteria or filters given. |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param array $columns Columns to retrieve with the objects. |
82 | 82 | * @return Paginator object with the results and the paginator. |
83 | 83 | */ |
84 | - public function paginate( $perPage, array $columns = ['*'] ); |
|
84 | + public function paginate($perPage, array $columns = ['*']); |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Allows you to set the current page with using the paginator. Useful when you want to overwrite the $_GET['page'] |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param int $page The page you want to retrieve. |
91 | 91 | * @return mixed The current repository object instance. |
92 | 92 | */ |
93 | - public function setCurrentPage( $page ); |
|
93 | + public function setCurrentPage($page); |
|
94 | 94 | |
95 | 95 | /** |
96 | 96 | * Creates a new entity of the entity type the repository handles, given certain data. |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param array $data Data the entity will have. |
99 | 99 | * @return mixed Model|NULL An Eloquent object when the entity was created, NULL in case of error. |
100 | 100 | */ |
101 | - public function create( array $data ); |
|
101 | + public function create(array $data); |
|
102 | 102 | |
103 | 103 | /** |
104 | 104 | * Updates as many entities as the filter matches with the given $data. |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return mixed Model|NULL|integer An Eloquent object representing the updated entity, a number of entities updated if mass updating, |
110 | 110 | * or NULL in case of error. |
111 | 111 | */ |
112 | - public function updateBy( array $data, $value = NULL, $field = 'id' ); |
|
112 | + public function updateBy(array $data, $value = NULL, $field = 'id'); |
|
113 | 113 | |
114 | 114 | /** |
115 | 115 | * Removes as many entities as the filter matches. If softdelete is applied, then they will be soft-deleted. |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @param string $field Field on the database that you will filter by. Default: id. |
121 | 121 | * @return boolean TRUE It will always return TRUE. |
122 | 122 | */ |
123 | - public function delete( $value = NULL, $field = 'id' ); |
|
123 | + public function delete($value = NULL, $field = 'id'); |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * @return int number of records matching the criteria (or total amount of records). |
@@ -143,6 +143,6 @@ discard block |
||
143 | 143 | * @param string $field Field on the database that you will filter by. |
144 | 144 | * @return mixed |
145 | 145 | */ |
146 | - public function destroy( $value = NULL, $field = 'id' ); |
|
146 | + public function destroy($value = NULL, $field = 'id'); |
|
147 | 147 | |
148 | 148 | } |
149 | 149 | \ No newline at end of file |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param int $amount |
19 | 19 | * @return mixed |
20 | 20 | */ |
21 | - public function incrementCounter( Model $model, $counter, $amount = 1 ); |
|
21 | + public function incrementCounter(Model $model, $counter, $amount = 1); |
|
22 | 22 | |
23 | 23 | |
24 | 24 | /** |
@@ -31,5 +31,5 @@ discard block |
||
31 | 31 | * @param bool|FALSE $allowNegative |
32 | 32 | * @return mixed |
33 | 33 | */ |
34 | - public function decrementCounter( Model $model, $counter, $amount = 1, $allowNegative = FALSE ); |
|
34 | + public function decrementCounter(Model $model, $counter, $amount = 1, $allowNegative = FALSE); |
|
35 | 35 | } |
36 | 36 | \ No newline at end of file |
@@ -16,5 +16,5 @@ |
||
16 | 16 | * @param string $field Column in the DB used for the filter. |
17 | 17 | * @return void |
18 | 18 | */ |
19 | - public function restore( $value, $field = 'id' ); |
|
19 | + public function restore($value, $field = 'id'); |
|
20 | 20 | } |
21 | 21 | \ No newline at end of file |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * @param $path |
33 | 33 | */ |
34 | - protected function makeDirectory( $path ) |
|
34 | + protected function makeDirectory($path) |
|
35 | 35 | { |
36 | - if ( !$this->filesystem->isDirectory( $path ) ) |
|
36 | + if (!$this->filesystem->isDirectory($path)) |
|
37 | 37 | { |
38 | - $this->filesystem->makeDirectory( $path, 0775, true, true); |
|
38 | + $this->filesystem->makeDirectory($path, 0775, true, true); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | */ |
46 | 46 | protected function findDefaultImplementation() |
47 | 47 | { |
48 | - $implementationBindings = config( 'repositories.bindings' ); |
|
48 | + $implementationBindings = config('repositories.bindings'); |
|
49 | 49 | |
50 | - $filtered = array_filter( $implementationBindings, function( $k ) { |
|
50 | + $filtered = array_filter($implementationBindings, function($k) { |
|
51 | 51 | return $k === 'default'; |
52 | 52 | }); |
53 | 53 | |
54 | 54 | $default = array_keys($filtered); |
55 | - $default = is_array( $default ) ? $default[0] : $default; |
|
55 | + $default = is_array($default) ? $default[0] : $default; |
|
56 | 56 | |
57 | 57 | return $default ? $default : 'eloquent'; |
58 | 58 | } |
@@ -17,12 +17,12 @@ discard block |
||
17 | 17 | * @param int $amount |
18 | 18 | * @return Model |
19 | 19 | */ |
20 | - public function incrementCounter( Model $model, $counter, $amount = 1 ) |
|
20 | + public function incrementCounter(Model $model, $counter, $amount = 1) |
|
21 | 21 | { |
22 | - $amount = $this->getAmount( $amount ); |
|
22 | + $amount = $this->getAmount($amount); |
|
23 | 23 | |
24 | - if ( $amount ) $model->increment( $counter, $amount ); |
|
25 | - else $model->increment( $counter ); |
|
24 | + if ($amount) $model->increment($counter, $amount); |
|
25 | + else $model->increment($counter); |
|
26 | 26 | |
27 | 27 | return $model; |
28 | 28 | } |
@@ -35,22 +35,22 @@ discard block |
||
35 | 35 | * @param bool|FALSE $allowNegative |
36 | 36 | * @return Model |
37 | 37 | */ |
38 | - public function decrementCounter( Model $model, $counter, $amount = 1, $allowNegative = FALSE ) |
|
38 | + public function decrementCounter(Model $model, $counter, $amount = 1, $allowNegative = FALSE) |
|
39 | 39 | { |
40 | - $amount = $this->getAmount( $amount, 1 ); |
|
40 | + $amount = $this->getAmount($amount, 1); |
|
41 | 41 | |
42 | 42 | $currentValue = $model->{$counter}; |
43 | 43 | $final = $model->{$counter} - $amount; |
44 | 44 | |
45 | - if ( !$allowNegative ) |
|
45 | + if (!$allowNegative) |
|
46 | 46 | { |
47 | - if ( $currentValue && $final < 0 ) |
|
47 | + if ($currentValue && $final < 0) |
|
48 | 48 | { |
49 | 49 | $model->{$counter} = 0; |
50 | 50 | $model->save(); |
51 | 51 | } |
52 | 52 | |
53 | - } else $model->decrement( $counter, $amount ); |
|
53 | + } else $model->decrement($counter, $amount); |
|
54 | 54 | |
55 | 55 | return $model; |
56 | 56 | } |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * @param null $default |
62 | 62 | * @return int|null |
63 | 63 | */ |
64 | - private function getAmount( $amount, $default = NULL ) |
|
64 | + private function getAmount($amount, $default = NULL) |
|
65 | 65 | { |
66 | - return is_int( $amount ) && $amount > 1 ? $amount : $default; |
|
66 | + return is_int($amount) && $amount > 1 ? $amount : $default; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | \ No newline at end of file |
@@ -13,8 +13,8 @@ |
||
13 | 13 | * @param $value |
14 | 14 | * @param string $field |
15 | 15 | */ |
16 | - public function restore( $value, $field = 'id' ) |
|
16 | + public function restore($value, $field = 'id') |
|
17 | 17 | { |
18 | - $this->model->where( $field, $value )->restore(); |
|
18 | + $this->model->where($field, $value)->restore(); |
|
19 | 19 | } |
20 | 20 | } |
21 | 21 | \ No newline at end of file |
@@ -14,5 +14,5 @@ |
||
14 | 14 | * @param mixed $queryBuilder Current query builder. |
15 | 15 | * @return mixed $queryBuilder Current instance of the query builder with the criteria appplied. |
16 | 16 | */ |
17 | - public function apply( $queryBuilder ); |
|
17 | + public function apply($queryBuilder); |
|
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * @param array $filter |
18 | 18 | */ |
19 | - public function __construct( array $filter ) |
|
19 | + public function __construct(array $filter) |
|
20 | 20 | { |
21 | 21 | $this->filter = $filter; |
22 | 22 | } |
@@ -26,26 +26,26 @@ discard block |
||
26 | 26 | * @param $modelOrBuilder |
27 | 27 | * @return mixed |
28 | 28 | */ |
29 | - public function apply( $modelOrBuilder ) |
|
29 | + public function apply($modelOrBuilder) |
|
30 | 30 | { |
31 | - foreach( $this->filter as $filter ) |
|
31 | + foreach ($this->filter as $filter) |
|
32 | 32 | { |
33 | - $nElements = count( $filter ); |
|
33 | + $nElements = count($filter); |
|
34 | 34 | |
35 | 35 | // Apply filter based on then number of items in the array. |
36 | - if ( $nElements === 2 ) |
|
36 | + if ($nElements === 2) |
|
37 | 37 | { |
38 | 38 | $column = $filter[0]; |
39 | 39 | $operation = NULL; |
40 | 40 | $value = $filter[1]; |
41 | - } else if ( $nElements === 3 ) |
|
41 | + } else if ($nElements === 3) |
|
42 | 42 | { |
43 | 43 | $column = $filter[0]; |
44 | 44 | $operation = $filter[1]; |
45 | 45 | $value = $filter[2]; |
46 | 46 | } else continue; |
47 | 47 | |
48 | - $modelOrBuilder = $this->applyFilter( $modelOrBuilder, $column, $value, $operation ); |
|
48 | + $modelOrBuilder = $this->applyFilter($modelOrBuilder, $column, $value, $operation); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | return $modelOrBuilder; |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | * @param $value |
59 | 59 | * @param null $operation |
60 | 60 | */ |
61 | - private function applyFilter( $modelOrBuilder, $column, $value, $operation = NULL ) |
|
61 | + private function applyFilter($modelOrBuilder, $column, $value, $operation = NULL) |
|
62 | 62 | { |
63 | - if ( is_null( $operation ) ) $modelOrBuilder = $modelOrBuilder->where( $column, $value ); |
|
64 | - else $modelOrBuilder = $modelOrBuilder->where( $column, $operation, $value ); |
|
63 | + if (is_null($operation)) $modelOrBuilder = $modelOrBuilder->where($column, $value); |
|
64 | + else $modelOrBuilder = $modelOrBuilder->where($column, $operation, $value); |
|
65 | 65 | |
66 | 66 | return $modelOrBuilder; |
67 | 67 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param $orderBy |
19 | 19 | * @param string $direction |
20 | 20 | */ |
21 | - public function __construct( $orderBy, $direction = 'ASC' ) |
|
21 | + public function __construct($orderBy, $direction = 'ASC') |
|
22 | 22 | { |
23 | 23 | $this->orderBy = $orderBy; |
24 | 24 | $this->direction = $direction; |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | * @param mixed $queryBuilder |
30 | 30 | * @return mixed |
31 | 31 | */ |
32 | - public function apply( $queryBuilder ) |
|
32 | + public function apply($queryBuilder) |
|
33 | 33 | { |
34 | - return $queryBuilder->orderBy( $this->orderBy, $this->direction ); |
|
34 | + return $queryBuilder->orderBy($this->orderBy, $this->direction); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 |