I try to get my category latest posts in main page
in Laravel 5.5 and I'm not sure how to do that.
Here is the code that I have:
View::composer('frontend.index', function ($view) {
$categoryone = Cateory::with('products')->where('category_id', $category)
->offset(1)
->limit(9)
->get();
$view->with('categoryone', $categoryone);
});
This is the error i get:
Class 'App\Providers\Cateory' not found
This is my AppServiceProvider
head:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\View;
use App\Category;
use DB;
class AppServiceProvider extends ServiceProvider
{
....
PS: except my question above, I need to know is there anyway that I can select my categories in admin panel and posts of that be shown in
homepage
instead of I statically load each category fromAppServiceProvider
or no?
If you worked with WP themes/plugins you can choose what category posts to be shown in front page from some sort of dropdown boxes.
Example:
I think you has a error typing
Use Category
instead of Cateory