add tests batch 20

This commit is contained in:
root
2026-06-09 01:03:53 -04:00
parent 95efb9652e
commit 6be4875c5e
1502 changed files with 13797 additions and 11313 deletions
+9 -15
View File
@@ -3,6 +3,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Section extends BaseModel
@@ -16,7 +17,6 @@ class Section extends BaseModel
'updated_at',
'updated_by',
];
public $timestamps = true;
protected $casts = [
@@ -49,13 +49,11 @@ 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}%");
});
}
@@ -80,9 +78,7 @@ 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();
@@ -95,9 +91,7 @@ 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();
}
@@ -110,9 +104,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'],
];
}
}
}