- **Sentry** wired in bootstrap/app.php via Sentry\Laravel\Integration.
No-op when SENTRY_LARAVEL_DSN is empty.
- **Audit logging** broadened: LogsActivity applied to Household, QrCode,
Trip, Payment with tight logOnly whitelists and named log channels
('household', 'qr_code', 'trip', 'payment') to keep the activity
stream useful.
- **Bulk admin actions**:
POST /admin/households/bulk-approve — skips already-approved /
no-proof / unknown ids, reports per-id outcomes
POST /admin/bulk/users/{suspend,activate} — admins protected
POST /admin/bulk/qr-codes/void — respects state machine transitions
- **FCM push scaffold**: PushDriver contract with LogPushDriver
(default) and FcmPushDriver (activates when FCM_SERVER_KEY is set).
PushChannel adapts notifications. RoutesByPreferences now also
routes via push when push_enabled + fcm_token. toPush() payloads
added to HouseholdApproved / QrBalanceLow / PickupImminent.
- **Reverb WebSocket broadcast**: laravel/reverb installed.
TruckLocationBroadcast fires on every TruckTracker::record().
routes/channels.php authenticates: admins → private-admin.live,
residents → area.{id}.trucks (only if their household barangay is
covered by the service area).
- **PSGC seeder** expanded: all 17 PH regions, 4 NCR districts,
all 17 NCR cities. Sample barangays still carry rectangular
boundaries for point-in-polygon resolution tests.
- **Conditional SPATIAL INDEX migration** for barangays.boundary —
safe no-op until every row has a polygon (i.e., after full PSA
dataset import). Re-running `php artisan migrate` after import
flips the column to NOT NULL and adds the index.
196 feature tests passing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
88 lines
2.3 KiB
PHP
88 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\HasProfileVerification;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Support\Str;
|
|
use MatanYadaev\EloquentSpatial\Objects\Point;
|
|
use MatanYadaev\EloquentSpatial\Traits\HasSpatial;
|
|
use Spatie\Activitylog\LogOptions;
|
|
use Spatie\Activitylog\Traits\LogsActivity;
|
|
|
|
class Household extends Model
|
|
{
|
|
use HasFactory, HasProfileVerification, HasSpatial, LogsActivity, SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'uuid',
|
|
'head_user_id',
|
|
'barangay_id',
|
|
'address_line',
|
|
'coordinates',
|
|
'household_size',
|
|
'proof_of_residency_path',
|
|
'assigned_drop_off_point_id',
|
|
'verification_status',
|
|
'verified_at',
|
|
'verified_by_admin_id',
|
|
'rejection_reason',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'coordinates' => Point::class,
|
|
'verified_at' => 'datetime',
|
|
'household_size' => 'integer',
|
|
];
|
|
}
|
|
|
|
public function getRouteKeyName(): string
|
|
{
|
|
return 'uuid';
|
|
}
|
|
|
|
public function getActivitylogOptions(): LogOptions
|
|
{
|
|
return LogOptions::defaults()
|
|
->logOnly(['verification_status', 'verified_by_admin_id', 'rejection_reason', 'assigned_drop_off_point_id'])
|
|
->logOnlyDirty()
|
|
->dontSubmitEmptyLogs()
|
|
->useLogName('household');
|
|
}
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (self $h): void {
|
|
if (empty($h->uuid)) {
|
|
$h->uuid = (string) Str::uuid();
|
|
}
|
|
});
|
|
}
|
|
|
|
public function head(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'head_user_id');
|
|
}
|
|
|
|
public function barangay(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Barangay::class);
|
|
}
|
|
|
|
public function members(): HasMany
|
|
{
|
|
return $this->hasMany(HouseholdMember::class);
|
|
}
|
|
|
|
public function assignedDropOffPoint(): BelongsTo
|
|
{
|
|
return $this->belongsTo(DropOffPoint::class, 'assigned_drop_off_point_id');
|
|
}
|
|
}
|