PHP code example of mydnic / changelog-commit-for-laravel
1. Go to this page and download the library: Download mydnic/changelog-commit-for-laravel 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/ */
mydnic / changelog-commit-for-laravel example snippets
return [
/**
* The name of the table to store the changelog in.
*/
'table_name' => 'changelogs',
/**
* The GitHub access token to use to fetch the commit history.
*/
'github_access_token' => env('GITHUB_ACCESS_TOKEN'),
/**
* The GitHub repositories to fetch the commit history from.
*/
'github_repositories' => [
'mydnic/changelog-commit-for-laravel', // change me
// other repositories if you want to fetch the commit history from multiple repositories
// To specify a branch, make it an array like this one below:
// [ 'mydnic/changelog-commit-for-laravel', 'main' ]
],
];
use Mydnic\ChangelogCommitForLaravel\Models\Changelog;
$changelogs = Changelog::latest('date')->paginate(50);
return view('changelog', compact('changelogs'));
// or return JSON response
return response()->json($changelogs);
class ChangelogController
{
public function __invoke()
{
$changelog = DB::table(config('changelog-commit-for-laravel.table_name'))
->select('message', 'date', 'branch')
->orderBy('date', 'desc')
->paginate(10);
// Group by date
$groupedChangelog = $changelog->getCollection()->groupBy('date');
return view('changelog', [
'groupedChangelog' => $groupedChangelog,
'pagination' => $changelog // Pass pagination object
]);
}
}