i need the code that will enable me fetch an entire table from the database and load it to my view. and also to the code that will display the item in my views
my controller:
public function index()
{
if(Auth::user()->usertype=='Admin')
{
$categories_count = Categories::count();
$news_count = News::count();
$published_news = News::where('status', 1)->count();
$unpublished_news = News::where('status', 0)->count();
$slider_news = News::where('slider_news', 'yes')->count();
$slidsder_news = News::where('slider_news', 'yes')->count();
$featured_news = News::where('featured_news', 'yes')->count();
$editor = User::where('usertype', 'Editor')->count();
}
else
{
$user_id=Auth::user()->id;
$news_count = News::where(['user_id' => $user_id])->count();
$published_news = News::where(['user_id' => $user_id, 'status' => '1'])->count();
$unpublished_news = News::where(['user_id' => $user_id, 'status' => '0'])->count();
}
return view('admin.pages.dashboard',compact('categories_count','news_count','published_news','unpublished_news','slider_news','featured_news','editor'));
}