I can't change middleware
Closed this issue · 4 comments
I want show visitLog only Admin user, how can i do?
If you want to show visitlogs in your own way (in this case to admins only), you can set visitlog_page
in config/visitlog.php
to false
to disable default viewer page.
Later on your app, you can use VisitLog
facade to get all visit log entries from database and show them however you like something like:
if (! $user->isAdmin()) {
// show 404 to non-admins
abort();
}
$visitLogs = VisitLog::all();
// pass $visitLogs to your custom view and iterate over them in your table/whatever
I did the same, but i can't set VisitLog::latest()->paginate(10);
VisitLog::orderBy('name', 'desc')->get();
or something, Why?
because Facade
does not have latest
method. You need to use its model so change:
use Sarfraznawaz2005\VisitLog\Facades\VisitLog;
to
use Sarfraznawaz2005\VisitLog\Models\VisitLog;
and then you can do $visitLogs = VisitLog::latest()->paginate(10);
Thank you so much, It's helpful
This is very good for me.