fix: initialize Capsule static database access
parent
cf6ab25c47
commit
2cd7b7a16e
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
$source = file_get_contents(
|
||||
dirname(__DIR__) . '/app/Services/Boot.php'
|
||||
);
|
||||
if ($source === false) {
|
||||
throw new RuntimeException('Unable to read the database bootstrap.');
|
||||
}
|
||||
|
||||
$start = strpos($source, 'public static function bootDb()');
|
||||
$end = strpos($source, 'private static function bootPaginator()', $start ?: 0);
|
||||
if ($start === false || $end === false || $end <= $start) {
|
||||
throw new RuntimeException('Unable to isolate Boot::bootDb().');
|
||||
}
|
||||
$method = substr($source, $start, $end - $start);
|
||||
$global = strpos($method, '$capsule->setAsGlobal();');
|
||||
$eloquent = strpos($method, '$capsule->bootEloquent();');
|
||||
|
||||
if ($global === false || $eloquent === false || $global > $eloquent) {
|
||||
throw new RuntimeException(
|
||||
'Boot::bootDb() must initialize Capsule static queries before Eloquent.'
|
||||
);
|
||||
}
|
||||
|
||||
echo "Boot database global contract tests passed\n";
|
||||
Loading…
Reference in New Issue