Posts

Showing posts from December, 2020

Creating and Viewing a Subweddit

Image
  To begin making a subweddit, we must make 4 things -  A Subweddit model A make_subweddit_table migration A Subweddit factory (a useful laravel technique for filling a database table with fake data A subweddit Controller, to control the data All 3 can be made by the command : php artisan make:model Subweddit -fmc (the suffix -fmc does the magic, making the factory, migration and controller) For the miagration - this is the layout as it stands: Apart from the ordinary id and timestamps, the subweddit table contains the subweddit name, bio and mod_id, which, by default, is the user who created the subweddit, they will be able to delete the subweddit, and in the future remove posts as well as comments from posts.   Now we are able to fill in the factory to create some fake data. after altering SubwedditFactory.php to look like so and attempting to use the factory by running  factory(App\Models\Subweddit)->create();  I encountered a problem  PHP Fatal error...

Creating a login system with Jetstream & Livewire

Image
For this project I will be using Jetstream and Livewire to create a killer login system. This process couldn't be simpler, only requiring 3 lines of code. composer require laravel/jetstream php artisan jetstream:install livewire npm install && npm run dev and voila! a working authentication system! but let's make some personal tweaks.. Perfect... When signing up to Reddit.com, you are asked for your name AND  username, which is not available out the box with livewire, so we must adapt! Firstly, I added a new field in the Livewire's register.blade.php form to take in 'username'. The issue now being that Reddit does not allow spaces in their usernames. A quick bit of validation in Fortify's 'CreateNewUser' action using the argument 'alpha_dash' means that usernames may be alpha-numeric and also contain dashes and underscores. And make sure to persist these changes below! At this point, the form appeared to be displaying correctly, and valid...

Welcome to Weddit

Image
Welcome! In this blog I will be attempting to create a clone of Reddit.com using the PHP framework - Laravel.  This blog will follow my progress, analysis of code and include any problems encountered along the way, as well as any solutions (If I find any!).  Disclaimer: Weddit is purely a display of technical ability and as such is not fully GDPR compliant. Furthermore, this application will not be used for commercial or revenue purposes. The main features of this application will include: Authentication Subweddits (communities containing subweddit-specific posts) Posts (including authorization, validation, CRUD, media upload, likes, comments) Timeline Admin access Guest access For simplicity - I will ignore some features of reddit.com such as the 'hot' feature - this features takes in to account the popularity of a post coupled with its submission date. Progress can be tracked on my GitHub account here - https://github.com/ConvertToInt Sit back and enjoy the (not so smoo...