Skip to content

Commit

Permalink
Merge branch 'master' of github.com:laraplus/translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
Anže Časar committed Apr 26, 2016
2 parents b21ec84 + abe229a commit f174dd2
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: php

php:
- 5.6
- 7.0
- hhvm

before_script:
composer install --dev --prefer-source --no-interaction

script: vendor/bin/phpunit
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Translatable Eloquent models (Laravel 5.2+)

[![Build Status](https://travis-ci.org/laraplus/translatable.svg)](https://travis-ci.org/laraplus/translatable)

This package provides a powerful and transparent way of managing multilingual models in Eloquent.

It makes use of Laravel's 5.2 enhanced global scopes to join translated attributes to every query rather than utilizing
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": ">=5.5.0",
"illuminate/database": "~5.2@dev"
"illuminate/database": "~5.2"
},
"require-dev": {
"phpunit/phpunit": "5.1.*"
Expand Down
4 changes: 2 additions & 2 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ protected function updateI18n(array $values)
}

$updated = $this->i18nQuery()
->where($this->model->getForeignKey(), $this->model->getKey())
->where($this->model->getLocaleKey(), $this->model->getLocale())
->whereOriginal($this->model->getForeignKey(), $this->model->getKey())
->whereOriginal($this->model->getLocaleKey(), $this->model->getLocale())
->update($values);

if(!$updated) {
Expand Down
16 changes: 16 additions & 0 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
return parent::where($column, $operator, $value, $boolean);
}

/**
* Add a where clause to the query and don't modify it for i18n.
*
* @param string|\Closure $column
* @param string $operator
* @param mixed $value
* @param string $boolean
* @return $this
*
* @throws \InvalidArgumentException
*/
public function whereOriginal($column, $operator = null, $value = null, $boolean = 'and')
{
return parent::where($column, $operator, $value, $boolean);
}

/**
* Add a translation where clause to the query.
*
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function setUp()

$capsule->addConnection([
'driver' => 'sqlite',
'database' => __DIR__.'/stubs/database.sqlite',
'database' => ':memory:',
'prefix' => ''
]);

Expand Down

0 comments on commit f174dd2

Please sign in to comment.