Posts

13. Notable Code Snippets Within Views

Image
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...

14. Notable Bugs Encountered

Image
This blog post will highlight some of the bugs within my application, which I encountered during development. These bugs took longer than expected to fix, requiring me to fiddle about with and tweak the code multiple times until a solution was reached.   Bug 1: Correctly displaying the body text of blog posts Originally, I used the code snippet below to display text from the 'body' column of the posts table within the post show (resources/views/posts/show.blade.php) and home (resources/views/home.blade.php) views. I didn't realise any issues at first, as the paragraphs generated with faker were short. There was no indication that line breaks were being ignored. However, after creating a longer post myself, which used line breaks, I noticed that these breaks between paragraphs were absent. To fix this issue, I wrapped the data to be displayed in {!! [data] !!} syntax, which prevents character escaping. However, this opens up the application to receive XSS attacks. To avoid t...

15. My Conclusion

It is now time to draw the curtains on my Laravel project, so this post will conclude my work and experience. This has been a very rewarding and enjoyable project for me to work through. I'm not overly confident when it comes to working with web frameworks in general and I have struggled in the past to get to grips with MVC architecture. I feel that this project has genuinely provided me with a massive amount of knowledge and learning that I will be able to utilise in future projects/work, whether they are educational or industrial. I was able to delve into the mechanics of controllers, models and views and learn about their implementation within Laravel. Initially, this was overwhelming and I felt like I faced a learning curve which I would struggle to overcome. However, with persistence and research, I was able to confidently build my blog application. I look forward to building upon my newly learned skills and imparting what I've learned onto others. In terms of the applicat...