security fix and fix parent pages
API CI/CD / Validate (composer + pint) (push) Successful in 3m7s
API CI/CD / Test (PHPUnit) (push) Failing after 5m46s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 3m7s
API CI/CD / Test (PHPUnit) (push) Failing after 5m46s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Application;
|
||||
|
||||
class BaseModel extends Model
|
||||
{
|
||||
@@ -11,17 +10,6 @@ class BaseModel extends Model
|
||||
|
||||
public function getFillable(): array
|
||||
{
|
||||
if ($this->isTestingEnv()) {
|
||||
$columns = $this->tableColumns();
|
||||
if (! empty($columns)) {
|
||||
$key = $this->getKeyName();
|
||||
|
||||
return array_values(array_filter($columns, static function ($col) use ($key) {
|
||||
return $col !== $key;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
$fillable = parent::getFillable();
|
||||
if ($this->timestamps) {
|
||||
if (! in_array('created_at', $fillable, true)) {
|
||||
@@ -35,33 +23,6 @@ class BaseModel extends Model
|
||||
return $fillable;
|
||||
}
|
||||
|
||||
private function isTestingEnv(): bool
|
||||
{
|
||||
$env = getenv('APP_ENV')
|
||||
?: ($_SERVER['APP_ENV'] ?? ($_ENV['APP_ENV'] ?? null));
|
||||
|
||||
if ($env === 'testing') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (defined('PHPUNIT_COMPOSER_INSTALL') || defined('__PHPUNIT_PHAR__')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (function_exists('app')) {
|
||||
try {
|
||||
$app = app();
|
||||
if ($app instanceof Application && $app->runningUnitTests()) {
|
||||
return true;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// Fallback to env checks when the container isn't booted.
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function tableColumns(): array
|
||||
{
|
||||
if (self::$tableColumnsCache === null) {
|
||||
|
||||
Reference in New Issue
Block a user