<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
michaelnabil230 / laravel-query-conditions example snippets
use Illuminate\Database\Eloquent\Model;
use MichaelNabil230\QueryConditions\Support\Condition;
use MichaelNabil230\QueryConditions\Concerns\HasQueryCondonation;
use MichaelNabil230\QueryConditions\Interfaces\QueryCondonation as InterfacesQueryCondonation;
use Illuminate\Database\Eloquent\Builder;
class YourModel extends Model implements InterfacesQueryCondonation
{
use HasQueryCondonation;
public function parseQBRule(Builder $query, Condition $condition, string $method): void
{
if ($condition->rule === 'age') {
$query->{$method}('age', $condition->operator, $condition->value);
}
if ($condition->rule === 'created_at') {
$query->{$method}('created_at', $condition->operator, $condition->value);
}
}
}