Skip to content
This repository was archived by the owner on Mar 15, 2024. It is now read-only.

Commit 0550e98

Browse files
committed
add database driver resolution trait
1 parent e052e9c commit 0550e98

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MichaelRubel\SqlFunctionRepository\Traits;
6+
7+
use Illuminate\Database\MySqlConnection;
8+
use Illuminate\Database\PostgresConnection;
9+
use Illuminate\Database\SQLiteConnection;
10+
use Illuminate\Support\Facades\DB;
11+
12+
trait ResolvesDatabaseDriver
13+
{
14+
/**
15+
* Determine whether the application is using the SQLite database driver.
16+
*
17+
* @return bool
18+
*/
19+
public function usingSQLite(): bool
20+
{
21+
return DB::connection() instanceof SQLiteConnection;
22+
}
23+
24+
/**
25+
* Determine whether the application is using the MySQL database driver.
26+
*
27+
* @return bool
28+
*/
29+
public function usingMySQL(): bool
30+
{
31+
return DB::connection() instanceof MySqlConnection;
32+
}
33+
34+
/**
35+
* Determine whether the application is using the Postgres database driver.
36+
*
37+
* @return bool
38+
*/
39+
public function usingPostgres(): bool
40+
{
41+
return DB::connection() instanceof PostgresConnection;
42+
}
43+
}

0 commit comments

Comments
 (0)