13. Notable Code Snippets Within Views
This blog will explore a few code snippets within views which could be easily overlooked. This is important as it highlights ways in which the application was improved to make for a better user experience. Dynamic navigation: Guest users and authenticated users will see different navigation links. This was achieved using an @guest tag. All HTML code within the opening @guest tag will be seen by guest users only, the HTML code within the @else tag will be seen by logged in users. This screen capture is taken from the application's only layout file (resources/views/layouts/app.blade.php). Additional information on posts: The following snippet shows how I was able to show some extra information on each post. I chose to show the name of the author and the date/time when a post was first published - I displayed this using a custom format to aid readability using the format() method. I also added a user-friendly time difference (e.g. 2 days ago), by using the diffForHumans() method. Usin...