EscolaLMS/Courses

View on GitHub
src/Repositories/Criteria/Primitives/LikeCriterion.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%
<?php

namespace EscolaLms\Courses\Repositories\Criteria\Primitives;

use EscolaLms\Core\Repositories\Criteria\Criterion;
use Illuminate\Database\Eloquent\Builder;

class LikeCriterion extends Criterion
{

    public function apply(Builder $query): Builder
    {
        if (!$this->value) {
            return $query;
        }

        return $query->where($this->key, 'ILIKE', '%' . $this->value . '%');
    }
}