'boolean', 'created_at' => 'datetime', 'updated_at' => 'datetime' ]; protected static function boot() { parent::boot(); static::creating(function ($note) { if (empty($note->unique_id)) { $note->unique_id = Str::uuid(); } }); } public function user() { return $this->belongsTo(User::class); } public function scopeActive($query) { return $query->where('completed', false); } public function scopeForUser($query, $userId = null) { if ($userId) { return $query->where('user_id', $userId); } return $query->whereNull('user_id'); } }