Skip to content

Commit

Permalink
fixed "where" selector when used Closure
Browse files Browse the repository at this point in the history
  • Loading branch information
Sayorus committed Jun 11, 2020
1 parent bd92d35 commit e4a171f
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 25 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ Eloquent model for ClickHouse

## Installation
```sh
$ composer require sklo-agency/laravel-clickhouse
$ composer require sayorus/laravel-clickhouse
```

Then add the code above into your config/app.php file providers section
```php
Sklo\LaravelClickHouse\ClickHouseServiceProvider::class,
Sayorus\LaravelClickHouse\ClickHouseServiceProvider::class,
```
And add new connection into your config/database.php file. Something like this:
```php
Expand All @@ -27,7 +27,7 @@ And add new connection into your config/database.php file. Something like this:
'password' => '',
'options' => [
'timeout' => 10,
'protocol' => 'https'
'protocol' => 'http'
]
]
]
Expand All @@ -46,7 +46,7 @@ Or like this, if clickhouse runs in cluster
'password' => '',
'options' => [
'timeout' => 10,
'protocol' => 'https'
'protocol' => 'http'
]
],
'server-2' => [
Expand All @@ -57,7 +57,7 @@ Or like this, if clickhouse runs in cluster
'password' => '',
'options' => [
'timeout' => 10,
'protocol' => 'https'
'protocol' => 'http'
]
]
]
Expand All @@ -69,7 +69,7 @@ Then create model
```php
<?php

use Sklo\LaravelClickHouse\Database\Eloquent\Model;
use Sayorus\LaravelClickHouse\Database\Eloquent\Model;

class Payment extends Model
{
Expand Down
16 changes: 12 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "sklo-agency/laravel-clickhouse",
"name": "sayorus/laravel-clickhouse",
"description": "",
"type": "library",
"license": "MIT",
"keywords": [
Expand All @@ -10,7 +11,7 @@
"require": {
"php": ">=7.1",
"laravel/framework": "5.5.*",
"sklo-agency/clickhouse-builder": "v2.1.2"
"sayorus/clickhouse-builder": "v2.2.0"
},
"require-dev": {
"phpunit/phpunit": "^6.5",
Expand All @@ -19,15 +20,22 @@
},
"autoload": {
"psr-4": {
"Sklo\\LaravelClickHouse\\": "src/"
"Sayorus\\LaravelClickHouse\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Sklo\\LaravelClickHouse\\Tests\\": "tests/"
"Sayorus\\LaravelClickHouse\\Tests\\": "tests/"
}
},
"scripts": {
"test": "vendor/bin/phpunit --stop-on-failure tests/"
},
"extra": {
"laravel": {
"providers": [
"Sayorus\\LaravelClickHouse\\ClickHouseServiceProvider"
]
}
}
}
6 changes: 3 additions & 3 deletions src/ClickHouseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace Sklo\LaravelClickHouse;
namespace Sayorus\LaravelClickHouse;

use Illuminate\Support\ServiceProvider;
use Illuminate\Database\DatabaseManager;
use Sklo\LaravelClickHouse\Database\Connection;
use Sklo\LaravelClickHouse\Database\Eloquent\Model;
use Sayorus\LaravelClickHouse\Database\Connection;
use Sayorus\LaravelClickHouse\Database\Eloquent\Model;

class ClickHouseServiceProvider extends ServiceProvider
{
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace Sklo\LaravelClickHouse\Database;
namespace Sayorus\LaravelClickHouse\Database;

use Tinderbox\ClickhouseBuilder\Query\Grammar;
use Sklo\LaravelClickHouse\Database\Query\Builder;
use Sayorus\LaravelClickHouse\Database\Query\Builder;

class Connection extends \Tinderbox\ClickhouseBuilder\Integrations\Laravel\Connection
{
Expand Down
6 changes: 3 additions & 3 deletions src/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Sklo\LaravelClickHouse\Database\Eloquent;
namespace Sayorus\LaravelClickHouse\Database\Eloquent;

use Closure;
use BadMethodCallException;
Expand All @@ -12,7 +12,7 @@
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Database\Eloquent\RelationNotFoundException;
use Sklo\LaravelClickHouse\Database\Query\Builder as QueryBuilder;
use Sayorus\LaravelClickHouse\Database\Query\Builder as QueryBuilder;

/**
* @mixin QueryBuilder
Expand Down Expand Up @@ -135,7 +135,7 @@ public function where($column, $operator = null, $value = null, string $boolean
$this->query->where(function (QueryBuilder $queryBuilder) use ($column) {
$eloquentBuilder = $this->model->newEloquentBuilder($queryBuilder);
$column($eloquentBuilder);
});
}, $operator, $value, $boolean);
} else {
$this->query->where(...func_get_args());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Eloquent/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Sklo\LaravelClickHouse\Database\Eloquent;
namespace Sayorus\LaravelClickHouse\Database\Eloquent;

use Illuminate\Support\Arr;
use Illuminate\Support\Collection as SupportCollection;
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Eloquent/Concerns/HasAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Sklo\LaravelClickHouse\Database\Eloquent\Concerns;
namespace Sayorus\LaravelClickHouse\Database\Eloquent\Concerns;

use Illuminate\Database\Eloquent\Concerns\HasAttributes as BaseHasAttributes;

Expand Down
6 changes: 3 additions & 3 deletions src/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

declare(strict_types=1);

namespace Sklo\LaravelClickHouse\Database\Eloquent;
namespace Sayorus\LaravelClickHouse\Database\Eloquent;

use ArrayAccess;
use JsonSerializable;
use Illuminate\Support\Str;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Contracts\Support\Arrayable;
use Tinderbox\ClickhouseBuilder\Query\Grammar;
use Sklo\LaravelClickHouse\Database\Connection;
use Sayorus\LaravelClickHouse\Database\Connection;
use Illuminate\Database\ConnectionResolverInterface;
use Illuminate\Database\Eloquent\Concerns\HasEvents;
use Illuminate\Database\Eloquent\JsonEncodingException;
Expand All @@ -19,7 +19,7 @@
use Illuminate\Database\Eloquent\Concerns\GuardsAttributes;
use Illuminate\Database\Eloquent\Concerns\HasRelationships;
use Illuminate\Database\ConnectionResolverInterface as Resolver;
use Sklo\LaravelClickHouse\Database\Query\Builder as QueryBuilder;
use Sayorus\LaravelClickHouse\Database\Query\Builder as QueryBuilder;

/**
* @mixin \Eloquent
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

declare(strict_types=1);

namespace Sklo\LaravelClickHouse\Database\Query;
namespace Sayorus\LaravelClickHouse\Database\Query;

use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Tinderbox\Clickhouse\Common\Format;
use Illuminate\Support\Traits\Macroable;
use Tinderbox\ClickhouseBuilder\Query\Grammar;
use Tinderbox\ClickhouseBuilder\Query\BaseBuilder;
use Sklo\LaravelClickHouse\Database\Connection;
use Sayorus\LaravelClickHouse\Database\Connection;

class Builder extends BaseBuilder
{
Expand Down

0 comments on commit e4a171f

Please sign in to comment.