completed)) { $task->completed = false; // Ensure completed is false when creating a new task } $task->user_id = Auth::id(); // Set user_id automatically }); } /* protected $attributes = [ 'completed' => false, // Set default value for completed ]; */ public function user() { return $this->belongsTo(User::class); } public function category() { return $this->belongsTo(Category::class); } }