Skip to content

Commit

Permalink
Apply fixes from StyleCI (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tucker-Eric authored Jul 4, 2018
1 parent 5583402 commit 693bba9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
15 changes: 8 additions & 7 deletions src/ModelFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace EloquentFilter;

use Illuminate\Database\Eloquent\Builder as QueryBuilder;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Eloquent\Builder as QueryBuilder;

/**
* @mixin QueryBuilder
Expand Down Expand Up @@ -259,7 +259,7 @@ public function getRelationConstraints($relation)

public function callRelatedLocalSetup($related, $query)
{
if (method_exists($this, $method = camel_case($related) . 'Setup')) {
if (method_exists($this, $method = camel_case($related).'Setup')) {
$this->{$method}($query);
}
}
Expand Down Expand Up @@ -557,27 +557,28 @@ public function methodIsBlacklisted($method)
*/
public function methodIsCallable($method)
{
return !$this->methodIsBlacklisted($method) &&
return ! $this->methodIsBlacklisted($method) &&
method_exists($this, $method) &&
!method_exists(ModelFilter::class, $method);
! method_exists(ModelFilter::class, $method);
}


/**
* Register paginate and simplePaginate macros on relations
* BelongsToMany overrides the QueryBuilder's paginate to append the pivot
* BelongsToMany overrides the QueryBuilder's paginate to append the pivot.
*/
private function registerMacros()
{
if (!Relation::hasMacro('paginateFilter') && !Relation::hasMacro('simplePaginateFilter')) {
if (! Relation::hasMacro('paginateFilter') && ! Relation::hasMacro('simplePaginateFilter')) {
Relation::macro('paginateFilter', function () {
$paginator = call_user_func_array([$this, 'paginate'], func_get_args());
$paginator->appends($this->getRelated()->filtered);

return $paginator;
});
Relation::macro('simplePaginateFilter', function () {
$paginator = call_user_func_array([$this, 'simplePaginate'], func_get_args());
$paginator->appends($this->getRelated()->filtered);

return $paginator;
});
}
Expand Down
8 changes: 4 additions & 4 deletions tests/ModelFilterChildTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ protected function dbSetup()
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]
]
],
],
];
$container = m::mock(\Illuminate\Container\Container::class);
$container->shouldReceive('bound')->andReturn(false);
Expand Down Expand Up @@ -122,10 +122,10 @@ protected function dbSetup()
$clients = [['name' => 'one'], ['name' => 'two'], ['name' => 'three'], ['name' => 'four']];
foreach ($clients as $index => $data) {
$client = Client::create($data);
$user = User::create(['name' => 'Client' . $index]);
$user = User::create(['name' => 'Client'.$index]);
$user->clients()->save($client);
$client->managers()->save($user);
$otherUser = User::create(['name' => 'Client' . ++$index]);
$otherUser = User::create(['name' => 'Client'.++$index]);
$client->managers()->save($otherUser);
}
}
Expand Down

0 comments on commit 693bba9

Please sign in to comment.