-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove Doctrine/DBAL dependency. Add enum mapper for SQLite.
- Loading branch information
1 parent
65d1f1b
commit 5bd255d
Showing
8 changed files
with
67 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TheDoctor0\LaravelFactoryGenerator\Database; | ||
|
||
use Illuminate\Support\Facades\DB; | ||
|
||
class EnumSqlite extends EnumDriver | ||
{ | ||
public function values(): ?array | ||
{ | ||
$query = DB::raw(" | ||
SELECT sql FROM sqlite_schema | ||
WHERE tbl_name = '{$this->table}' | ||
"); | ||
|
||
$type = DB::connection($this->connection) | ||
->select($query->getValue(DB::connection()->getQueryGrammar())); | ||
|
||
preg_match_all("/check \(\"{$this->field}\" in \((.+?)\)\)/", $type[0]->sql, $matches); | ||
|
||
if (isset($matches[1][0])) { | ||
return collect(explode(',', $matches[1][0]))->map(function ($value) { | ||
return trim(trim($value), "'"); | ||
})->toArray(); | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.