fix gitlab tests
This commit is contained in:
+15
-14
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class Event extends BaseModel
|
||||
{
|
||||
protected $table = 'events';
|
||||
@@ -24,9 +26,9 @@ class Event extends BaseModel
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'amount' => 'decimal:2', // adjust precision if needed
|
||||
'amount' => 'decimal:2', // adjust precision if needed
|
||||
'expiration_date' => 'date', // change to 'datetime' if stored as DATETIME
|
||||
'created_by' => 'integer',
|
||||
'created_by' => 'integer',
|
||||
];
|
||||
|
||||
/* Optional relationships */
|
||||
@@ -52,7 +54,7 @@ class Event extends BaseModel
|
||||
$q = static::query()
|
||||
->whereDate('expiration_date', '>=', now()->toDateString());
|
||||
|
||||
if (! empty($schoolYear)) {
|
||||
if (!empty($schoolYear)) {
|
||||
$q->where('school_year', $schoolYear);
|
||||
}
|
||||
|
||||
@@ -65,9 +67,9 @@ class Event extends BaseModel
|
||||
public static function getEventsByName(string $name, ?string $schoolYear = null)
|
||||
{
|
||||
$q = static::query()
|
||||
->where('event_name', 'like', '%'.$name.'%');
|
||||
->where('event_name', 'like', '%' . $name . '%');
|
||||
|
||||
if (! empty($schoolYear)) {
|
||||
if (!empty($schoolYear)) {
|
||||
$q->where('school_year', $schoolYear);
|
||||
}
|
||||
|
||||
@@ -81,7 +83,7 @@ class Event extends BaseModel
|
||||
{
|
||||
$q = static::query();
|
||||
|
||||
if (! empty($schoolYear)) {
|
||||
if (!empty($schoolYear)) {
|
||||
$q->where('school_year', $schoolYear);
|
||||
}
|
||||
|
||||
@@ -94,7 +96,6 @@ class Event extends BaseModel
|
||||
public static function addEvent(array $data): int
|
||||
{
|
||||
$row = static::create($data);
|
||||
|
||||
return (int) $row->id;
|
||||
}
|
||||
|
||||
@@ -105,7 +106,7 @@ class Event extends BaseModel
|
||||
{
|
||||
$q = static::query()->whereDate('expiration_date', $date);
|
||||
|
||||
if (! empty($schoolYear)) {
|
||||
if (!empty($schoolYear)) {
|
||||
$q->where('school_year', $schoolYear);
|
||||
}
|
||||
|
||||
@@ -120,11 +121,11 @@ class Event extends BaseModel
|
||||
$q = static::query()
|
||||
->whereDate('expiration_date', '>=', now()->toDateString());
|
||||
|
||||
if (! empty($schoolYear)) {
|
||||
if (!empty($schoolYear)) {
|
||||
$q->where('school_year', $schoolYear);
|
||||
}
|
||||
|
||||
if (! empty($semester)) {
|
||||
if (!empty($semester)) {
|
||||
$q->where('semester', $semester);
|
||||
}
|
||||
|
||||
@@ -138,7 +139,7 @@ class Event extends BaseModel
|
||||
{
|
||||
$q = static::query()->whereKey($id);
|
||||
|
||||
if (! empty($schoolYear)) {
|
||||
if (!empty($schoolYear)) {
|
||||
$q->where('school_year', $schoolYear);
|
||||
}
|
||||
|
||||
@@ -152,7 +153,7 @@ class Event extends BaseModel
|
||||
{
|
||||
$q = static::query()->whereKey($id);
|
||||
|
||||
if (! empty($schoolYear)) {
|
||||
if (!empty($schoolYear)) {
|
||||
$q->where('school_year', $schoolYear);
|
||||
}
|
||||
|
||||
@@ -166,10 +167,10 @@ class Event extends BaseModel
|
||||
{
|
||||
$q = static::query()->whereKey($id);
|
||||
|
||||
if (! empty($schoolYear)) {
|
||||
if (!empty($schoolYear)) {
|
||||
$q->where('school_year', $schoolYear);
|
||||
}
|
||||
|
||||
return (bool) $q->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user