forked from spatie/laravel-query-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvalidAppendQuery.php
32 lines (24 loc) · 1008 Bytes
/
InvalidAppendQuery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
namespace Spatie\QueryBuilder\Exceptions;
use Illuminate\Http\Response;
use Illuminate\Support\Collection;
class InvalidAppendQuery extends InvalidQuery
{
/** @var \Illuminate\Support\Collection */
public $appendsNotAllowed;
/** @var \Illuminate\Support\Collection */
public $allowedAppends;
public function __construct(Collection $appendsNotAllowed, Collection $allowedAppends)
{
$this->appendsNotAllowed = $appendsNotAllowed;
$this->allowedAppends = $allowedAppends;
$appendsNotAllowed = $appendsNotAllowed->implode(', ');
$allowedAppends = $allowedAppends->implode(', ');
$message = "Requested append(s) `{$appendsNotAllowed}` are not allowed. Allowed append(s) are `{$allowedAppends}`.";
parent::__construct(Response::HTTP_BAD_REQUEST, $message);
}
public static function appendsNotAllowed(Collection $appendsNotAllowed, Collection $allowedAppends)
{
return new static(...func_get_args());
}
}