<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;

class ParentNotification extends Model
{
    use HasFactory;

    
    /**
     * The attributes that are mass assignable.
     *
     * @var string[]
     */
    protected $fillable = [
        'parent_account_id',
        'message',
        'title',
        'payload',
        'read_at',
    ];


    public static function markAsRead($id)
    {
        $notification = self::find($id);
        if ($notification) {
            $notification->read_at = Carbon::now();
            return $notification->save();
        }
        return false;
    }

}
