Add (posts)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Category;
|
||||
use App\Models\CountryLocale;
|
||||
use App\Models\Post;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Stevebauman\Location\Facades\Location;
|
||||
@@ -27,7 +28,35 @@ public function country(Request $request, $country)
|
||||
|
||||
$request->session()->put('view_country_locale', $country_locale);
|
||||
|
||||
return view('front.country', ['country_locale' => $country_locale]);
|
||||
$featured_posts = Post::select('posts.*')
|
||||
->join('post_categories','posts.id','=', 'post_categories.post_id')
|
||||
->join('categories','post_categories.category_id','=', 'categories.id')
|
||||
->whereNotNull('post_categories.id')
|
||||
->whereNotNull('categories.id')
|
||||
->where('categories.country_locale_slug', $country_locale->slug)
|
||||
->where('posts.featured', true)
|
||||
->where('posts.status', 'publish')
|
||||
->orderBy('posts.updated_at', 'desc')
|
||||
->take(3)
|
||||
->get();
|
||||
|
||||
|
||||
$latest_posts = Post::select('posts.*')
|
||||
->join('post_categories','posts.id','=', 'post_categories.post_id')
|
||||
->join('categories','post_categories.category_id','=', 'categories.id')
|
||||
->whereNotNull('post_categories.id')
|
||||
->whereNotNull('categories.id')
|
||||
->where('categories.country_locale_slug', $country_locale->slug)
|
||||
->where('posts.featured', true)
|
||||
->whereNotIn('posts.id', $featured_posts->pluck('id')->toArray())
|
||||
->where('posts.status', 'publish')
|
||||
->orderBy('posts.updated_at', 'desc')
|
||||
->distinct()
|
||||
->take(20)
|
||||
->get();
|
||||
|
||||
return view('front.country', compact('country_locale','featured_posts','latest_posts')
|
||||
);
|
||||
}
|
||||
|
||||
return redirect()->route('home.country', ['country' => config('platform.general.fallback_country_slug')]);
|
||||
@@ -50,6 +79,13 @@ public function countryCategory(Request $request, $country, $category)
|
||||
return view('front.country_category', ['country_locale' => $country_locale, 'category' => $category]);
|
||||
}
|
||||
|
||||
public function all(Request $request, $country)
|
||||
{
|
||||
$country_locale = CountryLocale::where('slug', $country)->first();
|
||||
|
||||
return view('front.country_all', ['country_locale' => $country_locale]);
|
||||
}
|
||||
|
||||
public function posts(Request $request, $country)
|
||||
{
|
||||
return "{$country} : all posts";
|
||||
|
||||
Reference in New Issue
Block a user