Level 39
Hello, @xaad67 !
You need to create something like the following:
- order your collection by title and group them by the first letter:
Company::orderBy('brand')->get()->groupBy(function($company) ({
# insert your restriction
}));
- inside the groupBy method pass a closure with your restriction, for example, the first letter. You can use substr to get the first character of a string.
https://www.php.net/manual/en/function.substr.php
- in your views, filter these collections as needed.
Check the docs for how to group these collections: https://laravel.com/docs/5.8/queries
Let me know if it helps.