bug fixes, daily reports, holidays

This commit is contained in:
Kwesi Banson Jnr
2026-09-08 08:01:08 +00:00
parent 26f23c825a
commit c96e49ccdf
23 changed files with 1148 additions and 160 deletions

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class DailyReport extends Model
{
protected $fillable = ['user_id', 'report_date', 'content'];
protected $casts = [
'report_date' => 'date',
];
public function user()
{
return $this->belongsTo(StaffMember::class);
}
}

View File

@@ -29,4 +29,21 @@ class OfficeLocation extends Model
{
return $this->hasMany(OfficeLocationDocument::class, 'office_location_id');
}
public function holidays()
{
return $this->hasMany(PublicHoliday::class)->orderBy('holiday_date');
}
public function isHoliday($date)
{
$parsedDate = \Carbon\Carbon::parse($date);
return $this->holidays()->where(function($query) use ($parsedDate) {
$query->whereDate('holiday_date', $parsedDate->format('Y-m-d'))
->orWhere(function($q) use ($parsedDate) {
$q->where('is_recurring', true)
->whereMonth('holiday_date', $parsedDate->month)
->whereDay('holiday_date', $parsedDate->day);
});
})->exists();
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class PublicHoliday extends Model
{
protected $fillable = ['office_location_id', 'name', 'holiday_date', 'is_recurring'];
// protected $guarded = ['id']
protected $casts = [
'holiday_date' => 'date',
'is_recurring' => 'boolean',
];
public function location()
{
return $this->belongsTo(OfficeLocation::class, 'office_location_id');
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ReportOverride extends Model
{
protected $guarded = ['id'];
}

View File

@@ -27,7 +27,13 @@ class StaffMember extends Authenticatable
public function dependents() {
return $this->hasMany(StaffDependent::class, 'staff_id');
}
public function dailyReports() {
return $this->hasMany(DailyReport::class, 'user_id');
}
public function department(){
return $this->hasOne('App\Models\Department', 'id', 'department_id');
}
// 4. Cast dates correctly
protected $casts = [
// 'dob' => 'date',