Caching and og title
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Article;
|
||||
|
||||
class NameSpaceController extends Controller
|
||||
@@ -17,11 +18,16 @@ class NameSpaceController extends Controller
|
||||
if (!array_key_exists($namespace, config('karudhaas.topic_filters'))) return redirect('/namespaces');
|
||||
|
||||
$options = config("karudhaas.topic_filters." . $namespace);
|
||||
|
||||
$articles = Cache::remember("articles.$namespace", 600, function () use ($options) {
|
||||
return Article::with('source')->whereHas('topics', function ($q) use ($options) {
|
||||
$q->whereIn('slug', $options["keys"]);
|
||||
})->latest('published_date')->limit(8)->get();
|
||||
});
|
||||
|
||||
return view('namespaces.show', [
|
||||
'options' => $options,
|
||||
'articles' => Article::with('source')->whereHas('topics', function ($q) use ($options) {
|
||||
$q->whereIn('slug', $options["keys"]);
|
||||
})->latest('published_date')->paginate(8)
|
||||
'articles' => $articles
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user