Add (post manage)
Add (post country viewing)
This commit is contained in:
@@ -23,6 +23,7 @@ public function __construct()
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('admin.home');
|
||||
return redirect()->route('posts.manage');
|
||||
//return view('admin.home');
|
||||
}
|
||||
}
|
||||
|
||||
27
app/Http/Controllers/Admin/PostController.php
Normal file
27
app/Http/Controllers/Admin/PostController.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Post;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PostController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$posts = Post::with('post_categories.category.country_locale')->orderBy('created_at', 'desc')->paginate();
|
||||
|
||||
return view('admin.posts.manage', compact('posts'));
|
||||
}
|
||||
|
||||
public function new(Request $request)
|
||||
{
|
||||
return 'PostController@new';
|
||||
}
|
||||
|
||||
public function edit(Request $request, $post_id)
|
||||
{
|
||||
return 'PostController@edit : '.$post_id;
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,6 @@
|
||||
use App\Models\Post;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Stevebauman\Location\Facades\Location;
|
||||
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
@@ -25,37 +22,35 @@ public function country(Request $request, $country)
|
||||
$country_locale = CountryLocale::where('slug', $country)->first();
|
||||
|
||||
if (! is_null($country_locale)) {
|
||||
|
||||
|
||||
$request->session()->put('view_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();
|
||||
->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();
|
||||
->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)
|
||||
->whereNotIn('posts.id', $featured_posts->pluck('id')->toArray())
|
||||
->where('posts.status', 'publish')
|
||||
->orderBy('posts.updated_at', 'desc')
|
||||
->distinct()
|
||||
->take(10)
|
||||
->get();
|
||||
|
||||
return view('front.country', compact('country_locale','featured_posts','latest_posts')
|
||||
return view('front.country', compact('country_locale', 'featured_posts', 'latest_posts')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -67,32 +62,57 @@ public function countryCategory(Request $request, $country, $category)
|
||||
$country_locale = CountryLocale::where('slug', $country)->first();
|
||||
|
||||
if (is_null($country_locale)) {
|
||||
abort(404);
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$category = Category::where('slug', $category)->where('enabled', true)->first();
|
||||
$category = Category::where('slug', $category)->where('enabled', true)->first();
|
||||
|
||||
if (is_null($category))
|
||||
{
|
||||
abort(404);
|
||||
}
|
||||
return view('front.country_category', ['country_locale' => $country_locale, 'category' => $category]);
|
||||
if (is_null($category)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$latest_posts = Post::with('post_categories')->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('categories.id', $category->id)
|
||||
->where('posts.status', 'publish')
|
||||
->orderBy('posts.updated_at', 'desc')
|
||||
->distinct()
|
||||
->paginate(15);
|
||||
|
||||
return view('front.country_category', compact('country_locale', 'category', 'latest_posts'));
|
||||
}
|
||||
|
||||
public function all(Request $request, $country)
|
||||
{
|
||||
$country_locale = CountryLocale::where('slug', $country)->first();
|
||||
$country_locale = CountryLocale::where('slug', $country)->first();
|
||||
|
||||
return view('front.country_all', ['country_locale' => $country_locale]);
|
||||
$latest_posts = Post::with('post_categories')->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.status', 'publish')
|
||||
->orderBy('posts.updated_at', 'desc')
|
||||
->distinct()
|
||||
->paginate(15);
|
||||
|
||||
return view('front.country_all', compact('country_locale', 'latest_posts'));
|
||||
}
|
||||
|
||||
public function posts(Request $request, $country)
|
||||
public function post(Request $request, $country, $post_slug)
|
||||
{
|
||||
return "{$country} : all posts";
|
||||
}
|
||||
$post = Post::where('slug', $post_slug)->where('status', 'publish')->first();
|
||||
|
||||
if (! is_null($post)) {
|
||||
|
||||
return view('front.post', compact('post'));
|
||||
}
|
||||
abort(404);
|
||||
|
||||
public function post(Request $request, $country, $post)
|
||||
{
|
||||
return "{$country} : {$post}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user