public function assignCourse($product) { $this->products()->save(Product::whereName($product)->firstOrFail()); }