Caching and og title

This commit is contained in:
2021-01-11 19:36:39 +05:00
parent 0d78b68804
commit 09e544d361
4 changed files with 28 additions and 4 deletions

View File

@@ -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
]);
}
}