First of all from a best practive standpoint, dont communicate with the data layer from a view.
Pass the data to a view using the controller.
For you problem:
Fix the if statement, you're trying to echo the condition.
invoke function of my controller
public function __invoke(Category $category)
{
$categories = Category::all();
return view('machine.edit', compact('category', 'categories'));
}