Skip to content

Debugable

Gilberto Junior edited this page Dec 5, 2019 · 5 revisions

Avaliable for classes that extends CodeHappy\DataLayer\Repository.

Usage

Add the trait CodeHappy\DataLayer\Traits\Debugable into the repository:

<?php

namespace App\Repositories;

use CodeHappy\DataLayer\Repository;
use CodeHappy\DataLayer\Traits\Debugable;

class UserRepository extends Repository
{
    use Debugable;
}

Method

To debugs your queries.

Syntax

public function toSql(): string;

Example

PHP's way:

$productRepository->newQuery()
    ->isEqualTo('category_id', 123)
    ->orIsEqualTo('brand_id', 456)
    ->toSql();

Output:

"SELECT * FROM "products" WHERE category_id = '123' OR brand_id = '456';"

🡄 Advanced queries | Cacheable 🡆