1
<?php
2

3
namespace Nuwave\Lighthouse\Schema\Directives;
4

5
use Nuwave\Lighthouse\Support\Contracts\ArgBuilderDirective;
6

7
class WhereBetweenDirective extends BaseDirective implements ArgBuilderDirective
8
{
9 1
    public static function definition(): string
10
    {
11
        return /** @lang GraphQL */ <<<'GRAPHQL'
12 1
"""
13
Verify that a column's value is between two values.
14

15
The type of the input value this is defined upon should be
16
an `input` object with two fields.
17
"""
18
directive @whereBetween(
19
  """
20
  Specify the database column to compare.
21
  Only required if database column has a different name than the attribute in your schema.
22
  """
23
  key: String
24
) repeatable on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
25
GRAPHQL;
26
    }
27

28
    /**
29
     * Apply a "WHERE BETWEEN" clause.
30
     *
31
     * @param  \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder  $builder
32
     * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder
33
     */
34 1
    public function handleBuilder($builder, $values): object
35
    {
36 1
        return $builder->whereBetween(
37 1
            $this->directiveArgValue('key', $this->nodeName()),
38
            $values
39
        );
40
    }
41
}

Read our documentation on viewing source code .

Loading