Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

Commit 910b61b

Browse files
author
Robert Kummer
committed
Merge remote-tracking branch 'origin/master'
2 parents c39177d + 6535fe1 commit 910b61b

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

src/Contracts/Repositories/Conditions/TakesConditions.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ function limit($limit);
4545
*/
4646
function whereNotNull($field);
4747

48+
/**
49+
* @param string $field
50+
* @return $this
51+
*/
52+
function whereNull($field);
53+
4854
/**
4955
* @param string|\Closure $fieldOrClosure
5056
* @param string|mixed $operatorOrValue

src/Http/Controllers/JsonApiController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Ipunkt\LaravelJsonApi\Repositories\Conditions\LimitCondition;
2828
use Ipunkt\LaravelJsonApi\Repositories\Conditions\OffsetCondition;
2929
use Ipunkt\LaravelJsonApi\Repositories\Conditions\SortByCondition;
30+
use Ipunkt\LaravelJsonApi\Resources\ResourceDefinition;
3031
use Ipunkt\LaravelJsonApi\Resources\ResourceManager;
3132
use Ipunkt\LaravelJsonApi\Resources\ResourceNotDefinedException;
3233
use Symfony\Component\HttpKernel\Exception\HttpException;

src/Repositories/Conditions/ConditionApplier.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ public function addCondition(RepositoryCondition $condition)
3939
/**
4040
* returns condition by type
4141
*
42-
* @param string $respositoryType
42+
* @param string $repositoryType
4343
* @return Collection
4444
*/
45-
public function getConditionByType(string $respositoryType) : Collection
45+
public function getConditionByType(string $repositoryType) : Collection
4646
{
47-
return $this->conditions->filter(function (RepositoryCondition $condition) use ($respositoryType) {
48-
return $condition instanceof $respositoryType;
47+
return $this->conditions->filter(function (RepositoryCondition $condition) use ($repositoryType) {
48+
return $condition instanceof $repositoryType;
4949
});
5050
}
5151

src/Repositories/Conditions/ConditionTaker.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ function whereNotNull($field)
9191
return $this;
9292
}
9393

94+
/**
95+
* @param string $field
96+
* @return $this
97+
*/
98+
function whereNull($field)
99+
{
100+
$this->builder = $this->builder->whereNull($field);
101+
return $this;
102+
}
103+
94104
/**
95105
* @param string|\Closure $fieldOrClosure
96106
* @param string|mixed $operatorOrValue

src/Validation/ValidatesRequests.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ public function validate(RequestModel $request, array $rules, array $messages =
5454
}
5555
}
5656

57+
/**
58+
* Validate the given request data with the given rules.
59+
*
60+
* @param array $data
61+
* @param array $rules
62+
* @param array $messages
63+
* @param array $customAttributes
64+
* @return void
65+
*/
66+
public function validateData(array $data, array $rules, array $messages = [], array $customAttributes = [])
67+
{
68+
$validator = $this->getValidationFactory()->make($data, $rules, $messages, $customAttributes);
69+
70+
if ($validator->fails()) {
71+
$this->throwValidationException(request(), $validator);
72+
}
73+
}
74+
5775
/**
5876
* Validate the given request with the given rules.
5977
*
@@ -94,4 +112,4 @@ protected function throwValidationException(Request $request, $validator)
94112
$request, $this->formatValidationErrors($validator)
95113
));
96114
}
97-
}
115+
}

0 commit comments

Comments
 (0)