fix tests
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -31,12 +30,12 @@ class CalendarEvent extends BaseModel
|
||||
|
||||
protected $casts = [
|
||||
// If your column is DATE use 'date', if it's DATETIME use 'datetime'
|
||||
'date' => 'date',
|
||||
'notify_parent' => 'boolean',
|
||||
'notify_admin' => 'boolean',
|
||||
'date' => 'date',
|
||||
'notify_parent' => 'boolean',
|
||||
'notify_admin' => 'boolean',
|
||||
'notify_teacher' => 'boolean',
|
||||
'no_school' => 'integer',
|
||||
'event_type' => 'string',
|
||||
'no_school' => 'integer',
|
||||
'event_type' => 'string',
|
||||
];
|
||||
|
||||
private static ?bool $hasEventTypeColumn = null;
|
||||
@@ -48,18 +47,21 @@ class CalendarEvent extends BaseModel
|
||||
public static function getEvents()
|
||||
{
|
||||
$events = static::query()->get()->toArray();
|
||||
|
||||
return static::withNoSchoolFlag($events);
|
||||
}
|
||||
|
||||
public static function getEventByDate(string $date): array
|
||||
{
|
||||
$events = static::query()->where('date', $date)->get()->toArray();
|
||||
|
||||
return static::withNoSchoolFlag($events);
|
||||
}
|
||||
|
||||
public static function addEvent(array $data): int
|
||||
{
|
||||
$row = static::create($data);
|
||||
|
||||
return (int) $row->id;
|
||||
}
|
||||
|
||||
@@ -92,6 +94,7 @@ class CalendarEvent extends BaseModel
|
||||
if (static::$hasEventTypeColumn === null) {
|
||||
static::$hasEventTypeColumn = static::columnExists((new static)->getTable(), 'event_type');
|
||||
}
|
||||
|
||||
return (bool) static::$hasEventTypeColumn;
|
||||
}
|
||||
|
||||
@@ -123,9 +126,9 @@ class CalendarEvent extends BaseModel
|
||||
*/
|
||||
protected static function isNoSchoolEvent(array $event): bool
|
||||
{
|
||||
$title = strtolower((string)($event['title'] ?? ''));
|
||||
$desc = strtolower((string)($event['description'] ?? ''));
|
||||
$text = $title . ' ' . $desc;
|
||||
$title = strtolower((string) ($event['title'] ?? ''));
|
||||
$desc = strtolower((string) ($event['description'] ?? ''));
|
||||
$text = $title.' '.$desc;
|
||||
|
||||
$keywords = ['no school', 'no-school', 'cancel', 'vacation', 'holiday', 'break'];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user