diff --git a/src/Watchers/DeleteQueryWatcher.php b/src/Watchers/DeleteQueryWatcher.php index 43192a0..766c3ac 100644 --- a/src/Watchers/DeleteQueryWatcher.php +++ b/src/Watchers/DeleteQueryWatcher.php @@ -3,6 +3,7 @@ namespace Spatie\LaravelRay\Watchers; use Illuminate\Database\Events\QueryExecuted; +use Illuminate\Support\Str; use Spatie\Ray\Settings\Settings; class DeleteQueryWatcher extends ConditionalQueryWatcher @@ -14,7 +15,7 @@ public function register(): void $this->enabled = $settings->send_delete_queries_to_ray ?? false; $this->setConditionalCallback(function (QueryExecuted $query) { - return str_starts_with(strtolower($query->toRawSql()), 'delete'); + return Str::startsWith(strtolower($query->toRawSql()), 'delete'); }); } } diff --git a/src/Watchers/InsertQueryWatcher.php b/src/Watchers/InsertQueryWatcher.php index cdf6523..acc0419 100644 --- a/src/Watchers/InsertQueryWatcher.php +++ b/src/Watchers/InsertQueryWatcher.php @@ -3,6 +3,7 @@ namespace Spatie\LaravelRay\Watchers; use Illuminate\Database\Events\QueryExecuted; +use Illuminate\Support\Str; use Spatie\Ray\Settings\Settings; class InsertQueryWatcher extends ConditionalQueryWatcher @@ -14,7 +15,7 @@ public function register(): void $this->enabled = $settings->send_insert_queries_to_ray ?? false; $this->setConditionalCallback(function (QueryExecuted $query) { - return str_starts_with(strtolower($query->toRawSql()), 'insert'); + return Str::startsWith(strtolower($query->toRawSql()), 'insert'); }); } } diff --git a/src/Watchers/SelectQueryWatcher.php b/src/Watchers/SelectQueryWatcher.php index fb2dbe8..a403dbb 100644 --- a/src/Watchers/SelectQueryWatcher.php +++ b/src/Watchers/SelectQueryWatcher.php @@ -3,6 +3,7 @@ namespace Spatie\LaravelRay\Watchers; use Illuminate\Database\Events\QueryExecuted; +use Illuminate\Support\Str; use Spatie\Ray\Settings\Settings; class SelectQueryWatcher extends ConditionalQueryWatcher @@ -14,7 +15,7 @@ public function register(): void $this->enabled = $settings->send_select_queries_to_ray ?? false; $this->setConditionalCallback(function (QueryExecuted $query) { - return str_starts_with(strtolower($query->toRawSql()), 'select'); + return Str::startsWith(strtolower($query->toRawSql()), 'select'); }); } } diff --git a/src/Watchers/UpdateQueryWatcher.php b/src/Watchers/UpdateQueryWatcher.php index c3efaa0..10d0398 100644 --- a/src/Watchers/UpdateQueryWatcher.php +++ b/src/Watchers/UpdateQueryWatcher.php @@ -3,6 +3,7 @@ namespace Spatie\LaravelRay\Watchers; use Illuminate\Database\Events\QueryExecuted; +use Illuminate\Support\Str; use Spatie\Ray\Settings\Settings; class UpdateQueryWatcher extends ConditionalQueryWatcher @@ -14,7 +15,7 @@ public function register(): void $this->enabled = $settings->send_update_queries_to_ray ?? false; $this->setConditionalCallback(function (QueryExecuted $query) { - return str_starts_with(strtolower($query->toRawSql()), 'update'); + return Str::startsWith(strtolower($query->toRawSql()), 'update'); }); } } diff --git a/tests/Unit/ConditionalQueryTest.php b/tests/Unit/ConditionalQueryTest.php index 813dd85..58c362d 100644 --- a/tests/Unit/ConditionalQueryTest.php +++ b/tests/Unit/ConditionalQueryTest.php @@ -2,6 +2,7 @@ use Illuminate\Database\Events\QueryExecuted; use Illuminate\Support\Arr; +use Illuminate\Support\Str; use Spatie\LaravelRay\Tests\TestClasses\User; use Spatie\LaravelRay\Watchers\SelectQueryWatcher; use Spatie\Ray\Settings\Settings; @@ -51,7 +52,7 @@ it('can take a custom condition and only return those queries', function () { ray()->showConditionalQueries(function (QueryExecuted $query) { - return str_contains($query->toRawSql(), 'joan'); + return Str::contains($query->toRawSql(), 'joan'); }); User::query()->create(['email' => 'joan@example.com']); @@ -72,12 +73,12 @@ it('can handle multiple conditional query watchers', function () { $john = ray()->showConditionalQueries( function (QueryExecuted $query) { - return str_contains($query->toRawSql(), 'joan'); + return Str::contains($query->toRawSql(), 'joan'); }, function (): User { ray()->showConditionalQueries( function (QueryExecuted $query) { - return str_contains($query->toRawSql(), 'john'); + return Str::contains($query->toRawSql(), 'john'); }, null, 'look for john'