Skip to content

Commit

Permalink
docs: add blade example
Browse files Browse the repository at this point in the history
  • Loading branch information
mydnic authored Nov 14, 2024
1 parent 928d91e commit e56b3c5
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,51 @@ export default defineComponent({
</script>
```

#### Laravel Blade

```php
class ChangelogController
{
public function __invoke()
{
$changelog = DB::table(config('changelog-commit-for-laravel.table_name'))
->select('message', 'date')
->orderBy('date', 'desc')
->paginate(10);

// Group by date
$groupedChangelog = $changelog->getCollection()->groupBy('date');

return view('changelog', [
'groupedChangelog' => $groupedChangelog,
'pagination' => $changelog // Pass pagination object
]);
}
}
```

```html
<div>
@foreach ($groupedChangelog as $date => $items)
<h2 class="text-lg font-semibold text-gray-800 mt-5 mb-1 capitalize">
{{ \Carbon\Carbon::parse($date)->translatedFormat('l d M Y') }}
</h2>
<ul class="list-disc pl-4 text-gray-600 space-y-1">
@foreach ($items as $item)
<li class="text-sm">
{{ $item->message }}
</li>
@endforeach
</ul>
@endforeach

{{-- Laravel Pagination Links --}}
<div class="mt-10">
{{ $pagination->links() }}
</div>
</div>
```

## Testing

```bash
Expand Down

0 comments on commit e56b3c5

Please sign in to comment.