Laravel Articles

I am currently learning Laravel. When I have learnt something I know I’ll be coming back to, I find it useful to write out the key points in a post so that it is cemented in my brain!

It is also useful as a repository so that I can come and find it again when I need it. If these posts help anyone else, then great. If you see an error in one of my posts, then please let me know. Thanks for reading.

Creating Dummy Articles with the Same User using Laravel Eloquent

If you have set up your Laravel installation with --auth, then you will already have a User class and Factory. Then set up your Factory to create an article, it will look something like this: $factory->define(Article::class, function (Faker $faker) { return [...

Hosting for Laravel Apps (and others)

I have struggled to find a good host for testing my Laravel apps. My existing host I can't use because my sites are on a shared server. So, I have tried AWS and Azure but to no avail, they were too complicated and too expensive and in the end my apps just weren't...

A Simple Create Post Form with Validation

A simple form with basic validation. ArticlesController.php public function store() { //validation request()->validate([ 'title' => 'required', 'body' => 'required' ]); // persist the resource $article = new Article(); $article->title = request('title');...

Laravel: Change Default Error Pages

If you want to replace the default Laravel error pages (e.g. 401, 419, 500) then it's pretty straightforward. All you need to do is create a new folder in the 'views' directory and call it 'errors'. Then create your new error pages and use the following naming...