fix tests

This commit is contained in:
root
2026-06-11 11:46:12 -04:00
parent c91fa2ce4d
commit 5ead80fdc7
1489 changed files with 11349 additions and 10305 deletions
+15 -9
View File
@@ -3,7 +3,6 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Section extends BaseModel
@@ -17,6 +16,7 @@ class Section extends BaseModel
'updated_at',
'updated_by',
];
public $timestamps = true;
protected $casts = [
@@ -49,11 +49,13 @@ class Section extends BaseModel
public function scopeSearch(Builder $q, string $term): Builder
{
$term = trim($term);
if ($term === '') return $q;
if ($term === '') {
return $q;
}
return $q->where(function (Builder $w) use ($term) {
$w->where('section_name', 'like', "%{$term}%")
->orWhere('description', 'like', "%{$term}%");
->orWhere('description', 'like', "%{$term}%");
});
}
@@ -78,7 +80,9 @@ class Section extends BaseModel
public static function updateSection(int $sectionId, array $data): bool
{
$section = static::query()->find($sectionId);
if (!$section) return false;
if (! $section) {
return false;
}
// Laravel will set updated_at automatically when saving
return $section->fill($data)->save();
@@ -91,7 +95,9 @@ class Section extends BaseModel
public static function deleteSection(int $sectionId): bool
{
$section = static::query()->find($sectionId);
if (!$section) return false;
if (! $section) {
return false;
}
return (bool) $section->delete();
}
@@ -104,9 +110,9 @@ class Section extends BaseModel
public static function rules(?int $id = null): array
{
return [
'section_name' => ['required', 'string', 'max:255', 'unique:sections,section_name,' . ($id ?? 'NULL') . ',id'],
'description' => ['nullable', 'string', 'max:2000'],
'updated_by' => ['nullable', 'integer'],
'section_name' => ['required', 'string', 'max:255', 'unique:sections,section_name,'.($id ?? 'NULL').',id'],
'description' => ['nullable', 'string', 'max:2000'],
'updated_by' => ['nullable', 'integer'],
];
}
}
}