Skip to content

Commit

Permalink
last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PyaeSoneAungRgn committed Jul 7, 2023
1 parent 270eb09 commit d40f0b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

# To Raw SQL

⚠️ The `toRawSql()` function is included by default in Laravel 10.14.2. You don't need to install this package if your Laravel version is greater than 10.14.1 ⚠️

Get raw SQL from Laravel Query Builder and Eloquent Builder

## Installation
Expand Down Expand Up @@ -36,6 +38,8 @@ DB::table('users')

## Version History

- 1.1.3
- Do not register the `toRawSql()` macro if the Laravel version is greater than 10.14.1
- 1.1.2
- throw ToRawSqlException when encountering PostgreSQL jsonb operator errors
- 1.1.1
Expand Down
8 changes: 6 additions & 2 deletions src/ToRawSqlServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PyaeSoneAung\ToRawSql\Concerns\QueryBuilderMacros;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Illuminate\Foundation\Application;

class ToRawSqlServiceProvider extends PackageServiceProvider
{
Expand All @@ -14,8 +15,11 @@ class ToRawSqlServiceProvider extends PackageServiceProvider

public function boot(): void
{
$this->registerEloquentBuilderMacros();
$this->registerQueryBuilderMacros();
// skip if laravel version is greater than 10.14.1
if (version_compare(Application::VERSION, '10.14.1', '<=') === true) {
$this->registerEloquentBuilderMacros();
$this->registerQueryBuilderMacros();
}
}

public function configurePackage(Package $package): void
Expand Down

0 comments on commit d40f0b9

Please sign in to comment.