I will use the category a lot of places in my views to show, is there a way to insert somewhere so that I can use it in every view without getting this error Undefined variable: categories
At the moment i am doing it like this for every view:
$categories=Category::all();
return view('posts.create',compact('categories'));
$categories=Category::all();
return view('posts.edit',compact('categories'));
and so on..