PHP code example of makeabledk / laravel-querykit

1. Go to this page and download the library: Download makeabledk/laravel-querykit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

makeabledk / laravel-querykit example snippets


'providers' => [
    ...
    Makeable\QueryKit\QueryKitServiceProvider::class,
];

class Job extends Eloquent {
    use \Makeable\QueryKit\QueryKit;

    public function scopeHired($query)
    {
        return $query->whereIn('status', ['started', 'finished']);
    }
}

Job::hired()->first(); // a job with either 'started' or 'finished' status

$startedJob->passesScope('hired'); // true
$pendingJob->passesScope('hired'); // false

/**
 * Check if a model passes the given scope
 *
 * @param $name
 * @param array ...$args
 * @return bool
 */
public function passesScope($name, ...$args)

/**
 * Check if a model fails the given scope
 *
 * @param $name
 * @param array ...$args
 * @return bool
 */
public function failsScope($name, ...$args)

class WhereBetween implements \Makeable\QueryKit\Contracts\QueryConstraint
{
    public function __construct(...$args)
    {
        // Accept scope arguments here
    }

    public function check($model)
    {
        // Return boolean
    }
}


public function register()
{
    \Makeable\QueryKit\Builder\Builder::registerConstraint(WhereBetween::class);
}