PHP code example of deifhelt / laravel-activity-presenter
1. Go to this page and download the library: Download deifhelt/laravel-activity-presenter library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
deifhelt / laravel-activity-presenter example snippets
use Deifhelt\ActivityPresenter\Facades\ActivityPresenter;
use Spatie\Activitylog\Models\Activity;
public function index()
{
// Fetch logs (paginated)
$activities = Activity::latest()->paginate(20);
// Present them (loads relations, formats dates, translates events)
$presented = ActivityPresenter::presentCollection($activities);
return view('activities.index', [
'activities' => $presented
]);
}
bash
php artisan vendor:publish --provider="Deifhelt\ActivityPresenter\ActivityPresenterServiceProvider"