Skip to content

Commit 32af83a

Browse files
committed
Merge branch 'master' into develop
2 parents 7ffba14 + a5278f3 commit 32af83a

File tree

12 files changed

+217
-67
lines changed

12 files changed

+217
-67
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
language: php
22

33
php:
4-
- 7.0
5-
- 7.1
4+
- 7.1.3
65
- 7.2
76

87
before_script:

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,40 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.2.23] - 13 Feb 2018
8+
### Fixed
9+
- whereBetween and value bindings parsing.
10+
11+
## [0.2.22] - 10 Feb 2018
12+
### Fixed
13+
- Laravel 5.5 dependencies.
14+
15+
## [0.2.21] - 9 Feb 2018
16+
### Added
17+
- Laravel 5.6 compatibility.
18+
19+
## [0.2.20] - 7 Feb 2018
20+
### Fixed
21+
- previously existing unit tests to properly consider changes made in 0.2.19.
22+
23+
## [0.2.19] - 7 Feb 2018
24+
### Fixed
25+
- parsing of where clause operators.
26+
27+
## [0.2.18] - 16 Jan 2018
28+
### Added
29+
- hashing of cache keys to prevent key length over-run issues.
30+
31+
### Updated
32+
- dependency version constraint for "pretty test printer".
33+
34+
## [0.2.17] - 10 Jan 2018
35+
###Added
36+
- caching for value() querybuilder method.
37+
38+
### Updated
39+
- tests to use Orchestral Testbench.
40+
741
## [0.2.16] - 5 Jan 2018
842
### Added
943
- `thanks` package.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
# Model Caching for Laravel
44
[![Gitter](https://badges.gitter.im/GeneaLabs/laravel-model-caching.svg)](https://gitter.im/GeneaLabs/laravel-model-caching?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge)
5-
[![Travis](https://img.shields.io/travis/GeneaLabs/laravel-model-caching.svg)](https://travis-ci.org/GeneaLabs/laravel-model-caching)
6-
[![Scrutinizer](https://img.shields.io/scrutinizer/g/GeneaLabs/laravel-model-caching.svg)](https://scrutinizer-ci.com/g/GeneaLabs/laravel-model-caching)
7-
[![Coveralls](https://img.shields.io/coveralls/GeneaLabs/laravel-model-caching.svg)](https://coveralls.io/github/GeneaLabs/laravel-model-caching)
5+
[![Travis](https://img.shields.io/travis/GeneaLabs/laravel-model-caching/master.svg)](https://travis-ci.org/GeneaLabs/laravel-model-caching)
6+
[![Scrutinizer](https://img.shields.io/scrutinizer/g/GeneaLabs/laravel-model-caching/master.svg)](https://scrutinizer-ci.com/g/GeneaLabs/laravel-model-caching)
7+
[![Coveralls](https://img.shields.io/coveralls/GeneaLabs/laravel-model-caching/master.svg)](https://coveralls.io/github/GeneaLabs/laravel-model-caching)
88
[![GitHub (pre-)release](https://img.shields.io/github/release/GeneaLabs/laravel-model-caching/all.svg)](https://github.com/GeneaLabs/laravel-model-caching)
99
[![Packagist](https://img.shields.io/packagist/dt/GeneaLabs/laravel-model-caching.svg)](https://packagist.org/packages/genealabs/laravel-model-caching)
1010
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/GeneaLabs/laravel-model-caching/master/LICENSE)
@@ -23,8 +23,8 @@ relationships. This package is the attempt to address those requirements.
2323
flush entire cache for providers that don't).
2424

2525
## Requirements
26-
- PHP >= 7.0.0
27-
- Laravel 5.5
26+
- PHP >= 7.1.3
27+
- Laravel >= 5.5
2828

2929
## Installation
3030
```

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
}
1010
],
1111
"require": {
12-
"illuminate/cache": "5.5.*",
13-
"illuminate/database": "5.5.*",
14-
"php": ">=7.0.0"
12+
"illuminate/cache": "5.5 - 5.6",
13+
"illuminate/database": "5.5 - 5.6",
14+
"php": ">=7.1.3"
1515
},
1616
"require-dev": {
1717
"codedungeon/phpunit-result-printer": "*",
1818
"fzaninotto/faker": "~1.4",
1919
"mockery/mockery": "0.9.*",
20-
"orchestra/database": "^3.5",
21-
"orchestra/testbench-browser-kit": "^3.5",
22-
"orchestra/testbench-dusk": "3.5.x-dev@dev",
23-
"orchestra/testbench": "^3.5",
20+
"orchestra/database": "3.6.x-dev@dev",
21+
"orchestra/testbench-browser-kit": "^3.6",
22+
"orchestra/testbench-dusk": "3.6.x-dev@dev",
23+
"orchestra/testbench": "^3.6",
2424
"php-coveralls/php-coveralls" : "*",
2525
"phpmd/phpmd": "*",
2626
"phpunit/phpunit": "*",

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
convertWarningsToExceptions="true"
1010
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer"
1111
processIsolation="false"
12-
stopOnFailure="false"
12+
stopOnFailure="true"
1313
syntaxCheck="false"
1414
>
1515
<testsuites>

src/CacheKey.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,28 @@ protected function getQueryColumns(array $columns) : string
9090

9191
protected function getTypeClause($where) : string
9292
{
93-
return in_array($where['type'], ['In', 'Null', 'NotNull'])
93+
$type =in_array($where['type'], ['In', 'Null', 'NotNull', 'between'])
9494
? strtolower($where['type'])
95-
: '';
95+
: strtolower($where['operator']);
96+
97+
return str_replace(' ', '_', $type);
9698
}
9799

98100
protected function getValuesClause(array $where = null) : string
99101
{
100-
return is_array(array_get($where, 'values'))
101-
? '_' . implode('_', $where['values'])
102+
if (in_array($where['type'], ['NotNull'])) {
103+
return '';
104+
}
105+
106+
$values = is_array(array_get($where, 'values'))
107+
? implode('_', $where['values'])
102108
: '';
109+
110+
if (! $values && $this->query->bindings['where'] ?? false) {
111+
$values = implode('_', $this->query->bindings['where']);
112+
}
113+
114+
return '_' . $values;
103115
}
104116

105117
protected function getWhereClauses(array $wheres = []) : string
@@ -149,8 +161,7 @@ protected function getOtherClauses(array $where, string $carry = null) : string
149161
return '';
150162
}
151163

152-
$value = array_get($where, 'value');
153-
$value .= $this->getTypeClause($where);
164+
$value = $this->getTypeClause($where);
154165
$value .= $this->getValuesClause($where);
155166

156167
return "{$carry}-{$where['column']}_{$value}";

tests/CreatesApplication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public function setUp()
1010
parent::setUp();
1111

1212
$this->withFactories(__DIR__ . '/database/factories');
13-
$this->loadMigrationsFrom(realpath(__DIR__ . '/database/migrations'));
13+
$this->loadMigrationsFrom(__DIR__ . '/database/migrations');
1414
}
1515

1616
/**

tests/Fixtures/Book.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66

77
class Book extends CachedModel
88
{
9+
protected $casts = [
10+
'price' => 'float',
11+
];
912
protected $dates = [
1013
'published_at',
1114
];
1215
protected $fillable = [
1316
'description',
1417
'published_at',
1518
'title',
19+
'price',
1620
];
1721

1822
public function author() : BelongsTo

0 commit comments

Comments
 (0)